1
0
Fork 0

day(07): remove debugs

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-12-07 14:50:55 +01:00
parent b3b26cd6a9
commit b574bc6999
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -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]