diff options
author | Yigit Sever | 2022-12-01 17:43:04 +0300 |
---|---|---|
committer | Yigit Sever | 2022-12-01 17:43:04 +0300 |
commit | 5055786d3db80e45a5c3f128f41866ea78865c45 (patch) | |
tree | 19f8df50614798285ffdd8556e28bb7840c02c34 /2022/day1/part1/src/main.rs | |
parent | 00731fd04963873b99e8a1d2571f27c87d8b7658 (diff) | |
download | aoc-5055786d3db80e45a5c3f128f41866ea78865c45.tar.gz aoc-5055786d3db80e45a5c3f128f41866ea78865c45.tar.bz2 aoc-5055786d3db80e45a5c3f128f41866ea78865c45.zip |
2022, day1: done
Diffstat (limited to '2022/day1/part1/src/main.rs')
-rw-r--r-- | 2022/day1/part1/src/main.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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 @@ | |||
1 | use itertools::Itertools; | ||
2 | |||
3 | fn main() { | ||
4 | let input: String = include_str!("../../input").to_string(); | ||
5 | let mut calories: Vec<usize> = Vec::new(); | ||
6 | |||
7 | for (key, group) in &input.lines().group_by(|line| *line != "") { | ||
8 | if key { | ||
9 | calories.push(group.into_iter().map(|i| i.parse::<usize>().unwrap()).sum()); | ||
10 | } | ||
11 | } | ||
12 | |||
13 | println!("{}", calories.iter().max().unwrap()); | ||
14 | } | ||