commit 5dc0c2a36fd627ddd9dfe52f6da0f4fbd47eb69d parent 10269e71277c7da5a7e37602b18aa31d30be9c72 Author: Lukas Henkel <lh@entf.net> Date: Wed, 7 Dec 2022 12:58:53 +0100 Day 7 task 2 Diffstat:
M | src/day07.lisp | | | 10 | +++++++++- |
M | t/day07.lisp | | | 6 | ++++++ |
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/day07.lisp b/src/day07.lisp @@ -84,7 +84,15 @@ when (<= (size dir) 100000) sum (size dir)))) +(defun task2 (inputs) + (loop with tree = (build-fs-tree inputs) + with free-space = (- 70000000 (size tree)) + with needed-space = (- 30000000 free-space) + for dir in (get-all-directories tree) + when (> (size dir) needed-space) + minimize (size dir))) + (define-day 7 () #'task1 - nil) + #'task2) diff --git a/t/day07.lisp b/t/day07.lisp @@ -29,3 +29,9 @@ $ ls (= 95437 (run-task 7 1 (make-string-input-stream +testdata-day07+))))) + +(def-test day07-task2 () + (is-true + (= 24933642 + (run-task 7 2 + (make-string-input-stream +testdata-day07+)))))