Module advent_solutions::advent2017::day14
[−]
[src]
Day 14: Disk Defragmentation
Suddenly, a scheduled job activates the system's disk defragmenter. Were the situation different, you might sit and watch it for a while, but today, you just don't have that kind of time. It's soaking up valuable system resources that are needed elsewhere, and so the only option is to help it finish its task as soon as possible.
Structs
| Grid |
The disk in question consists of a 128x128 grid; each square of the grid is either free or used. On this disk, the state of the grid is tracked by the bits in a sequence of knot hashes. |
Functions
| make_hashes |
A total of 128 knot hashes are calculated, each corresponding to a
single row in the grid; each hash contains 128 bits which correspond to
individual grid squares. Each bit of a hash indicates whether that
square is free ( |
| parse_input | |
| part1 |
The output of a knot hash is traditionally represented by 32 hexadecimal
digits; each of these digits correspond to 4 bits, for a total of
|
| part2 |
Now, all the defragmenter needs to know is the number of regions. A region is a group of used squares that are all adjacent, not including diagonals. Every used square is in exactly one region: lone used squares form their own isolated regions, while several adjacent squares all count as a single region. |