Done day 13
[advent-of-code-21.git] / problems / day13.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 13 - Advent of Code 2021</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?26"/>
9 <link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
10 <link rel="shortcut icon" href="/favicon.png"/>
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 a massive company, and I can
23 only take 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, social media), I
27 built the whole thing myself, including the design, animations, prose, and all
28 of the puzzles.
29
30 The puzzles are most of the work; preparing a new calendar and a new set of
31 puzzles each year takes all of my free time for 4-5 months. A lot of effort
32 went into building this thing - I hope you're enjoying playing it as much as I
33 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="/2021/about">[About]</a></li><li><a href="/2021/events">[Events]</a></li><li><a href="https://teespring.com/stores/advent-of-code" target="_blank">[Shop]</a></li><li><a href="/2021/settings">[Settings]</a></li><li><a href="/2021/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <a href="/2021/support" class="supporter-badge" title="Advent of Code Supporter">(AoC++)</a> <span class="star-count">26*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">/^</span><a href="/2021">2021</a><span class="title-event-wrap">$/</span></h1><nav><ul><li><a href="/2021">[Calendar]</a></li><li><a href="/2021/support">[AoC++]</a></li><li><a href="/2021/sponsors">[Sponsors]</a></li><li><a href="/2021/leaderboard">[Leaderboard]</a></li><li><a href="/2021/stats">[Stats]</a></li></ul></nav></div></header>
91
92 <div id="sidebar">
93 <div id="sponsor"><div class="quiet">Our <a href="/2021/sponsors">sponsors</a> help make Advent of Code possible:</div><div class="sponsor"><a href="https://rick379856.typeform.com/to/oQ0e2jpi?utm_source=event&amp;utm_medium=ad&amp;utm_campaign=adventofcode2021" target="_blank" onclick="if(ga)ga('send','event','sponsor','sidebar',this.href);" rel="noopener">Honeycomb</a> - You like performant, correct code. So do we. Distributed systems should be easy to understand. Use Honeycomb for free to debug your distributed systems and get a free shirt. Download our white papers and watch our demo.</div></div>
94 </div><!--/sidebar-->
95
96 <main>
97 <script>window.addEventListener('click', function(e,s,r){if(e.target.nodeName==='CODE'&&e.detail===3){s=window.getSelection();s.removeAllRanges();r=document.createRange();r.selectNodeContents(e.target);s.addRange(r);}});</script>
98 <article class="day-desc"><h2>--- Day 13: Transparent Origami ---</h2><p>You reach another volcanically active part of the cave. It would be nice if you could do some kind of thermal imaging so you could tell ahead of time which caves are too hot to safely enter.</p>
99 <p>Fortunately, the submarine seems to be equipped with a thermal camera! When you activate it, you are greeted with:</p>
100 <pre><code>Congratulations on your purchase! To activate this infrared thermal imaging
101 camera system, please enter the code found on page 1 of the manual.
102 </code></pre>
103 <p>Apparently, the Elves have never used this feature. To your surprise, you manage to find the manual; as you go to open it, page 1 falls out. It's a large sheet of <a href="https://en.wikipedia.org/wiki/Transparency_(projection)" target="_blank">transparent paper</a>! The transparent paper is marked with random dots and includes instructions on how to fold it up (your puzzle input). For example:</p>
104 <pre><code>6,10
105 0,14
106 9,10
107 0,3
108 10,4
109 4,11
110 6,0
111 6,12
112 4,1
113 0,13
114 10,12
115 3,4
116 3,0
117 8,4
118 1,10
119 2,14
120 8,10
121 9,0
122
123 fold along y=7
124 fold along x=5
125 </code></pre>
126 <p>The first section is a list of dots on the transparent paper. <code>0,0</code> represents the top-left coordinate. The first value, <code>x</code>, increases to the right. The second value, <code>y</code>, increases downward. So, the coordinate <code>3,0</code> is to the right of <code>0,0</code>, and the coordinate <code>0,7</code> is below <code>0,0</code>. The coordinates in this example form the following pattern, where <code>#</code> is a dot on the paper and <code>.</code> is an empty, unmarked position:</p>
127 <pre><code>...#..#..#.
128 ....#......
129 ...........
130 #..........
131 ...#....#.#
132 ...........
133 ...........
134 ...........
135 ...........
136 ...........
137 .#....#.##.
138 ....#......
139 ......#...#
140 #..........
141 #.#........
142 </code></pre>
143 <p>Then, there is a list of <em>fold instructions</em>. Each instruction indicates a line on the transparent paper and wants you to fold the paper <em>up</em> (for horizontal <code>y=...</code> lines) or <em>left</em> (for vertical <code>x=...</code> lines). In this example, the first fold instruction is <code>fold along y=7</code>, which designates the line formed by all of the positions where <code>y</code> is <code>7</code> (marked here with <code>-</code>):</p>
144 <pre><code>...#..#..#.
145 ....#......
146 ...........
147 #..........
148 ...#....#.#
149 ...........
150 ...........
151 -----------
152 ...........
153 ...........
154 .#....#.##.
155 ....#......
156 ......#...#
157 #..........
158 #.#........
159 </code></pre>
160 <p>Because this is a horizontal line, fold the bottom half <em>up</em>. Some of the dots might end up overlapping after the fold is complete, but dots will never appear exactly on a fold line. The result of doing this fold looks like this:</p>
161 <pre><code>#.##..#..#.
162 #...#......
163 ......#...#
164 #...#......
165 .#.#..#.###
166 ...........
167 ...........
168 </code></pre>
169 <p>Now, only <code>17</code> dots are visible.</p>
170 <p>Notice, for example, the two dots in the bottom left corner before the transparent paper is folded; after the fold is complete, those dots appear in the top left corner (at <code>0,0</code> and <code>0,1</code>). Because the paper is transparent, the dot just below them in the result (at <code>0,3</code>) remains visible, as it can be seen through the transparent paper.</p>
171 <p>Also notice that some dots can end up <em>overlapping</em>; in this case, the dots merge together and become a single dot.</p>
172 <p>The second fold instruction is <code>fold along x=5</code>, which indicates this line:</p>
173 <pre><code>#.##.|#..#.
174 #...#|.....
175 .....|#...#
176 #...#|.....
177 .#.#.|#.###
178 .....|.....
179 .....|.....
180 </code></pre>
181 <p>Because this is a vertical line, fold <em>left</em>:</p>
182 <pre><code>#####
183 #...#
184 #...#
185 #...#
186 #####
187 .....
188 .....
189 </code></pre>
190 <p>The instructions made a square!</p>
191 <p>The transparent paper is pretty big, so for now, focus on just completing the first fold. After the first fold in the example above, <code><em>17</em></code> dots are visible - dots that end up overlapping after the fold is completed count as a single dot.</p>
192 <p><em>How many dots are visible after completing just the first fold instruction on your transparent paper?</em></p>
193 </article>
194 <p>Your puzzle answer was <code>763</code>.</p><article class="day-desc"><h2 id="part2">--- Part Two ---</h2><p><span title="How can you fold it that many times? You tell me, I'm not the one folding it.">Finish folding</span> the transparent paper according to the instructions. The manual says the code is always <em>eight capital letters</em>.</p>
195 <p><em>What code do you use to activate the infrared thermal imaging camera system?</em></p>
196 </article>
197 <p>Your puzzle answer was <code>RHALRCRA</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
198 <p>At this point, you should <a href="/2021">return to your Advent calendar</a> and try another puzzle.</p>
199 <p>If you still want to see it, you can <a href="13/input" target="_blank">get your puzzle input</a>.</p>
200 <p>You can also <span class="share">[Share<span class="share-content">on
201 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Transparent+Origami%22+%2D+Day+13+%2D+Advent+of+Code+2021&amp;url=https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F13&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
202 <a href="javascript:void(0);" onclick="var mastodon_instance=prompt('Mastodon Instance / Server Name?'); if(typeof mastodon_instance==='string' && mastodon_instance.length){this.href='https://'+mastodon_instance+'/share?text=I%27ve+completed+%22Transparent+Origami%22+%2D+Day+13+%2D+Advent+of+Code+2021+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F13'}else{return false;}" target="_blank">Mastodon</a
203 ></span>]</span> this puzzle.</p>
204 </main>
205
206 <!-- ga -->
207 <script>
208 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
209 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
210 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
211 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
212 ga('create', 'UA-69522494-1', 'auto');
213 ga('set', 'anonymizeIp', true);
214 ga('send', 'pageview');
215 </script>
216 <!-- /ga -->
217 </body>
218 </html>