aboutsummaryrefslogtreecommitdiff
path: root/2022/src/day01.rs
diff options
context:
space:
mode:
Diffstat (limited to '2022/src/day01.rs')
-rw-r--r--2022/src/day01.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/2022/src/day01.rs b/2022/src/day01.rs
new file mode 100644
index 0000000..a328975
--- /dev/null
+++ b/2022/src/day01.rs
@@ -0,0 +1,21 @@
+use crate::utils::max_n;
+
+mod utils;
+
+fn main() {
+ let input = utils::read_input();
+
+ let mut elf_cal_counts: Vec<usize> = input
+ .split("\n\n")
+ .map(|xs| {
+ xs.lines()
+ .map(|x| x.parse::<usize>().unwrap())
+ .sum::<usize>()
+ })
+ .collect();
+
+ let top_3 = max_n(&mut elf_cal_counts, 3);
+
+ println!("Max: {}", top_3.last().unwrap());
+ println!("Sum of top 3: {}", top_3.iter().sum::<usize>());
+}