1
0
Fork 0
aoc2022/src/day1/1.rs

32 lines
688 B
Rust

#![feature(test)]
extern crate test;
const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")];
fn parse(input: &'static str) -> Vec<Vec<i64>> {
input
.trim()
.split("\n\n")
.map(|set| {
set.split('\n')
.map(|c| c.trim())
.map(|c| c.parse::<i64>().unwrap())
.collect()
})
.collect()
}
fn main() {
for input in INPUTS.iter() {
let output = parse(input);
let max = output
.into_iter()
.map(|c| c.into_iter().sum::<i64>())
.max()
.unwrap();
println!("{}", max);
}
}