aoc::year2017

Module day14

Source
Expand description

§Disk Defragmentation

This problem is a blend of the hashing from Day 10 and the connected clique finding from Day 12 and reuses the same flood fill approach to count groups.

Structs§

  • Exclusive 🔒
    Regular data structures need to be protected by a mutex.
  • Atomics can be safely shared between threads.

Functions§

  • dfs 🔒
    Flood fill that explores the connected squares in the grid.
  • fill_row 🔒
    Compute the knot hash for a row and expand into an array of bytes.
  • knot_hash 🔒
    Slightly tweaked version of the code from Day 10 that always performs 64 rounds.
  • Parallelize the hashing as each row is independent.
  • worker 🔒
    Each worker thread chooses the next available index then computes the hash and patches the final vec with the result.