Updated README to fix a typo and add some clarificaiton about directories
[advent-of-code-16.git] / day19.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 19 - Advent of Code 2016</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?9"/>
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. The best surprises don't
19 even appear in the source until you unlock them for real.
20
21 Please be careful with automated requests; I'm not Google, and I can only take
22 so much traffic. Please be considerate so that everyone gets to play.
23
24 If you're curious about how Advent of Code works, it's running on some custom
25 Perl code. Other than a few integrations (auth, analytics, ads, social media),
26 I built the whole thing myself, including the design, animations, prose, and
27 all of the puzzles.
28
29 The puzzles probably took the longest; the easiest ones were around 45 minutes
30 each, but the harder ones took 2-3 hours, and a few even longer than that. A
31 lot of effort went into building this thing - I hope you're enjoying playing it
32 as much as I enjoyed making it for you!
33
34 If you'd like to hang out, I'm @ericwastl on Twitter.
35
36 - Eric Wastl
37
38
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 <body>
89 <header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2016/about">[About]</a></li><li><a href="/2016/support">[AoC++]</a></li><li><a href="/2016/events">[Events]</a></li><li><a href="/2016/settings">[Settings]</a></li><li><a href="/2016/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <span class="supporter">(AoC++)</span> <span class="star-count">38*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">sub y{</span><a href="/2016">2016</a><span class="title-event-wrap">}</span></h1><nav><ul><li><a href="/2016">[Calendar]</a></li><li><a href="/2016/leaderboard">[Leaderboard]</a></li><li><a href="/2016/stats">[Stats]</a></li><li><a href="/2016/sponsors">[Sponsors]</a></li></ul></nav></div></header>
90
91 <div id="sidebar">
92 <div id="sponsor"><div class="quiet">Our <a href="/2016/sponsors">sponsors</a> help make AoC possible:</div><p><a href="https://www.detroitlabs.com/careers" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);">Detroit Labs</a> - Build beautiful mobile apps.</p></div>
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 </div><!--/sidebar-->
105
106 <main>
107 <article class="day-desc"><h2>--- Day 19: An Elephant Named Joseph ---</h2><p>The Elves contact you over a highly secure emergency channel. Back at the North Pole, the Elves are busy <span title="Eggnoggedly misunderstanding them, actually.">misunderstanding</span> <a href="https://en.wikipedia.org/wiki/White_elephant_gift_exchange">White Elephant parties</a>.</p>
108 <p>Each Elf brings a present. They all sit in a circle, numbered starting with position <code>1</code>. Then, starting with the first Elf, they take turns stealing all the presents from the Elf to their left. An Elf with no presents is removed from the circle and does not take turns.</p>
109 <p>For example, with five Elves (numbered <code>1</code> to <code>5</code>):</p>
110 <pre><code> 1
111 5 2
112 4 3
113 </code></pre>
114 <ul>
115 <li>Elf <code>1</code> takes Elf <code>2</code>'s present.</li>
116 <li>Elf <code>2</code> has no presents and is skipped.</li>
117 <li>Elf <code>3</code> takes Elf <code>4</code>'s present.</li>
118 <li>Elf <code>4</code> has no presents and is also skipped.</li>
119 <li>Elf <code>5</code> takes Elf <code>1</code>'s two presents.</li>
120 <li>Neither Elf <code>1</code> nor Elf <code>2</code> have any presents, so both are skipped.</li>
121 <li>Elf <code>3</code> takes Elf <code>5</code>'s three presents.</li>
122 </ul>
123 <p>So, with <em>five</em> Elves, the Elf that sits starting in position <code>3</code> gets all the presents.</p>
124 <p>With the number of Elves given in your puzzle input, <em>which Elf gets all the presents?</em></p>
125 </article>
126 <p>Your puzzle answer was <code>1830117</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>Realizing the folly of their present-exchange rules, the Elves agree to instead steal presents from the Elf <em>directly across the circle</em>. If two Elves are across the circle, the one on the left (from the perspective of the stealer) is stolen from. The other rules remain unchanged: Elves with no presents are removed from the circle entirely, and the other elves move in slightly to keep the circle evenly spaced.</p>
127 <p>For example, with five Elves (again numbered <code>1</code> to <code>5</code>):</p>
128 <ul>
129 <li>The Elves sit in a circle; Elf <code>1</code> goes first:
130 <pre><code> <em>1</em>
131 5 2
132 4 3
133 </code></pre></li>
134 <li>Elves <code>3</code> and <code>4</code> are across the circle; Elf <code>3</code>'s present is stolen, being the one to the left. Elf <code>3</code> leaves the circle, and the rest of the Elves move in:
135 <pre><code> <em>1</em> 1
136 5 2 --&gt; 5 2
137 4 - 4
138 </code></pre></li>
139 <li>Elf <code>2</code> steals from the Elf directly across the circle, Elf <code>5</code>:
140 <pre><code> 1 1
141 - <em>2</em> --&gt; 2
142 4 4
143 </code></pre></li>
144 <li>Next is Elf <code>4</code> who, choosing between Elves <code>1</code> and <code>2</code>, steals from Elf <code>1</code>:
145 <pre><code> - 2
146 2 --&gt;
147 <em>4</em> 4
148 </code></pre></li>
149 <li>Finally, Elf <code>2</code> steals from Elf <code>4</code>:
150 <pre><code> <em>2</em>
151 --&gt; 2
152 -
153 </code></pre></li>
154 </ul>
155 <p>So, with <em>five</em> Elves, the Elf that sits starting in position <code>2</code> gets all the presents.</p>
156 <p>With the number of Elves given in your puzzle input, <em>which Elf now gets all the presents?</em></p>
157 </article>
158 <p>Your puzzle answer was <code>1417887</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
159 <p>At this point, you should <a href="/2016">return to your advent calendar</a> and try another puzzle.</p>
160 <p>Your puzzle input was <code class="puzzle-input">3012210</code>.</p>
161 <p>You can also <span class="share">[Share<span class="share-content">on
162 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22An+Elephant+Named+Joseph%22+%2D+Day+19+%2D+Advent+of+Code+2016&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F19&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
163 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F19" target="_blank">Google+</a>
164 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F19&amp;title=I%27ve+completed+%22An+Elephant+Named+Joseph%22+%2D+Day+19+%2D+Advent+of+Code+2016" target="_blank">Reddit</a
165 ></span>]</span> this puzzle.</p>
166 </main>
167
168 <!-- ga -->
169 <script>
170 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
171 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
172 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
173 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
174 ga('create', 'UA-69522494-1', 'auto');
175 ga('send', 'pageview');
176 </script>
177 <!-- /ga -->
178 </body>
179 </html>