summary refs log tree commit diff homepage
path: root/2022
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-12-07 10:28:19 -0500
committerJune McEnroe <june@causal.agency>2022-12-07 10:28:19 -0500
commite0f7e353eabe4bb4597a6fcfa93d14bf9eb7ab42 (patch)
tree5f89dbcd030da48339cb21d91f4dc29958588380 /2022
parentSolve day 7 part 1 (diff)
downloadaoc-e0f7e353eabe4bb4597a6fcfa93d14bf9eb7ab42.tar.gz
aoc-e0f7e353eabe4bb4597a6fcfa93d14bf9eb7ab42.zip
Solve day 7 part 2
Diffstat (limited to '')
-rw-r--r--2022/day07.awk9
1 files changed, 9 insertions, 0 deletions
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;
 }