This commit is contained in:
dolphinau 2025-12-01 18:43:14 +01:00
parent fc496204e7
commit e6471a3c3f
No known key found for this signature in database

View file

@ -3,12 +3,32 @@ use crate::days::Solution;
pub struct Day01;
impl Solution for Day01 {
type Input = ();
type Input = Vec<i16>;
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::<String>().parse::<i16>();
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 {