Day 7, puzzle 1
This commit is contained in:
20
src/bin/d7p1.rs
Normal file
20
src/bin/d7p1.rs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user