Taking advantage of a neat trick for using $ rather than a lambda
[advent-of-code-17.git] / problems / day16.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 16 - Advent of Code 2017</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?12"/>
9 <link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
10 <link rel="shortcut icon" href="/favicon.ico?2"/>
11 </head><!--
12
13
14
15
16 Oh, hello! Funny seeing you here.
17
18 I appreciate your enthusiasm, but you aren't going to find much down here.
19 There certainly aren't clues to any of the puzzles. The best surprises don't
20 even appear in the source until you unlock them for real.
21
22 Please be careful with automated requests; I'm not Google, and I can only take
23 so much traffic. Please be considerate so that everyone gets to play.
24
25 If you're curious about how Advent of Code works, it's running on some custom
26 Perl code. Other than a few integrations (auth, analytics, ads, social media),
27 I built the whole thing myself, including the design, animations, prose, and
28 all of the puzzles.
29
30 The puzzles probably took the longest; the easiest ones took an hour or two
31 each, but the harder ones took 4-5 hours, and a few even longer than that. A
32 lot of effort went into building this thing - I hope you're enjoying playing it
33 as much as I enjoyed making it for you!
34
35 If you'd like to hang out, I'm @ericwastl on Twitter.
36
37 - Eric Wastl
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 -->
89 <body>
90 <header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2017/about">[About]</a></li><li><a href="/2017/support">[AoC++]</a></li><li><a href="/2017/events">[Events]</a></li><li><a href="/2017/settings">[Settings]</a></li><li><a href="/2017/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <span class="supporter">(AoC++)</span> <span class="star-count">32*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">$year=</span><a href="/2017">2017</a><span class="title-event-wrap">;</span></h1><nav><ul><li><a href="/2017">[Calendar]</a></li><li><a href="/2017/leaderboard">[Leaderboard]</a></li><li><a href="/2017/stats">[Stats]</a></li><li><a href="/2017/sponsors">[Sponsors]</a></li></ul></nav></div></header>
91
92 <div id="sidebar">
93 <div id="sponsor"><div class="quiet">Our <a href="/2017/sponsors">sponsors</a> help make Advent of Code possible:</div><p><a href="http://kx.com/" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);" rel="noopener">Kx Systems</a> - kdb+, the in-memory time series technology standard</p></div>
94 <div id="ad">
95 <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
96 <!-- Advent of Code Wide Skyscraper -->
97 <ins class="adsbygoogle"
98 style="display:inline-block;width:160px;height:600px"
99 data-ad-client="ca-pub-9420604735624631"
100 data-ad-slot="8014013294"></ins>
101 <script>
102 (adsbygoogle = window.adsbygoogle || []).push({});
103 </script>
104 </div><!--/ad-->
105 </div><!--/sidebar-->
106
107 <main>
108 <article class="day-desc"><h2>--- Day 16: Permutation Promenade ---</h2><p>You come upon a very unusual sight; a group of programs here appear to be <a href="https://www.youtube.com/watch?v=lyZQPjUT5B4&t=53">dancing</a>.</p>
109 <p>There are sixteen programs in total, named <code>a</code> through <code>p</code>. They start by standing in a <span title="This is called a 'newline'.">line</span>: <code>a</code> stands in position <code>0</code>, <code>b</code> stands in position <code>1</code>, and so on until <code>p</code>, which stands in position <code>15</code>.</p>
110 <p>The programs' <em>dance</em> consists of a sequence of <em>dance moves</em>:</p>
111 <ul>
112 <li><em>Spin</em>, written <code>sX</code>, makes <code>X</code> programs move from the end to the front, but maintain their order otherwise. (For example, <code>s3</code> on <code>abcde</code> produces <code>cdeab</code>).</li>
113 <li><em>Exchange</em>, written <code>xA/B</code>, makes the programs at positions <code>A</code> and <code>B</code> swap places.</li>
114 <li><em>Partner</em>, written <code>pA/B</code>, makes the programs named <code>A</code> and <code>B</code> swap places.</li>
115 </ul>
116 <p>For example, with only five programs standing in a line (<code>abcde</code>), they could do the following dance:</p>
117 <ul>
118 <li><code>s1</code>, a spin of size <code>1</code>: <code>eabcd</code>.</li>
119 <li><code>x3/4</code>, swapping the last two programs: <code>eabdc</code>.</li>
120 <li><code>pe/b</code>, swapping programs <code>e</code> and <code>b</code>: <code>baedc</code>.</li>
121 </ul>
122 <p>After finishing their dance, the programs end up in order <code>baedc</code>.<p>
123 <p>You watch the dance for a while and record their dance moves (your puzzle input). <em>In what order are the programs standing</em> after their dance?</p>
124 </article>
125 <p>Your puzzle answer was <code>giadhmkpcnbfjelo</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>Now that you're starting to get a feel for the dance moves, you turn your attention to <em>the dance as a whole</em>.</p>
126 <p>Keeping the positions they ended up in from their previous dance, the programs perform it again and again: including the first dance, a total of <em>one billion</em> (<code>1000000000</code>) times.</p>
127 <p>In the example above, their second dance would <em>begin</em> with the order <code>baedc</code>, and use the same dance moves:</p>
128 <ul>
129 <li><code>s1</code>, a spin of size <code>1</code>: <code>cbaed</code>.</li>
130 <li><code>x3/4</code>, swapping the last two programs: <code>cbade</code>.</li>
131 <li><code>pe/b</code>, swapping programs <code>e</code> and <code>b</code>: <code>ceadb</code>.</li>
132 </ul>
133 <p><em>In what order are the programs standing</em> after their billion dances?</p>
134 </article>
135 <p>Your puzzle answer was <code>njfgilbkcoemhpad</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
136 <p>At this point, you should <a href="/2017">return to your advent calendar</a> and try another puzzle.</p>
137 <p>If you still want to see it, you can <a href="16/input" target="_blank">get your puzzle input</a>.</p>
138 <p>You can also <span class="share">[Share<span class="share-content">on
139 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Permutation+Promenade%22+%2D+Day+16+%2D+Advent+of+Code+2017&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F16&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
140 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F16" target="_blank">Google+</a>
141 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F16&amp;title=I%27ve+completed+%22Permutation+Promenade%22+%2D+Day+16+%2D+Advent+of+Code+2017" target="_blank">Reddit</a
142 ></span>]</span> this puzzle.</p>
143 </main>
144
145 <!-- ga -->
146 <script>
147 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
148 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
149 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
150 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
151 ga('create', 'UA-69522494-1', 'auto');
152 ga('send', 'pageview');
153 </script>
154 <!-- /ga -->
155 </body>
156 </html>