diff --git a/AoC_2025/src/days/day01.rs b/AoC_2025/src/days/day01.rs index 72fef3a..932bd4c 100644 --- a/AoC_2025/src/days/day01.rs +++ b/AoC_2025/src/days/day01.rs @@ -3,12 +3,32 @@ use crate::days::Solution; pub struct Day01; impl Solution for Day01 { - type Input = (); + type Input = Vec; - fn parse(&self, data: &str) -> Self::Input {} + fn parse(&self, data: &str) -> Self::Input { + data.split("\n") + .map(|l| { + let mut chars = l.chars(); + let first = chars.next(); + let num = chars.collect::().parse::(); + + match (first, num) { + (Some('L'), Ok(n)) => -1 * n, + (Some('R'), Ok(n)) => n, + _ => 0, + } + }) + .collect() + } fn part1(&self, input: &Self::Input) -> usize { - 0 + input + .iter() + .fold((50, 0), |(sum, res), x| match (sum + x) % 100 { + 0 => (0, res + 1), + newsum => (newsum, res), + }) + .1 } fn part2(&self, input: &Self::Input) -> usize {