Module aoc::year2017::day06

source ·
Expand description

§Memory Reallocation

Looking at the input and the reallocation rules, we make an assertion:

  • No memory bank will ever exceed 15 blocks.

This has a nice effect that we can store the entire memory layout packed into a single u64 with each memory bank represented by a nibble.

This makes it very fast to find the highest nibble using bitwise logic. To detect the cycle a FastMap stores each previously seen memory layout along with the cycle that it first appeared.

Constants§

  • REMOVE 🔒
    Reallocate a bank and set to zero by rotating this mask the correct number of bits.
  • SPREAD 🔒
    The highest number of banks possible is 15, so each bank will add at most 1 to each of the banks that come after it.

Functions§

Type Aliases§