Day 11
[advent-of-code-2021.git] / day11 / task.txt
1 --- Day 11: Dumbo Octopus ---
2 You enter a large cavern full of rare bioluminescent dumbo octopuses! They seem to not like the Christmas lights on your submarine, so you turn them off for now.
3
4 There are 100 octopuses arranged neatly in a 10 by 10 grid. Each octopus slowly gains energy over time and flashes brightly for a moment when its energy is full. Although your lights are off, maybe you could navigate through the cave without disturbing the octopuses if you could predict when the flashes of light will happen.
5
6 Each octopus has an energy level - your submarine can remotely measure the energy level of each octopus (your puzzle input). For example:
7
8 5483143223
9 2745854711
10 5264556173
11 6141336146
12 6357385478
13 4167524645
14 2176841721
15 6882881134
16 4846848554
17 5283751526
18 The energy level of each octopus is a value between 0 and 9. Here, the top-left octopus has an energy level of 5, the bottom-right one has an energy level of 6, and so on.
19
20 You can model the energy levels and flashes of light in steps. During a single step, the following occurs:
21
22 First, the energy level of each octopus increases by 1.
23 Then, any octopus with an energy level greater than 9 flashes. This increases the energy level of all adjacent octopuses by 1, including octopuses that are diagonally adjacent. If this causes an octopus to have an energy level greater than 9, it also flashes. This process continues as long as new octopuses keep having their energy level increased beyond 9. (An octopus can only flash at most once per step.)
24 Finally, any octopus that flashed during this step has its energy level set to 0, as it used all of its energy to flash.
25 Adjacent flashes can cause an octopus to flash on a step even if it begins that step with very little energy. Consider the middle octopus with 1 energy in this situation:
26
27 Before any steps:
28 11111
29 19991
30 19191
31 19991
32 11111
33
34 After step 1:
35 34543
36 40004
37 50005
38 40004
39 34543
40
41 After step 2:
42 45654
43 51115
44 61116
45 51115
46 45654
47 An octopus is highlighted when it flashed during the given step.
48
49 Here is how the larger example above progresses:
50
51 Before any steps:
52 5483143223
53 2745854711
54 5264556173
55 6141336146
56 6357385478
57 4167524645
58 2176841721
59 6882881134
60 4846848554
61 5283751526
62
63 After step 1:
64 6594254334
65 3856965822
66 6375667284
67 7252447257
68 7468496589
69 5278635756
70 3287952832
71 7993992245
72 5957959665
73 6394862637
74
75 After step 2:
76 8807476555
77 5089087054
78 8597889608
79 8485769600
80 8700908800
81 6600088989
82 6800005943
83 0000007456
84 9000000876
85 8700006848
86
87 After step 3:
88 0050900866
89 8500800575
90 9900000039
91 9700000041
92 9935080063
93 7712300000
94 7911250009
95 2211130000
96 0421125000
97 0021119000
98
99 After step 4:
100 2263031977
101 0923031697
102 0032221150
103 0041111163
104 0076191174
105 0053411122
106 0042361120
107 5532241122
108 1532247211
109 1132230211
110
111 After step 5:
112 4484144000
113 2044144000
114 2253333493
115 1152333274
116 1187303285
117 1164633233
118 1153472231
119 6643352233
120 2643358322
121 2243341322
122
123 After step 6:
124 5595255111
125 3155255222
126 3364444605
127 2263444496
128 2298414396
129 2275744344
130 2264583342
131 7754463344
132 3754469433
133 3354452433
134
135 After step 7:
136 6707366222
137 4377366333
138 4475555827
139 3496655709
140 3500625609
141 3509955566
142 3486694453
143 8865585555
144 4865580644
145 4465574644
146
147 After step 8:
148 7818477333
149 5488477444
150 5697666949
151 4608766830
152 4734946730
153 4740097688
154 6900007564
155 0000009666
156 8000004755
157 6800007755
158
159 After step 9:
160 9060000644
161 7800000976
162 6900000080
163 5840000082
164 5858000093
165 6962400000
166 8021250009
167 2221130009
168 9111128097
169 7911119976
170
171 After step 10:
172 0481112976
173 0031112009
174 0041112504
175 0081111406
176 0099111306
177 0093511233
178 0442361130
179 5532252350
180 0532250600
181 0032240000
182 After step 10, there have been a total of 204 flashes. Fast forwarding, here is the same configuration every 10 steps:
183
184 After step 20:
185 3936556452
186 5686556806
187 4496555690
188 4448655580
189 4456865570
190 5680086577
191 7000009896
192 0000000344
193 6000000364
194 4600009543
195
196 After step 30:
197 0643334118
198 4253334611
199 3374333458
200 2225333337
201 2229333338
202 2276733333
203 2754574565
204 5544458511
205 9444447111
206 7944446119
207
208 After step 40:
209 6211111981
210 0421111119
211 0042111115
212 0003111115
213 0003111116
214 0065611111
215 0532351111
216 3322234597
217 2222222976
218 2222222762
219
220 After step 50:
221 9655556447
222 4865556805
223 4486555690
224 4458655580
225 4574865570
226 5700086566
227 6000009887
228 8000000533
229 6800000633
230 5680000538
231
232 After step 60:
233 2533334200
234 2743334640
235 2264333458
236 2225333337
237 2225333338
238 2287833333
239 3854573455
240 1854458611
241 1175447111
242 1115446111
243
244 After step 70:
245 8211111164
246 0421111166
247 0042111114
248 0004211115
249 0000211116
250 0065611111
251 0532351111
252 7322235117
253 5722223475
254 4572222754
255
256 After step 80:
257 1755555697
258 5965555609
259 4486555680
260 4458655580
261 4570865570
262 5700086566
263 7000008666
264 0000000990
265 0000000800
266 0000000000
267
268 After step 90:
269 7433333522
270 2643333522
271 2264333458
272 2226433337
273 2222433338
274 2287833333
275 2854573333
276 4854458333
277 3387779333
278 3333333333
279
280 After step 100:
281 0397666866
282 0749766918
283 0053976933
284 0004297822
285 0004229892
286 0053222877
287 0532222966
288 9322228966
289 7922286866
290 6789998766
291 After 100 steps, there have been a total of 1656 flashes.
292
293 Given the starting energy levels of the dumbo octopuses in your cavern, simulate 100 steps. How many total flashes are there after 100 steps?
294
295 Your puzzle answer was 1675.
296
297 --- Part Two ---
298 It seems like the individual flashes aren't bright enough to navigate. However, you might have a better option: the flashes seem to be synchronizing!
299
300 In the example above, the first time all octopuses flash simultaneously is step 195:
301
302 After step 193:
303 5877777777
304 8877777777
305 7777777777
306 7777777777
307 7777777777
308 7777777777
309 7777777777
310 7777777777
311 7777777777
312 7777777777
313
314 After step 194:
315 6988888888
316 9988888888
317 8888888888
318 8888888888
319 8888888888
320 8888888888
321 8888888888
322 8888888888
323 8888888888
324 8888888888
325
326 After step 195:
327 0000000000
328 0000000000
329 0000000000
330 0000000000
331 0000000000
332 0000000000
333 0000000000
334 0000000000
335 0000000000
336 0000000000
337 If you can calculate the exact moments when the octopuses will all flash simultaneously, you should be able to navigate through the cavern. What is the first step during which all octopuses flash?
338
339 Your puzzle answer was 515.
340
341 Both parts of this puzzle are complete! They provide two gold stars: **
342
343 At this point, you should return to your Advent calendar and try another puzzle.
344
345 If you still want to see it, you can get your puzzle input.
346
347 You can also [Share] this puzzle.