-
Notifications
You must be signed in to change notification settings - Fork 0
/
year2024_day14_puzzle.html
226 lines (157 loc) · 8.8 KB
/
year2024_day14_puzzle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8"/>
<title>Day 14 - Advent of Code 2024</title>
<link rel="stylesheet" type="text/css" href="/static/style.css?31"/>
<link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?1" title="High Contrast"/>
<link rel="shortcut icon" href="/favicon.png"/>
<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>
</head><!--
Oh, hello! Funny seeing you here.
I appreciate your enthusiasm, but you aren't going to find much down here.
There certainly aren't clues to any of the puzzles. The best surprises don't
even appear in the source until you unlock them for real.
Please be careful with automated requests; I'm not a massive company, and I can
only take so much traffic. Please be considerate so that everyone gets to play.
If you're curious about how Advent of Code works, it's running on some custom
Perl code. Other than a few integrations (auth, analytics, social media), I
built the whole thing myself, including the design, animations, prose, and all
of the puzzles.
The puzzles are most of the work; preparing a new calendar and a new set of
puzzles each year takes all of my free time for 4-5 months. A lot of effort
went into building this thing - I hope you're enjoying playing it as much as I
enjoyed making it for you!
If you'd like to hang out, I'm @was.tl on Bluesky, @[email protected] on
Mastodon, and @ericwastl on Twitter.
- Eric Wastl
-->
<body>
<div id="sidebar">
</div><!--/sidebar-->
<main>
<article class="day-desc"><h2>--- Day 14: Restroom Redoubt ---</h2><p>One of The Historians needs to use the bathroom; fortunately, you know there's a bathroom near an unvisited location on their list, and so you're all quickly teleported directly to the lobby of Easter Bunny Headquarters.</p>
<p>Unfortunately, EBHQ seems to have "improved" bathroom security <em>again</em> after your last <a href="/2016/day/2">visit</a>. The area outside the bathroom is swarming with robots!</p>
<p>To get The Historian safely to the bathroom, you'll need a way to predict where the robots will be in the future. Fortunately, they all seem to be moving on the tile floor in predictable <em>straight lines</em>.</p>
<p>You make a list (your puzzle input) of all of the robots' current <em>positions</em> (<code>p</code>) and <em>velocities</em> (<code>v</code>), one robot per line. For example:</p>
<pre><code>p=0,4 v=3,-3
p=6,3 v=-1,-3
p=10,3 v=-1,2
p=2,0 v=2,-1
p=0,0 v=1,3
p=3,0 v=-2,-2
p=7,6 v=-1,-3
p=3,0 v=-1,-2
p=9,3 v=2,3
p=7,3 v=-1,2
p=2,4 v=2,-3
p=9,5 v=-3,-3
</code></pre>
<p>Each robot's position is given as <code>p=x,y</code> where <code>x</code> represents the number of tiles the robot is from the left wall and <code>y</code> represents the number of tiles from the top wall (when viewed from above). So, a position of <code>p=0,0</code> means the robot is all the way in the top-left corner.</p>
<p>Each robot's velocity is given as <code>v=x,y</code> where <code>x</code> and <code>y</code> are given in <em>tiles per second</em>. Positive <code>x</code> means the robot is moving to the <em>right</em>, and positive <code>y</code> means the robot is moving <em>down</em>. So, a velocity of <code>v=1,-2</code> means that each second, the robot moves <code>1</code> tile to the right and <code>2</code> tiles up.</p>
<p>The robots outside the actual bathroom are in a space which is <code>101</code> tiles wide and <code>103</code> tiles tall (when viewed from above). However, in this example, the robots are in a space which is only <code>11</code> tiles wide and <code>7</code> tiles tall.</p>
<p>The robots are good at navigating over/under each other (due to a combination of springs, extendable legs, and quadcopters), so they can share the same tile and don't interact with each other. Visually, the number of robots on each tile in this example looks like this:</p>
<pre><code>1.12.......
...........
...........
......11.11
1.1........
.........1.
.......1...
</code></pre>
<p>These robots have a unique feature for maximum bathroom security: they can <em>teleport</em>. When a robot would run into an edge of the space they're in, they instead <em>teleport to the other side</em>, effectively wrapping around the edges. Here is what robot <code>p=2,4 v=2,-3</code> does for the first few seconds:</p>
<pre><code>Initial state:
...........
...........
...........
...........
..1........
...........
...........
After 1 second:
...........
....1......
...........
...........
...........
...........
...........
After 2 seconds:
...........
...........
...........
...........
...........
......1....
...........
After 3 seconds:
...........
...........
........1..
...........
...........
...........
...........
After 4 seconds:
...........
...........
...........
...........
...........
...........
..........1
After 5 seconds:
...........
...........
...........
.1.........
...........
...........
...........
</code></pre>
<p>The Historian can't wait much longer, so you don't have to simulate the robots for very long. Where will the robots be after <code>100</code> seconds?</p>
<p>In the above example, the number of robots on each tile after 100 seconds has elapsed looks like this:</p>
<pre><code>......2..1.
...........
1..........
.11........
.....1.....
...12......
.1....1....
</code></pre>
<p>To determine the safest area, count the <em>number of robots in each quadrant</em> after 100 seconds. Robots that are exactly in the middle (horizontally or vertically) don't count as being in any quadrant, so the only relevant robots are:</p>
<pre><code>..... 2..1.
..... .....
1.... .....
..... .....
...12 .....
.1... 1....
</code></pre>
<p>In this example, the quadrants contain <code>1</code>, <code>3</code>, <code>4</code>, and <code>1</code> robot. Multiplying these together gives a total <em>safety factor</em> of <code><em>12</em></code>.</p>
<p>Predict the motion of the robots in your list within a space which is <code>101</code> tiles wide and <code>103</code> tiles tall. <em>What will the safety factor be after exactly 100 seconds have elapsed?</em></p>
</article>
<p>Your puzzle answer was <code>222062148</code>.</p><article class="day-desc"><h2 id="part2">--- Part Two ---</h2><p>During the bathroom break, someone notices that these robots seem awfully similar to ones built and used at the North Pole. If they're the same type of robots, they should have a hard-coded <span title="This puzzle was originally going to be about the motion of space rocks in a fictitious arcade game called Meteoroids, but we just had an arcade puzzle.">Easter egg</span>: very rarely, most of the robots should arrange themselves into <em>a picture of a Christmas tree</em>.</p>
<p><em>What is the fewest number of seconds that must elapse for the robots to display the Easter egg?</em></p>
</article>
<p>Your puzzle answer was <code>7520</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
<p>At this point, you should <a href="/2024">return to your Advent calendar</a> and try another puzzle.</p>
<p>If you still want to see it, you can <a href="14/input" target="_blank">get your puzzle input</a>.</p>
<p>You can also <span class="share">[Share<span class="share-content">on
<a href="https://bsky.app/intent/compose?text=I%27ve+completed+%22Restroom+Redoubt%22+%2D+Day+14+%2D+Advent+of+Code+2024+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2024%2Fday%2F14" target="_blank">Bluesky</a>
<a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Restroom+Redoubt%22+%2D+Day+14+%2D+Advent+of+Code+2024&url=https%3A%2F%2Fadventofcode%2Ecom%2F2024%2Fday%2F14&related=ericwastl&hashtags=AdventOfCode" target="_blank">Twitter</a>
<a href="javascript:void(0);" onclick="var ms; try{ms=localStorage.getItem('mastodon.server')}finally{} if(typeof ms!=='string')ms=''; ms=prompt('Mastodon Server?',ms); if(typeof ms==='string' && ms.length){this.href='https://'+ms+'/share?text=I%27ve+completed+%22Restroom+Redoubt%22+%2D+Day+14+%2D+Advent+of+Code+2024+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2024%2Fday%2F14';try{localStorage.setItem('mastodon.server',ms);}finally{}}else{return false;}" target="_blank">Mastodon</a
></span>]</span> this puzzle.</p>
</main>
<!-- ga -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-69522494-1', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
<!-- /ga -->
</body>
</html>