Expand description
This is my solution for Advent of Code - Day 1: Historian Hysteria
The input has been turned into a list of u32 for each column by parse_input
. Part 1 is solved in two steps
to_sorted_pairs
sorts the lists and zips them together, then sum_diffs
reduces the list of pairs to the
puzzle solution. Part 2 is solved by sum_similarity_scores
.
FunctionsΒ§
- parse_
input πBuild up lists of ids from the puzzle input. The input is two columns of numbers separated by three spaces, e.g. - The entry point for running the solutions with the βrealβ puzzle input.
- sum_
diffs πThe second part of the solution to part 1, given a sorted list of pairs, sum the distance between them - The solution to part 2. The similarity score for a number in the left-hand column is that number multiplied by the number of times it appears in the right-hand column.
- to_
sorted_ πpairs The first part of the solution to part 1. Pair the lowest integers in each list, then second lowest, and so onβ¦