diff options
author | June McEnroe <june@causal.agency> | 2022-12-07 10:28:19 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2022-12-07 10:28:19 -0500 |
commit | e0f7e353eabe4bb4597a6fcfa93d14bf9eb7ab42 (patch) | |
tree | 5f89dbcd030da48339cb21d91f4dc29958588380 /2022 | |
parent | Solve day 7 part 1 (diff) | |
download | aoc-e0f7e353eabe4bb4597a6fcfa93d14bf9eb7ab42.tar.gz aoc-e0f7e353eabe4bb4597a6fcfa93d14bf9eb7ab42.zip |
Solve day 7 part 2
Diffstat (limited to '')
-rw-r--r-- | 2022/day07.awk | 9 |
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; } |