Added some problem specifications
[advent-of-code-17.git] / problems / day05.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 5 - 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?11"/>
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 took an hour or two
30 each, but the harder ones took 4-5 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="/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">12*</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>
90
91 <div id="sidebar">
92 <div id="sponsor"><div class="quiet">Our <a href="/2017/sponsors">sponsors</a> help make Advent of Code possible:</div><p><a href="http://smartystreets.com/aoc" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);" rel="noopener">SmartyStreets</a> - U2VuZGluZyBDaH Jpc3RtYXMgY2Fy ZHMgdG8gYmFkIG FkZHJlc3Nlcz8K</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 5: A Maze of Twisty Trampolines, All Alike ---</h2><p>An urgent <span title="Later, on its turn, it sends you a sorcery.">interrupt</span> arrives from the CPU: it's trapped in a maze of jump instructions, and it would like assistance from any programs with spare cycles to help find the exit.</p>
108 <p>The message includes a list of the offsets for each jump. Jumps are relative: <code>-1</code> moves to the previous instruction, and <code>2</code> skips the next one. Start at the first instruction in the list. The goal is to follow the jumps until one leads <em>outside</em> the list.</p>
109 <p>In addition, these instructions are a little strange; after each jump, the offset of that instruction increases by <code>1</code>. So, if you come across an offset of <code>3</code>, you would move three instructions forward, but change it to a <code>4</code> for the next time it is encountered.</p>
110 <p>For example, consider the following list of jump offsets:</p>
111 <pre><code>0
112 3
113 0
114 1
115 -3
116 </code></pre>
117 <p>Positive jumps ("forward") move downward; negative jumps move upward. For legibility in this example, these offset values will be written all on one line, with the current instruction marked in parentheses. The following steps would be taken before an exit is found:</p>
118 <ul>
119 <li><code>(0)&nbsp;3&nbsp;&nbsp;0&nbsp;&nbsp;1&nbsp;&nbsp;-3&nbsp;</code> - <em>before</em> we have taken any steps.</li>
120 <li><code>(1)&nbsp;3&nbsp;&nbsp;0&nbsp;&nbsp;1&nbsp;&nbsp;-3&nbsp;</code> - jump with offset <code>0</code> (that is, don't jump at all). Fortunately, the instruction is then incremented to <code>1</code>.</li>
121 <li><code>&nbsp;2&nbsp;(3)&nbsp;0&nbsp;&nbsp;1&nbsp;&nbsp;-3&nbsp;</code> - step forward because of the instruction we just modified. The first instruction is incremented again, now to <code>2</code>.</li>
122 <li><code>&nbsp;2&nbsp;&nbsp;4&nbsp;&nbsp;0&nbsp;&nbsp;1&nbsp;(-3)</code> - jump all the way to the end; leave a <code>4</code> behind.</li>
123 <li><code>&nbsp;2&nbsp;(4)&nbsp;0&nbsp;&nbsp;1&nbsp;&nbsp;-2&nbsp;</code> - go back to where we just were; increment <code>-3</code> to <code>-2</code>.</li>
124 <li><code>&nbsp;2&nbsp;&nbsp;5&nbsp;&nbsp;0&nbsp;&nbsp;1&nbsp;&nbsp;-2&nbsp;</code> - jump <code>4</code> steps forward, escaping the maze.</li>
125 </ul>
126 <p>In this example, the exit is reached in <code>5</code> steps.</p>
127 <p><em>How many steps</em> does it take to reach the exit?</p>
128 </article>
129 <p>Your puzzle answer was <code>315613</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>Now, the jumps are even stranger: after each jump, if the offset was <em>three or more</em>, instead <em>decrease</em> it by <code>1</code>. Otherwise, increase it by <code>1</code> as before.</p>
130 <p>Using this rule with the above example, the process now takes <code>10</code> steps, and the offset values after finding the exit are left as <code>2 3 2 3 -1</code>.</p>
131 <p><em>How many steps</em> does it now take to reach the exit?</p>
132 </article>
133 <p>Your puzzle answer was <code>22570529</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
134 <p>At this point, you should <a href="/2017">return to your advent calendar</a> and try another puzzle.</p>
135 <p>If you still want to see it, you can <a href="5/input" target="_blank">get your puzzle input</a>.</p>
136 <p>You can also <span class="share">[Share<span class="share-content">on
137 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22A+Maze+of+Twisty+Trampolines%2C+All+Alike%22+%2D+Day+5+%2D+Advent+of+Code+2017&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F5&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
138 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F5" target="_blank">Google+</a>
139 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F5&amp;title=I%27ve+completed+%22A+Maze+of+Twisty+Trampolines%2C+All+Alike%22+%2D+Day+5+%2D+Advent+of+Code+2017" target="_blank">Reddit</a
140 ></span>]</span> this puzzle.</p>
141 </main>
142
143 <!-- ga -->
144 <script>
145 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
146 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
147 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
148 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
149 ga('create', 'UA-69522494-1', 'auto');
150 ga('send', 'pageview');
151 </script>
152 <!-- /ga -->
153 </body>
154 </html>