25 lines
539 B
Markdown
25 lines
539 B
Markdown
Advent of code 2024
|
|
|
|
Day 1
|
|
|
|
Usage:
|
|
|
|
rustc d1p1.rs
|
|
cat input.txt | ./d1p1
|
|
|
|
Part 1:
|
|
|
|
Parse each line into a pair of ints; store them in a pair of heaps.
|
|
Convert heaps into sorted lists. Iterate through them together
|
|
and find the absolute difference between each pair of numbers.
|
|
|
|
Part 2:
|
|
|
|
Parse each line into a pair of ints; store the first in an array,
|
|
place the second into a map that accumulate the number of times
|
|
a value is seen.
|
|
|
|
Iterate through the array, adding the number times the number of
|
|
times it was seen in the map.
|
|
|