ai_advent_code_2024/lib/advent_code2024/solutions/day1
Ruidy (aider) ac7eea0f9b
feat: Reorganize project structure for Day 1 solution
This commit:
- Moves input files to priv/inputs/day1/
- Creates solutions directory in lib/advent_code2024/solutions/
- Adds README.md with problem description
- Updates module and import paths
- Removes old directory structure
2024-12-01 18:10:25 +01:00
..
day1.ex feat: Reorganize project structure for Day 1 solution 2024-12-01 18:10:25 +01:00
README.md feat: Reorganize project structure for Day 1 solution 2024-12-01 18:10:25 +01:00

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

  1. Sort both sequences of numbers
  2. Calculate absolute differences between paired numbers
  3. Sum all differences

Part 2: Similarity Score

Calculate similarity scores based on frequency matching between number sequences.

Algorithm

  1. Calculate frequency of numbers in right sequence
  2. For each number in left sequence, multiply by its frequency in right sequence
  3. Sum all products