Fixed typo
[advent-of-code-15.git] / advent-of-code-22.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 22 - Advent of Code</title>
6 <!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
7 <link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
8 <link rel="stylesheet" type="text/css" href="/static/style.css?3"/>
9 <link rel="shortcut icon" href="/favicon.ico?2"/>
10 </head><!--
11
12
13
14
15 Oh, hello! Funny seeing you here.
16
17 I appreciate your enthusiasm, but you aren't going to find much down here.
18 There certainly aren't clues to any of the puzzles. You do risk spoiling a few
19 surprises for yourself, though. Best to play the normal way and discover
20 everything as it was intended, I think. The best surprises don't even appear
21 in the source until you unlock them for real.
22
23 Please be careful with automated requests; I'm not Google, and I can only take
24 so much traffic. Please be considerate so that everyone gets to play.
25
26 If you're curious about how Advent of Code works, it's running on some custom
27 Perl code. Other than a few integrations (auth, analytics, ads, social media),
28 I built the whole thing myself, including the design, animations, prose, and
29 all of the puzzles.
30
31 The puzzles probably took the longest; the easiest ones were around 45 minutes
32 each, but the harder ones took 2-3 hours, some even longer than that. A lot of
33 effort went into building this thing - I hope you're enjoying playing it as
34 much as I enjoyed making it for you!
35
36 If you'd like to hang out, I'm @ericwastl on Twitter.
37
38 - Eric Wastl
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 -->
90 <body>
91 <header><h1><a href="/">Advent of Code</a></h1><div class="user">Neil Smith <span class="star-count">44*</span></div><nav><ul><li><a href="/about">[About]</a></li><li><a href="/stats">[Stats]</a></li><li><a href="/leaderboard">[Leaderboard]</a></li><li><a href="/settings">[Settings]</a></li><li><a href="/auth/logout">[Log out]</a></li></ul></nav></header>
92
93 <div id="ad">
94 <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
95 <!-- Advent of Code Wide Skyscraper -->
96 <ins class="adsbygoogle"
97 style="display:inline-block;width:160px;height:600px"
98 data-ad-client="ca-pub-9420604735624631"
99 data-ad-slot="8014013294"></ins>
100 <script>
101 (adsbygoogle = window.adsbygoogle || []).push({});
102 </script>
103 </div><!--/ad-->
104
105 <main>
106 <article class="day-desc"><h2>--- Day 22: Wizard Simulator 20XX ---</h2><p>Little Henry Case decides that defeating bosses with <a href="/day/21">swords and stuff</a> is boring. Now he's playing the game with a <span title="Being a !@#$% Sorcerer.">wizard</span>. Of course, he gets stuck on another boss and needs your help again.</p>
107 <p>In this version, combat still proceeds with the player and the boss taking alternating turns. The player still goes first. Now, however, you don't get any equipment; instead, you must choose one of your spells to cast. The first character at or below <code>0</code> hit points loses.</p>
108 <p>Since you're a wizard, you don't get to wear armor, and you can't attack normally. However, since you do <em>magic damage</em>, your opponent's armor is ignored, and so the boss effectively has zero armor as well. As before, if armor (from a spell, in this case) would reduce damage below <code>1</code>, it becomes <code>1</code> instead - that is, the boss' attacks always deal at least <code>1</code> damage.</p>
109 <p>On each of your turns, you must select one of your spells to cast. If you cannot afford to cast any spell, you lose. Spells cost <em>mana</em>; you start with <em>500</em> mana, but have no maximum limit. You must have enough mana to cast a spell, and its cost is immediately deducted when you cast it. Your spells are Magic Missile, Drain, Shield, Poison, and Recharge.</p>
110 <ul>
111 <li><em>Magic Missile</em> costs <code>53</code> mana. It instantly does <code>4</code> damage.</li>
112 <li><em>Drain</em> costs <code>73</code> mana. It instantly does <code>2</code> damage and heals you for <code>2</code> hit points.</li>
113 <li><em>Shield</em> costs <code>113</code> mana. It starts an <em>effect</em> that lasts for <code>6</code> turns. While it is active, your armor is increased by <code>7</code>.</li>
114 <li><em>Poison</em> costs <code>173</code> mana. It starts an <em>effect</em> that lasts for <code>6</code> turns. At the start of each turn while it is active, it deals the boss <code>3</code> damage.</li>
115 <li><em>Recharge</em> costs <code>229</code> mana. It starts an <em>effect</em> that lasts for <code>5</code> turns. At the start of each turn while it is active, it gives you <code>101</code> new mana.</li>
116 </ul>
117 <p><em>Effects</em> all work the same way. Effects apply at the start of both the player's turns and the boss' turns. Effects are created with a timer (the number of turns they last); at the start of each turn, after they apply any effect they have, their timer is decreased by one. If this decreases the timer to zero, the effect ends. You cannot cast a spell that would start an effect which is already active. However, effects can be started on the same turn they end.</p>
118 <p>For example, suppose the player has <code>10</code> hit points and <code>250</code> mana, and that the boss has <code>13</code> hit points and <code>8</code> damage:</p>
119 <pre><code>-- Player turn --
120 - Player has 10 hit points, 0 armor, 250 mana
121 - Boss has 13 hit points
122 Player casts Poison.
123
124 -- Boss turn --
125 - Player has 10 hit points, 0 armor, 77 mana
126 - Boss has 13 hit points
127 Poison deals 3 damage; its timer is now 5.
128 Boss attacks for 8 damage.
129
130 -- Player turn --
131 - Player has 2 hit points, 0 armor, 77 mana
132 - Boss has 10 hit points
133 Poison deals 3 damage; its timer is now 4.
134 Player casts Magic Missile, dealing 4 damage.
135
136 -- Boss turn --
137 - Player has 2 hit points, 0 armor, 24 mana
138 - Boss has 3 hit points
139 Poison deals 3 damage. This kills the boss, and the player wins.
140 </code></pre>
141 <p>Now, suppose the same initial conditions, except that the boss has <code>14</code> hit points instead:</p>
142 <pre><code>-- Player turn --
143 - Player has 10 hit points, 0 armor, 250 mana
144 - Boss has 14 hit points
145 Player casts Recharge.
146
147 -- Boss turn --
148 - Player has 10 hit points, 0 armor, 21 mana
149 - Boss has 14 hit points
150 Recharge provides 101 mana; its timer is now 4.
151 Boss attacks for 8 damage!
152
153 -- Player turn --
154 - Player has 2 hit points, 0 armor, 122 mana
155 - Boss has 14 hit points
156 Recharge provides 101 mana; its timer is now 3.
157 Player casts Shield, increasing armor by 7.
158
159 -- Boss turn --
160 - Player has 2 hit points, 7 armor, 110 mana
161 - Boss has 14 hit points
162 Shield's timer is now 5.
163 Recharge provides 101 mana; its timer is now 2.
164 Boss attacks for 8 - 7 = 1 damage!
165
166 -- Player turn --
167 - Player has 1 hit point, 7 armor, 211 mana
168 - Boss has 14 hit points
169 Shield's timer is now 4.
170 Recharge provides 101 mana; its timer is now 1.
171 Player casts Drain, dealing 2 damage, and healing 2 hit points.
172
173 -- Boss turn --
174 - Player has 3 hit points, 7 armor, 239 mana
175 - Boss has 12 hit points
176 Shield's timer is now 3.
177 Recharge provides 101 mana; its timer is now 0.
178 Recharge wears off.
179 Boss attacks for 8 - 7 = 1 damage!
180
181 -- Player turn --
182 - Player has 2 hit points, 7 armor, 340 mana
183 - Boss has 12 hit points
184 Shield's timer is now 2.
185 Player casts Poison.
186
187 -- Boss turn --
188 - Player has 2 hit points, 7 armor, 167 mana
189 - Boss has 12 hit points
190 Shield's timer is now 1.
191 Poison deals 3 damage; its timer is now 5.
192 Boss attacks for 8 - 7 = 1 damage!
193
194 -- Player turn --
195 - Player has 1 hit point, 7 armor, 167 mana
196 - Boss has 9 hit points
197 Shield's timer is now 0.
198 Shield wears off, decreasing armor by 7.
199 Poison deals 3 damage; its timer is now 4.
200 Player casts Magic Missile, dealing 4 damage.
201
202 -- Boss turn --
203 - Player has 1 hit point, 0 armor, 114 mana
204 - Boss has 2 hit points
205 Poison deals 3 damage. This kills the boss, and the player wins.
206 </code></pre>
207 <p>You start with <em>50 hit points</em> and <em>500 mana points</em>. The boss's actual stats are in your puzzle input. What is the <em>least amount of mana</em> you can spend and still win the fight? (Do not include mana recharge effects as "spending" negative mana.)</p>
208 </article>
209 <p>Your puzzle answer was <code>1269</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>On the next run through the game, you increase the difficulty to <em>hard</em>.</p>
210 <p>At the start of each <em>player turn</em> (before any other effects apply), you lose <code>1</code> hit point. If this brings you to or below <code>0</code> hit points, you lose.</p>
211 <p>With the same starting stats for you and the boss, what is the <em>least amount of mana</em> you can spend and still win the fight?</p>
212 </article>
213 <p>Your puzzle answer was <code>1309</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
214 <p>At this point, you should <a href="/">return to your advent calendar</a> and try another puzzle.</p>
215 <p>If you still want to see it, you can <a href="/day/22/input" target="_blank">get your puzzle input</a>.</p>
216 <p>You can also <span class="share">[Share<span class="share-content">on
217 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Wizard+Simulator+20XX%22+%2D+Day+22+%2D+Advent+of+Code&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
218 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22" target="_blank">Google+</a>
219 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22&amp;title=I%27ve+completed+%22Wizard+Simulator+20XX%22+%2D+Day+22+%2D+Advent+of+Code" target="_blank">Reddit</a
220 ></span>]</span>
221 this puzzle.</p>
222 </main>
223
224 <!-- ga -->
225 <script>
226 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
227 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
228 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
229 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
230 ga('create', 'UA-69522494-1', 'auto');
231 ga('send', 'pageview');
232 </script>
233 <!-- /ga -->
234 </body>
235 </html>