-
Notifications
You must be signed in to change notification settings - Fork 0
/
day24.html
278 lines (257 loc) · 8.73 KB
/
day24.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<html lang="en-us">
<head>
<meta charset="utf-8" />
<title>Advent of Code 2022</title>
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="./assets/style.css" />
<link rel="shortcut icon" href="./assets/favicon.png" />
</head>
<body>
<header>
<div>
<h1 class="title-global"><a href="https://adventofcode.com/2022" target="_blank">Advent of Code</a></h1>
<div class="user">John Dugan <span class="star-count">(AoC++) 50*</span></div>
</div>
<div>
<h1 class="title-event"> <span class="title-event-wrap">{year=></span><a href="https://adventofcode.com/2022" target="_blank">2022</a><span class="title-event-wrap">}</span></h1>
<nav>
<ul>
<li><a href="index.html">[Calendar]</a></li>
<li><a href="https://adventofcode.com/2022/leaderboard/private/view/453227" target="_blank">[Aidn]</a></li>
<li><a href="https://adventofcode.com/2022/leaderboard/private/view/251766" target="_blank">[Memphis]</a></li>
<li><a href="https://adventofcode.com/2022/leaderboard/private/view/371961" target="_blank">[Telia]</a></li>
<li><a href="https://adventofcode.com/2022/leaderboard/self" target="_blank">[Personal Stats]</a></li>
</ul>
</nav>
</div>
</header>
<main>
<article class="day-desc">
<h2>--- Day 24: Blizzard Basin ---</h2>
<p>With everything replanted for next year (and with elephants and monkeys to tend the grove), you and the Elves leave for the extraction point.</p>
<p>Partway up the mountain that shields the grove is a flat, open area that serves as the extraction point. It's a bit of a climb, but nothing the expedition can't handle.</p>
<p>At least, that would normally be true; now that the mountain is covered in snow, things have become more difficult than the Elves are used to.</p>
<p>As the expedition reaches a valley that must be traversed to reach the extraction site, you find that strong, turbulent winds are pushing small <em>blizzards</em> of snow and sharp ice around the valley. It's a good thing everyone packed
warm clothes! To make it across safely, you'll need to find a way to avoid them.</p>
<p>Fortunately, it's easy to see all of this from the entrance to the valley, so you make a map of the valley and the blizzards (your puzzle input). For example:</p>
<pre><code>#.#####
#.....#
#>....#
#.....#
#...v.#
#.....#
#####.#
</code></pre>
<p>The walls of the valley are drawn as <code>#</code>; everything else is ground. Clear ground - where there is currently no blizzard - is drawn as <code>.</code>. Otherwise, blizzards are drawn with an arrow indicating their direction of
motion: up (<code>^</code>), down (<code>v</code>), left (<code><</code>), or right (<code>></code>).</p>
<p>The above map includes two blizzards, one moving right (<code>></code>) and one moving down (<code>v</code>). In one minute, each blizzard moves one position in the direction it is pointing:</p>
<pre><code>#.#####
#.....#
#.>...#
#.....#
#.....#
#...v.#
#####.#
</code></pre>
<p>Due to <span title="I think, anyway. Do I look like a theoretical blizzacist?">conservation of blizzard energy</span>, as a blizzard reaches the wall of the valley, a new blizzard forms on the opposite side of the valley moving in the same
direction. After another minute, the bottom downward-moving blizzard has been replaced with a new downward-moving blizzard at the top of the valley instead:</p>
<pre><code>#.#####
#...v.#
#..>..#
#.....#
#.....#
#.....#
#####.#
</code></pre>
<p>Because blizzards are made of tiny snowflakes, they pass right through each other. After another minute, both blizzards temporarily occupy the same position, marked <code>2</code>:</p>
<pre><code>#.#####
#.....#
#...2.#
#.....#
#.....#
#.....#
#####.#
</code></pre>
<p>After another minute, the situation resolves itself, giving each blizzard back its personal space:</p>
<pre><code>#.#####
#.....#
#....>#
#...v.#
#.....#
#.....#
#####.#
</code></pre>
<p>Finally, after yet another minute, the rightward-facing blizzard on the right is replaced with a new one on the left facing the same direction:</p>
<pre><code>#.#####
#.....#
#>....#
#.....#
#...v.#
#.....#
#####.#
</code></pre>
<p>This process repeats at least as long as you are observing it, but probably forever.</p>
<p>Here is a more complex example:</p>
<pre><code>#.######
#>>.<^<#
#.<..<<#
#>v.><>#
#<^v^^>#
######.#
</code></pre>
<p>Your expedition begins in the only non-wall position in the top row and needs to reach the only non-wall position in the bottom row. On each minute, you can <em>move</em> up, down, left, or right, or you can <em>wait</em> in place. You and
the blizzards act <em>simultaneously</em>, and you cannot share a position with a blizzard.</p>
<p>In the above example, the fastest way to reach your goal requires <code><em>18</em></code> steps. Drawing the position of the expedition as <code>E</code>, one way to achieve this is:</p>
<pre><code>Initial state:
#<em>E</em>######
#>>.<^<#
#.<..<<#
#>v.><>#
#<^v^^>#
######.#
Minute 1, move down:
#.######
#<em>E</em>>3.<.#
#<..<<.#
#>2.22.#
#>v..^<#
######.#
Minute 2, move down:
#.######
#.2>2..#
#<em>E</em>^22^<#
#.>2.^>#
#.>..<.#
######.#
Minute 3, wait:
#.######
#<^<22.#
#<em>E</em>2<.2.#
#><2>..#
#..><..#
######.#
Minute 4, move up:
#.######
#<em>E</em><..22#
#<<.<..#
#<2.>>.#
#.^22^.#
######.#
Minute 5, move right:
#.######
#2<em>E</em>v.<>#
#<.<..<#
#.^>^22#
#.2..2.#
######.#
Minute 6, move right:
#.######
#>2<em>E</em><.<#
#.2v^2<#
#>..>2>#
#<....>#
######.#
Minute 7, move down:
#.######
#.22^2.#
#<v<em>E</em><2.#
#>>v<>.#
#>....<#
######.#
Minute 8, move left:
#.######
#.<>2^.#
#.<em>E</em><<.<#
#.22..>#
#.2v^2.#
######.#
Minute 9, move up:
#.######
#<<em>E</em>2>>.#
#.<<.<.#
#>2>2^.#
#.v><^.#
######.#
Minute 10, move right:
#.######
#.2<em>E</em>.>2#
#<2v2^.#
#<>.>2.#
#..<>..#
######.#
Minute 11, wait:
#.######
#2^<em>E</em>^2>#
#<v<.^<#
#..2.>2#
#.<..>.#
######.#
Minute 12, move down:
#.######
#>>.<^<#
#.<<em>E</em>.<<#
#>v.><>#
#<^v^^>#
######.#
Minute 13, move down:
#.######
#.>3.<.#
#<..<<.#
#>2<em>E</em>22.#
#>v..^<#
######.#
Minute 14, move right:
#.######
#.2>2..#
#.^22^<#
#.>2<em>E</em>^>#
#.>..<.#
######.#
Minute 15, move right:
#.######
#<^<22.#
#.2<.2.#
#><2><em>E</em>.#
#..><..#
######.#
Minute 16, move right:
#.######
#.<..22#
#<<.<..#
#<2.>><em>E</em>#
#.^22^.#
######.#
Minute 17, move down:
#.######
#2.v.<>#
#<.<..<#
#.^>^22#
#.2..2<em>E</em>#
######.#
Minute 18, move down:
#.######
#>2.<.<#
#.2v^2<#
#>..>2>#
#<....>#
######<em>E</em>#
</code></pre>
<p><em>What is the fewest number of minutes required to avoid the blizzards and reach the goal?</em></p>
</article>
<p>Your puzzle answer was <code>277</code>.</p>
<article class="day-desc">
<h2 id="part2">--- Part Two ---</h2>
<p>As the expedition reaches the far side of the valley, one of the Elves looks especially dismayed:</p>
<p>He <em>forgot his snacks</em> at the entrance to the valley!</p>
<p>Since you're so good at dodging blizzards, the Elves humbly request that you go back for his snacks. From the same initial conditions, how quickly can you make it from the start to the goal, then back to the start, then back to the goal?</p>
<p>In the above example, the first trip to the goal takes <code>18</code> minutes, the trip back to the start takes <code>23</code> minutes, and the trip back to the goal again takes <code>13</code> minutes, for a total time of
<code><em>54</em></code> minutes.</p>
<p><em>What is the fewest number of minutes required to reach the goal, go back to the start, then reach the goal again?</em></p>
</article>
<p>Your puzzle answer was <code>877</code>.</p>
<p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
<p>At this point, all that is left is for you to <a href="index.html">admire your Advent calendar</a>.</p>
<p>If you still want to see it, you can <a href="../data/day24/input.txt" target="_blank">get your puzzle input</a>.</p>
</main>
</body>
</html>