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"/>
15 Oh, hello! Funny seeing you here.
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.
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.
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
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!
34 If you'd like to hang out, I'm @ericwastl on Twitter.
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"> <span class=
"title-event-wrap"><y
></span><a href=
"/2016">2016</a><span class=
"title-event-wrap"></y
></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>
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
&K Rentals
</a> - Affordable, high-quality homes just north of Kansas City.
</p></div>
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>
101 (adsbygoogle = window.adsbygoogle || []).push({});
104 </div><!--/sidebar-->
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>
115 <p>Suppose your instructions are:
</p>
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>
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>
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>
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>
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>
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>
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&url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F2&related=ericwastl&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&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>
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');