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

View File

@ -10,9 +10,9 @@ chrono = "0.4.23"
regex = "1.7.0" regex = "1.7.0"
[features] [features]
default = ["a", "b", "today"] default = ["part1", "part2", "today"]
a = [] part1 = []
b = [] part2 = []
today = [] today = []
01 = [] 01 = []
02 = [] 02 = []

File diff suppressed because it is too large Load Diff

View File

@ -2,4 +2,29 @@ use crate::read;
pub fn run() { pub fn run() {
let input = read("01"); 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);
}
} }