Expand description
This is my solution for Advent of Code - Day 9: Disk Fragmenter
parse_input
Marks each of the entries as a FILE
or SPACE
, along with caching their
position on disk, and the id of the files.
calculate_checksum
solves the puzzle, delegating to pack_files
which calculates the final position of the
files. fill_space_with_fragmentation
Is the logic for filling in disk space for part 1,
fill_space_without_fragmentation
for part 2.
StructsΒ§
EnumsΒ§
- Disk
Usage πAn enum to union both types of disk usage
FunctionsΒ§
- calculate_
checksum πReduces the list of packed files to the puzzle solution - Part 1 space filler - split files to fully fill in every hole
- Part 2 space filler - only move files into spaces they fit
- pack_
files πThe common logic for reading from both ends of the disk usage map, outputting files as their final position becomes known. - parse_
input πTurn input into alternating file/space entries. Filtering out any with size 0 - The entry point for running the solutions with the βrealβ puzzle input.
Type AliasesΒ§
- Space
Filler πThis represents the difference between the parts.