20 lines
492 B
Rust
20 lines
492 B
Rust
#![allow(dead_code, unused_imports)]
|
|
use anyhow::Result;
|
|
use itertools::Itertools;
|
|
|
|
use std::{io::{stdin, Read}, str::FromStr};
|
|
|
|
fn descending_window(size: usize) -> Result<usize> {
|
|
Ok(aoc::read_one_per_line::<u32>("./data/1.depths")?
|
|
.windows(size)
|
|
.filter(|win| win[0] < win[size - 1])
|
|
.collect_vec()
|
|
.len())
|
|
}
|
|
|
|
fn main() -> Result<()> {
|
|
println!("Part 1: {}", descending_window(2)?);
|
|
println!("Part 2: {}", descending_window(4)?);
|
|
|
|
Ok(())
|
|
}
|