Module aoc::year2021::day11

source ·
Expand description

§Dumbo Octopus

This puzzle resembles the Day 9 flood fill a little. Since there are only 100 octopuses a fixed size array is used both to track current energy levels and a second array to track if an octopus has flashed this turn. Each time an octopus flashes it bumps its neighbors energy levels, which can propagate recursively through the entire grid.

Constants§

  • NEIGHBORS 🔒
    Offsets for each of the eight neighbors. The last four offsets will wrap around when added to u8 to give a smaller index.

Functions§

Type Aliases§

  • Input 🔒
    Pad the 10x10 grid by 1 on either side so that we can avoid boundary checks.