From 5055786d3db80e45a5c3f128f41866ea78865c45 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Thu, 1 Dec 2022 17:43:04 +0300 Subject: 2022, day1: done --- 2022/day1/part1/src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 2022/day1/part1/src/main.rs (limited to '2022/day1/part1/src/main.rs') diff --git a/2022/day1/part1/src/main.rs b/2022/day1/part1/src/main.rs new file mode 100644 index 0000000..637b4e3 --- /dev/null +++ b/2022/day1/part1/src/main.rs @@ -0,0 +1,14 @@ +use itertools::Itertools; + +fn main() { + let input: String = include_str!("../../input").to_string(); + let mut calories: Vec = Vec::new(); + + for (key, group) in &input.lines().group_by(|line| *line != "") { + if key { + calories.push(group.into_iter().map(|i| i.parse::().unwrap()).sum()); + } + } + + println!("{}", calories.iter().max().unwrap()); +} -- cgit v1.2.3-70-g09d2