description.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. 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.
  4. Each octopus has an energy level - your submarine can remotely measure the energy level of each octopus (your puzzle input). For example:
  5. 5483143223
  6. 2745854711
  7. 5264556173
  8. 6141336146
  9. 6357385478
  10. 4167524645
  11. 2176841721
  12. 6882881134
  13. 4846848554
  14. 5283751526
  15. 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.
  16. You can model the energy levels and flashes of light in steps. During a single step, the following occurs:
  17. First, the energy level of each octopus increases by 1.
  18. 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.)
  19. Finally, any octopus that flashed during this step has its energy level set to 0, as it used all of its energy to flash.
  20. 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:
  21. Before any steps:
  22. 11111
  23. 19991
  24. 19191
  25. 19991
  26. 11111
  27. After step 1:
  28. 34543
  29. 40004
  30. 50005
  31. 40004
  32. 34543
  33. After step 2:
  34. 45654
  35. 51115
  36. 61116
  37. 51115
  38. 45654
  39. An octopus is highlighted when it flashed during the given step.
  40. Here is how the larger example above progresses:
  41. Before any steps:
  42. 5483143223
  43. 2745854711
  44. 5264556173
  45. 6141336146
  46. 6357385478
  47. 4167524645
  48. 2176841721
  49. 6882881134
  50. 4846848554
  51. 5283751526
  52. After step 1:
  53. 6594254334
  54. 3856965822
  55. 6375667284
  56. 7252447257
  57. 7468496589
  58. 5278635756
  59. 3287952832
  60. 7993992245
  61. 5957959665
  62. 6394862637
  63. After step 2:
  64. 8807476555
  65. 5089087054
  66. 8597889608
  67. 8485769600
  68. 8700908800
  69. 6600088989
  70. 6800005943
  71. 0000007456
  72. 9000000876
  73. 8700006848
  74. After step 3:
  75. 0050900866
  76. 8500800575
  77. 9900000039
  78. 9700000041
  79. 9935080063
  80. 7712300000
  81. 7911250009
  82. 2211130000
  83. 0421125000
  84. 0021119000
  85. After step 4:
  86. 2263031977
  87. 0923031697
  88. 0032221150
  89. 0041111163
  90. 0076191174
  91. 0053411122
  92. 0042361120
  93. 5532241122
  94. 1532247211
  95. 1132230211
  96. After step 5:
  97. 4484144000
  98. 2044144000
  99. 2253333493
  100. 1152333274
  101. 1187303285
  102. 1164633233
  103. 1153472231
  104. 6643352233
  105. 2643358322
  106. 2243341322
  107. After step 6:
  108. 5595255111
  109. 3155255222
  110. 3364444605
  111. 2263444496
  112. 2298414396
  113. 2275744344
  114. 2264583342
  115. 7754463344
  116. 3754469433
  117. 3354452433
  118. After step 7:
  119. 6707366222
  120. 4377366333
  121. 4475555827
  122. 3496655709
  123. 3500625609
  124. 3509955566
  125. 3486694453
  126. 8865585555
  127. 4865580644
  128. 4465574644
  129. After step 8:
  130. 7818477333
  131. 5488477444
  132. 5697666949
  133. 4608766830
  134. 4734946730
  135. 4740097688
  136. 6900007564
  137. 0000009666
  138. 8000004755
  139. 6800007755
  140. After step 9:
  141. 9060000644
  142. 7800000976
  143. 6900000080
  144. 5840000082
  145. 5858000093
  146. 6962400000
  147. 8021250009
  148. 2221130009
  149. 9111128097
  150. 7911119976
  151. After step 10:
  152. 0481112976
  153. 0031112009
  154. 0041112504
  155. 0081111406
  156. 0099111306
  157. 0093511233
  158. 0442361130
  159. 5532252350
  160. 0532250600
  161. 0032240000
  162. After step 10, there have been a total of 204 flashes. Fast forwarding, here is the same configuration every 10 steps:
  163. After step 20:
  164. 3936556452
  165. 5686556806
  166. 4496555690
  167. 4448655580
  168. 4456865570
  169. 5680086577
  170. 7000009896
  171. 0000000344
  172. 6000000364
  173. 4600009543
  174. After step 30:
  175. 0643334118
  176. 4253334611
  177. 3374333458
  178. 2225333337
  179. 2229333338
  180. 2276733333
  181. 2754574565
  182. 5544458511
  183. 9444447111
  184. 7944446119
  185. After step 40:
  186. 6211111981
  187. 0421111119
  188. 0042111115
  189. 0003111115
  190. 0003111116
  191. 0065611111
  192. 0532351111
  193. 3322234597
  194. 2222222976
  195. 2222222762
  196. After step 50:
  197. 9655556447
  198. 4865556805
  199. 4486555690
  200. 4458655580
  201. 4574865570
  202. 5700086566
  203. 6000009887
  204. 8000000533
  205. 6800000633
  206. 5680000538
  207. After step 60:
  208. 2533334200
  209. 2743334640
  210. 2264333458
  211. 2225333337
  212. 2225333338
  213. 2287833333
  214. 3854573455
  215. 1854458611
  216. 1175447111
  217. 1115446111
  218. After step 70:
  219. 8211111164
  220. 0421111166
  221. 0042111114
  222. 0004211115
  223. 0000211116
  224. 0065611111
  225. 0532351111
  226. 7322235117
  227. 5722223475
  228. 4572222754
  229. After step 80:
  230. 1755555697
  231. 5965555609
  232. 4486555680
  233. 4458655580
  234. 4570865570
  235. 5700086566
  236. 7000008666
  237. 0000000990
  238. 0000000800
  239. 0000000000
  240. After step 90:
  241. 7433333522
  242. 2643333522
  243. 2264333458
  244. 2226433337
  245. 2222433338
  246. 2287833333
  247. 2854573333
  248. 4854458333
  249. 3387779333
  250. 3333333333
  251. After step 100:
  252. 0397666866
  253. 0749766918
  254. 0053976933
  255. 0004297822
  256. 0004229892
  257. 0053222877
  258. 0532222966
  259. 9322228966
  260. 7922286866
  261. 6789998766
  262. After 100 steps, there have been a total of 1656 flashes.
  263. Given the starting energy levels of the dumbo octopuses in your cavern, simulate 100 steps. How many total flashes are there after 100 steps?
  264. Your puzzle answer was 1571.
  265. --- Part Two ---
  266. 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!
  267. In the example above, the first time all octopuses flash simultaneously is step 195:
  268. After step 193:
  269. 5877777777
  270. 8877777777
  271. 7777777777
  272. 7777777777
  273. 7777777777
  274. 7777777777
  275. 7777777777
  276. 7777777777
  277. 7777777777
  278. 7777777777
  279. After step 194:
  280. 6988888888
  281. 9988888888
  282. 8888888888
  283. 8888888888
  284. 8888888888
  285. 8888888888
  286. 8888888888
  287. 8888888888
  288. 8888888888
  289. 8888888888
  290. After step 195:
  291. 0000000000
  292. 0000000000
  293. 0000000000
  294. 0000000000
  295. 0000000000
  296. 0000000000
  297. 0000000000
  298. 0000000000
  299. 0000000000
  300. 0000000000
  301. 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?
  302. Your puzzle answer was 387.