use itertools::Itertools; const INPUT: &str = include_str!("../inputs/01"); fn input_numbers() -> impl Iterator { INPUT.lines().filter_map(|s| s.parse::().ok()) } fn part_1() -> usize { input_numbers() .tuple_windows() .filter(|(a, b)| b > a) .count() } fn part_2() -> usize { input_numbers() .tuple_windows() .map(|(a, b, c)| a + b + c) .tuple_windows() .filter(|(a, b)| b > a) .count() } pub fn main() { println!("Day 1:"); println!(" Part 1: {}", part_1()); println!(" Part 2: {}", part_2()); }