Taking advantage of a neat trick for using $ rather than a lambda
[advent-of-code-17.git] / problems / day11.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 11 - 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">22*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">0xffff&amp;</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 11: Hex Ed ---</h2><p>Crossing the bridge, you've barely reached the other side of the stream when a program comes up to you, clearly in distress. "It's my child process," she says, "he's gotten lost in an infinite grid!"</p>
109 <p>Fortunately for her, you have plenty of experience with infinite grids.</p>
110 <p>Unfortunately for you, it's a <a href="https://en.wikipedia.org/wiki/Hexagonal_tiling">hex grid</a>.</p>
111 <p>The hexagons ("hexes") in <span title="Raindrops on roses and whiskers on kittens.">this grid</span> are aligned such that adjacent hexes can be found to the north, northeast, southeast, south, southwest, and northwest:</p>
112 <pre><code> \ n /
113 nw +--+ ne
114 / \
115 -+ +-
116 \ /
117 sw +--+ se
118 / s \
119 </code></pre>
120 <p>You have the path the child process took. Starting where he started, you need to determine the fewest number of steps required to reach him. (A "step" means to move from the hex you are in to any adjacent hex.)</p>
121 <p>For example:</p>
122 <ul>
123 <li><code>ne,ne,ne</code> is <code>3</code> steps away.</li>
124 <li><code>ne,ne,sw,sw</code> is <code>0</code> steps away (back where you started).</li>
125 <li><code>ne,ne,s,s</code> is <code>2</code> steps away (<code>se,se</code>).</li>
126 <li><code>se,sw,se,sw,sw</code> is <code>3</code> steps away (<code>s,s,sw</code>).</li>
127 </ul>
128 </article>
129 <p>Your puzzle answer was <code>670</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p><em>How many steps away</em> is the <em>furthest</em> he ever got from his starting position?</p>
130 </article>
131 <p>Your puzzle answer was <code>1426</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
132 <p>At this point, you should <a href="/2017">return to your advent calendar</a> and try another puzzle.</p>
133 <p>If you still want to see it, you can <a href="11/input" target="_blank">get your puzzle input</a>.</p>
134 <p>You can also <span class="share">[Share<span class="share-content">on
135 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Hex+Ed%22+%2D+Day+11+%2D+Advent+of+Code+2017&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F11&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
136 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F11" target="_blank">Google+</a>
137 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F11&amp;title=I%27ve+completed+%22Hex+Ed%22+%2D+Day+11+%2D+Advent+of+Code+2017" target="_blank">Reddit</a
138 ></span>]</span> this puzzle.</p>
139 </main>
140
141 <!-- ga -->
142 <script>
143 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
144 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
145 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
146 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
147 ga('create', 'UA-69522494-1', 'auto');
148 ga('send', 'pageview');
149 </script>
150 <!-- /ga -->
151 </body>
152 </html>