day07: Changes for part 2
Now that we have the sizes of the directories in a list, it's quite easy to work with them to get part 2 using Iterator functions.
This commit is contained in:
parent
2620d59a8f
commit
bc3599fff0
|
@ -153,8 +153,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
|
||||
// compute sizes
|
||||
let sizes = fs_tree.get_dir_sizes();
|
||||
println!("{}", sizes.iter().filter(|x| **x < 100000).sum::<u32>());
|
||||
|
||||
println!("Hello, world!");
|
||||
let full_space = 70000000;
|
||||
let free_space = full_space - sizes[sizes.len() - 1];
|
||||
let needed_space = 30000000 - free_space;
|
||||
println!("{}", sizes.iter().filter(|x| **x > needed_space).min().unwrap());
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue