Day 7, puzzle 1

This commit is contained in:
jazzpi
2022-12-14 13:26:20 +01:00
parent a446a05c07
commit bedf4a790a
3 changed files with 179 additions and 0 deletions

20
src/bin/d7p1.rs Normal file
View File

@ -0,0 +1,20 @@
use aoc22::{day7, util};
const MAX_SIZE: usize = 100000;
pub fn main() {
let root = day7::parse_cmdline(&util::parse_input());
let mut total_size = 0;
for child in root.borrow().all_children() {
let c = &*child.borrow();
if let day7::Node::Dir { .. } = c {
let size = c.size();
if size <= MAX_SIZE {
total_size += size;
}
}
}
println!("Total size of small directories: {}", total_size);
}