aoc::year2020

Module day11

Source
Expand description

ยงSeating System

Cellular automata are hard to speed up due to the need to check all neighbors each iteration. For both parts we minimize expensive memory allocation by creating only two temporary buffers then swapping between them each turn, a similar approach to double buffering.

For part two we can further optimize by precalculating the locations of the nearest visible seats only once then reusing that information for each step.

Structsยง

Constantsยง

Functionsยง