mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 09:33:19 -09:00
solve problem 1
This commit is contained in:
parent
8bc687743d
commit
26544fc9a3
18
src/day1.rs
Normal file → Executable file
18
src/day1.rs
Normal file → Executable file
@ -1,7 +1,21 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn parse_input(input: &str) -> Vec<u32> {
|
||||
input.split_ascii_whitespace().map(|x| x.parse().unwrap() ).collect()
|
||||
}
|
||||
|
||||
fn part_1_solution(input: &str) -> u64 {
|
||||
parse_input(input)
|
||||
.as_slice()
|
||||
.windows(2)
|
||||
.fold(0, |acc, w| if w[0] < w[1] { acc + 1 } else { acc })
|
||||
}
|
||||
|
||||
|
||||
todo!();
|
||||
fn part_2_solution(input: &str) -> u64 {
|
||||
parse_input(input)
|
||||
.as_slice()
|
||||
.windows(4)
|
||||
.fold(0, |acc, w| if w[0] < w[3] { acc + 1 } else { acc })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user