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.
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.
6 Each octopus has an energy level - your submarine can remotely measure the energy level of each octopus (your puzzle input). For example:
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.
20 You can model the energy levels and flashes of light in steps. During a single step, the following occurs:
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:
47 An octopus is highlighted when it flashed during the given step.
49 Here is how the larger example above progresses:
182 After step 10, there have been a total of 204 flashes. Fast forwarding, here is the same configuration every 10 steps:
291 After 100 steps, there have been a total of 1656 flashes.
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?
295 Your puzzle answer was 1675.
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!
300 In the example above, the first time all octopuses flash simultaneously is step 195:
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?
339 Your puzzle answer was 515.
341 Both parts of this puzzle are complete! They provide two gold stars: **
343 At this point, you should return to your Advent calendar and try another puzzle.
345 If you still want to see it, you can get your puzzle input.
347 You can also [Share] this puzzle.