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.
Shared
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.
parse
Parallelize the hashing as each row is independent.
part1
part2
worker ๐Ÿ”’
Each worker thread chooses the next available index then computes the hash and patches the final vec with the result.