From b574bc699916bb770ef03f8ec72a4a27d0c8cc41 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Wed, 7 Dec 2022 14:50:55 +0100 Subject: [PATCH] day(07): remove debugs Signed-off-by: Matej Focko --- src/bin/day07.rs | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/bin/day07.rs b/src/bin/day07.rs index 2fb7619..731224d 100644 --- a/src/bin/day07.rs +++ b/src/bin/day07.rs @@ -41,10 +41,7 @@ impl AocFile { fn cd(&mut self, dir: &str) -> FileHandle { if let AocFile::Directory(files) = self { - let handle = files.entry(dir.to_string()).or_default().clone(); - - // debug!("Entering directory: {:?}", handle); - return handle; + return files.entry(dir.to_string()).or_default().clone(); } panic!("cannot cd in file") @@ -58,10 +55,7 @@ impl AocFile { .values() .map(|f| f.borrow().size_under_100000()) .fold((0_usize, 0_usize), |(mut running, size), (dir, r, s)| { - // debug!("Checking ({}, {}, {})", dir, r, s); - if dir && s <= 100000 { - // debug!("Is small (hehe) directory, adding to total: {s}"); running += s; } @@ -119,8 +113,6 @@ impl Filesystem { } fn cd(&mut self, dir: &str) { - // debug!("swish swish: {}", dir); - match dir { ".." => { self.cwd.pop(); @@ -139,7 +131,6 @@ impl Filesystem { fn touch(&mut self, name: &str, size: usize) { let idx = self.cwd.len() - 1; - // debug!("touchy touchy: {} ({})", name, size); self.cwd[idx].borrow_mut().add_file(name, size); } @@ -170,7 +161,6 @@ impl FromStr for Filesystem { let mut fs = Filesystem::new(); for command in s.trim_start_matches("$ ").split("\n$ ") { - // debug!("Running command: {}", command); fs.run_command(command); } @@ -188,16 +178,10 @@ fn part_1(input: &Input) -> Output { fn part_2(input: &Input) -> Output { let (total, needed) = (70000000, 30000000); let used = input.root.borrow().size_under_100000().2; + // to_be_freed >= needed - (total - used) let to_be_freed = needed - (total - used); - // debug!( - // "Used: {}, free: {}, to_be_freed: {}", - // used, - // total - used, - // to_be_freed - // ); - input.root.borrow().smallest_bigger(to_be_freed).1 } @@ -225,7 +209,7 @@ fn main() -> Result<()> { } #[cfg(test)] -mod day_06 { +mod day_07 { use super::*; #[test]