This commit is contained in:
Olivier David Laplante
2025-12-01 11:02:04 -05:00
parent 67d3eb6e76
commit 84e553f4c7
3 changed files with 4511 additions and 2 deletions

View File

@@ -1,5 +1,15 @@
pub fn run(input: &str) { pub fn run(input: &str) {
let step_list = input.lines()
.map(|l| l.replace("L", "").replace("R", "-").parse::<i32>().unwrap());
let counted = step_list.scan(50, |dial, steps| {
let at_0 = (*dial..(*dial + steps))
.chain((*dial + steps + 1)..=*dial)
.filter(|num| *num % 100 == 0).count();
*dial += steps;
Some((*dial % 100 == 0, at_0))
});
println!("Part 1: {}", counted.clone().filter(|(is_0, _)| *is_0).count());
println!("Part 2: {}", counted.fold(0, |acc, num| acc + num.1));
} }

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ mod day1;
const CHOICES: [&str; 2] = [ const CHOICES: [&str; 2] = [
"Exit", "Exit",
"Day 1: ", "Day 1: Secret Entrance",
]; ];
fn main() { fn main() {