From 2437fc0e6f51342ccc83b71fa9dc6492353e7d55 Mon Sep 17 00:00:00 2001 From: Tobias Berger Date: Mon, 12 Dec 2022 10:19:06 +0100 Subject: [PATCH] Revert "Rust Day 7 - Better `cd /`" because it actually broke things? This reverts commit ec9f1e92bc4731a126eccf3f5ea511003f576f84. --- rust/src/day07/part_1.rs | 5 +++-- rust/src/day07/part_2.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rust/src/day07/part_1.rs b/rust/src/day07/part_1.rs index c6a0ab7..3598f14 100644 --- a/rust/src/day07/part_1.rs +++ b/rust/src/day07/part_1.rs @@ -9,8 +9,9 @@ pub(crate) fn part_1(input: &Vec) -> usize { for line in input { match line { ConsoleLine::MoveRoot => { - current_directory.clear(); - current_directory.push(""); + while current_directory.len() > 1 { + current_directory.pop(); + } } ConsoleLine::MoveUp => { current_directory.pop(); diff --git a/rust/src/day07/part_2.rs b/rust/src/day07/part_2.rs index 9488b95..f70c957 100644 --- a/rust/src/day07/part_2.rs +++ b/rust/src/day07/part_2.rs @@ -11,8 +11,9 @@ pub(crate) fn part_2(input: &Vec) -> usize { for line in input { match line { ConsoleLine::MoveRoot => { - current_directory.clear(); - current_directory.push(""); + while current_directory.len() > 1 { + current_directory.pop(); + } } ConsoleLine::MoveUp => { current_directory.pop();