Fixed typo
[advent-of-code-15.git] / advent-of-code-21.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 21 - 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">42*</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 21: RPG Simulator 20XX ---</h2><p>Little <span title="The sky above the battle is the color of television, tuned to a dead channel.">Henry Case</span> got a new video game for Christmas. It's an <a href="https://en.wikipedia.org/wiki/Role-playing_video_game">RPG</a>, and he's stuck on a boss. He needs to know what equipment to buy at the shop. He hands you the <a href="https://en.wikipedia.org/wiki/Game_controller">controller</a>.</p>
107 <p>In this game, the player (you) and the enemy (the boss) take turns attacking. The player always goes first. Each attack reduces the opponent's hit points by at least <code>1</code>. The first character at or below <code>0</code> hit points loses.</p>
108 <p>Damage dealt by an attacker each turn is equal to the attacker's damage score minus the defender's armor score. An attacker always does at least <code>1</code> damage. So, if the attacker has a damage score of <code>8</code>, and the defender has an armor score of <code>3</code>, the defender loses <code>5</code> hit points. If the defender had an armor score of <code>300</code>, the defender would still lose <code>1</code> hit point.</p>
109 <p>Your damage score and armor score both start at zero. They can be increased by buying items in exchange for gold. You start with no items and have as much gold as you need. Your total damage or armor is equal to the sum of those stats from all of your items. You have <em>100 hit points</em>.</p>
110 <p>Here is what the item shop is selling:</p>
111 <pre><code>Weapons: Cost Damage Armor
112 Dagger 8 4 0
113 Shortsword 10 5 0
114 Warhammer 25 6 0
115 Longsword 40 7 0
116 Greataxe 74 8 0
117
118 Armor: Cost Damage Armor
119 Leather 13 0 1
120 Chainmail 31 0 2
121 Splintmail 53 0 3
122 Bandedmail 75 0 4
123 Platemail 102 0 5
124
125 Rings: Cost Damage Armor
126 Damage +1 25 1 0
127 Damage +2 50 2 0
128 Damage +3 100 3 0
129 Defense +1 20 0 1
130 Defense +2 40 0 2
131 Defense +3 80 0 3
132 </code></pre>
133 <p>You must buy exactly one weapon; no dual-wielding. Armor is optional, but you can't use more than one. You can buy 0-2 rings (at most one for each hand). You must use any items you buy. The shop only has one of each item, so you can't buy, for example, two rings of Damage +3.</p>
134 <p>For example, suppose you have <code>8</code> hit points, <code>5</code> damage, and <code>5</code> armor, and that the boss has <code>12</code> hit points, <code>7</code> damage, and <code>2</code> armor:</p>
135 <ul>
136 <li>The player deals <code>5-2 = 3</code> damage; the boss goes down to 9 hit points.</li>
137 <li>The boss deals <code>7-5 = 2</code> damage; the player goes down to 6 hit points.</li>
138 <li>The player deals <code>5-2 = 3</code> damage; the boss goes down to 6 hit points.</li>
139 <li>The boss deals <code>7-5 = 2</code> damage; the player goes down to 4 hit points.</li>
140 <li>The player deals <code>5-2 = 3</code> damage; the boss goes down to 3 hit points.</li>
141 <li>The boss deals <code>7-5 = 2</code> damage; the player goes down to 2 hit points.</li>
142 <li>The player deals <code>5-2 = 3</code> damage; the boss goes down to 0 hit points.</li>
143 </ul>
144 <p>In this scenario, the player wins! (Barely.)</p>
145 <p>You have <em>100 hit points</em>. The boss's actual stats are in your puzzle input. What is <em>the least amount of gold you can spend</em> and still win the fight?</p>
146 </article>
147 <p>Your puzzle answer was <code>91</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>Turns out the shopkeeper is working with the boss, and can persuade you to buy whatever items he wants. The other rules still apply, and he still only has one of each item.</p>
148 <p>What is the <em>most</em> amount of gold you can spend and still <em>lose</em> the fight?</p>
149 </article>
150 <p>Your puzzle answer was <code>158</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
151 <p>At this point, you should <a href="/">return to your advent calendar</a> and try another puzzle.</p>
152 <p>If you still want to see it, you can <a href="/day/21/input" target="_blank">get your puzzle input</a>.</p>
153 <p>You can also <span class="share">[Share<span class="share-content">on
154 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22RPG+Simulator+20XX%22+%2D+Day+21+%2D+Advent+of+Code&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
155 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21" target="_blank">Google+</a>
156 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21&amp;title=I%27ve+completed+%22RPG+Simulator+20XX%22+%2D+Day+21+%2D+Advent+of+Code" target="_blank">Reddit</a
157 ></span>]</span>
158 this puzzle.</p>
159 </main>
160
161 <!-- ga -->
162 <script>
163 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
164 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
165 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
166 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
167 ga('create', 'UA-69522494-1', 'auto');
168 ga('send', 'pageview');
169 </script>
170 <!-- /ga -->
171 </body>
172 </html>