diff options
author | Andreas Grois <andi@grois.info> | 2021-12-06 18:25:30 +0100 |
---|---|---|
committer | Andreas Grois <andi@grois.info> | 2021-12-06 18:29:53 +0100 |
commit | 66248e33e20868c4cc3d6872f1550c0bf9522a94 (patch) | |
tree | 193424e78906cd58ccf0c417fcdbbcdcb6826400 /src/day1.rs | |
parent | 33d3f533e61d1da6a50b839ff25aede62cfffbdf (diff) |
Let's not talk about the other solutions, 'kay?
Diffstat (limited to 'src/day1.rs')
-rw-r--r-- | src/day1.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/day1.rs b/src/day1.rs index 3e9037a..5c4949b 100644 --- a/src/day1.rs +++ b/src/day1.rs @@ -21,6 +21,15 @@ pub fn solve_part1_iterators(input : &Vec<u32>) -> usize { input.iter().skip(1).zip(input.iter()).filter(|(new, old)| new > old).count() } +#[aoc(day1, part2, ItTookMeWayTooLongToRealizeThis)] +pub fn solve_part2_correct_solution(input : &Vec<u32>) -> usize { + input.iter().skip(3).zip(input.iter()).filter(|(new, old)| new > old).count() +} + +//-------------------------------------------------------------------------------------------- +//let's not talk about the stuff below. It's just here for reference. Because it took me way too +//long to realize that part 2 is just part 1 with a different offset... + #[aoc(day1, part2, InternalState)] pub fn solve_part2(input : &Vec<u32>) -> usize { let floating_window :u32 = input.iter().take(3).sum(); @@ -192,3 +201,5 @@ pub fn solve_part2_accumulator_infallible(input : &Vec<u32>) -> Option<u32> { } ) } + + |