From e0f7e353eabe4bb4597a6fcfa93d14bf9eb7ab42 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 7 Dec 2022 10:28:19 -0500 Subject: Solve day 7 part 2 --- 2022/day07.awk | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to '2022') diff --git a/2022/day07.awk b/2022/day07.awk index 4143a8b..ddcc7b0 100644 --- a/2022/day07.awk +++ b/2022/day07.awk @@ -24,4 +24,13 @@ END { sum += dirs[dir]; } print sum; + used = dirs["/"]; + unused = 70000000 - used; + needed = 30000000 - unused; + min = used; + for (dir in dirs) { + if (dirs[dir] < needed) continue; + if (dirs[dir] < min) min = dirs[dir]; + } + print min; } -- cgit 1.4.1