Now using fromMaybe
[advent-of-code-16.git] / day02.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 2 - 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?7"/>
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">6*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">&lt;y&gt;</span><a href="/2016">2016</a><span class="title-event-wrap">&lt;/y&gt;</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="http://www.aandkrentals.net/" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);">A&amp;K Rentals</a> - Affordable, high-quality homes just north of Kansas City.</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 2: Bathroom Security ---</h2><p>You arrive at <em>Easter Bunny Headquarters</em> under cover of darkness. However, you left in such a rush that you forgot to use the bathroom! Fancy office buildings like this one usually have keypad locks on their bathrooms, so you search the front desk for the code.</p>
108 <p>"In order to improve security," the document you find says, "bathroom codes will no longer be written down. Instead, please memorize and follow the procedure below to access the bathrooms."</p>
109 <p>The document goes on to explain that each button to be pressed can be found by starting on the previous button and moving to adjacent buttons on the keypad: <code>U</code> moves up, <code>D</code> moves down, <code>L</code> moves left, and <code>R</code> moves right. Each line of instructions corresponds to one button, starting at the previous button (or, for the first line, <em>the "5" button</em>); press whatever button you're on at the end of each line. If a move doesn't lead to a button, ignore it.</p>
110 <p>You can't hold it much longer, so you decide to figure out the code as you walk to the bathroom. You picture a keypad like this:</p>
111 <pre><code>1 2 3
112 4 5 6
113 7 8 9
114 </code></pre>
115 <p>Suppose your instructions are:</p>
116 <pre><code>ULL
117 RRDDD
118 LURDL
119 UUUUD
120 </code></pre>
121 <ul>
122 <li>You start at "5" and move up (to "2"), left (to "1"), and left (you can't, and stay on "1"), so the first button is <code>1</code>.</li>
123 <li>Starting from the previous button ("1"), you move right twice (to "3") and then down three times (stopping at "9" after two moves and ignoring the third), ending up with <code>9</code>.</li>
124 <li>Continuing from "9", you move left, up, right, down, and left, ending with <code>8</code>.</li>
125 <li>Finally, you move up four times (stopping at "2"), then down once, ending with <code>5</code>.</li>
126 </ul>
127 <p>So, in this example, the bathroom code is <code>1985</code>.</p>
128 <p>Your puzzle input is the instructions from the document you found at the front desk. What is the <em>bathroom code</em>?</p>
129 </article>
130 <p>Your puzzle answer was <code>12578</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>You finally arrive at the bathroom (it's a several minute walk from the lobby so visitors can behold the many fancy conference rooms and water coolers on this floor) and go to punch in the code. Much to your bladder's dismay, the keypad is not at all like you imagined it. Instead, you are confronted with the result of hundreds of man-hours of <span title="User Group 143 found a diamond shape to be the most environmentally friendly.">bathroom-keypad-design meetings</title>:</p>
131 <pre><code> 1
132 2 3 4
133 5 6 7 8 9
134 A B C
135 D
136 </code></pre>
137 <p>You still start at "5" and stop when you're at an edge, but given the same instructions as above, the outcome is very different:</p>
138 <ul>
139 <li>You start at "5" and don't move at all (up and left are both edges), ending at <code>5</code>.</li>
140 <li>Continuing from "5", you move right twice and down three times (through "6", "7", "B", "D", "D"), ending at <code>D</code>.</li>
141 <li>Then, from "D", you move five more times (through "D", "B", "C", "C", "B"), ending at <code>B</code>.</li>
142 <li>Finally, after five more moves, you end at <code>3</code>.</li>
143 </ul>
144 <p>So, given the actual keypad layout, the code would be <code>5DB3</code>.</p>
145 <p>Using the same instructions in your puzzle input, what is the correct <em>bathroom code</em>?</p>
146 </article>
147 <p>Your puzzle answer was <code>516DD</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
148 <p>At this point, you should <a href="/2016">return to your advent calendar</a> and try another puzzle.</p>
149 <p>If you still want to see it, you can <a href="2/input" target="_blank">get your puzzle input</a>.</p>
150 <p>You can also <span class="share">[Share<span class="share-content">on
151 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Bathroom+Security%22+%2D+Day+2+%2D+Advent+of+Code+2016&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F2&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
152 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F2" target="_blank">Google+</a>
153 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F2&amp;title=I%27ve+completed+%22Bathroom+Security%22+%2D+Day+2+%2D+Advent+of+Code+2016" target="_blank">Reddit</a
154 ></span>]</span> this puzzle.</p>
155 </main>
156
157 <!-- ga -->
158 <script>
159 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
160 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
161 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
162 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
163 ga('create', 'UA-69522494-1', 'auto');
164 ga('send', 'pageview');
165 </script>
166 <!-- /ga -->
167 </body>
168 </html>