mirror of
https://github.com/rjNemo/ai_advent_code_2024
synced 2026-06-06 02:26:44 +00:00
| .. | ||
| day1.ex | ||
| README.md | ||
Day 1: Historian Hysteria
Part 1: Distance Calculation
Given pairs of numbers, calculate the total distance between sorted pairs.
Input Format
Each line contains two space-separated integers.
Example:
39687 54930
86219 31559
48536 73145
Algorithm
- Sort both sequences of numbers
- Calculate absolute differences between paired numbers
- Sum all differences
Part 2: Similarity Score
Calculate similarity scores based on frequency matching between number sequences.
Algorithm
- Calculate frequency of numbers in right sequence
- For each number in left sequence, multiply by its frequency in right sequence
- Sum all products