This commit is contained in:
2022-12-01 07:14:55 +01:00
parent 907e17ae44
commit 2fd479d02d
3 changed files with 2263 additions and 3 deletions

View File

@ -2,4 +2,29 @@ use crate::read;
pub fn run() {
let input = read("01");
let set = vec![0];
let mut res = input.lines().fold(set, |mut acc, x|{
if x.is_empty() {
acc.push(0);
} else {
let num: i32 = x.parse().unwrap();
*acc.last_mut().unwrap() += num;
}
acc
});
res.sort();
res.reverse();
#[cfg(feature="part2")]
{
let a = res.first().unwrap();
eprintln!("Part 01: {}", *a);
}
#[cfg(feature="part2")]
{
let b: i32 = res[..3].iter().sum();
eprintln!("Part 02: {}", b);
}
}