diff options
author | Oscar Najera <hi@oscarnajera.com> | 2023-01-11 02:43:21 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2023-01-11 02:43:21 +0100 |
commit | 5fcc997caa199bbf7e7f1ae0e8d68c1a947bd5ea (patch) | |
tree | e5f54beba0a1c85934aa311f6a609c83a3b7a8c1 /AoC2022 | |
parent | bf1e61288bc8d5723251187f14ada5a7c39a9006 (diff) | |
download | scratch-5fcc997caa199bbf7e7f1ae0e8d68c1a947bd5ea.tar.gz scratch-5fcc997caa199bbf7e7f1ae0e8d68c1a947bd5ea.tar.bz2 scratch-5fcc997caa199bbf7e7f1ae0e8d68c1a947bd5ea.zip |
some isolation of tasks
Diffstat (limited to 'AoC2022')
-rw-r--r-- | AoC2022/18/solver.lisp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/AoC2022/18/solver.lisp b/AoC2022/18/solver.lisp index 778843d..91397ec 100644 --- a/AoC2022/18/solver.lisp +++ b/AoC2022/18/solver.lisp @@ -39,17 +39,22 @@ (defconstant +neighbor-dirs+ '((1 0 0) (0 1 0) (0 0 1) (-1 0 0) (0 -1 0) (0 0 -1))) -(defun spread-steam (next outer-region cubes min-point max-point) +(defun spread-steam (next allowedp) (loop for dir in +neighbor-dirs+ for nbg = (mapcar #'+ next dir) - when (and (every #'<= min-point nbg max-point) - (not (member nbg cubes :test #'equal)) - (not (member nbg outer-region :test #'equal))) + when (funcall allowedp nbg) collect nbg)) +(defun available-p (cubes min-point max-point) + (lambda (point) + (and (every #'<= min-point point max-point) + (not (member point cubes :test #'equal))))) + (defun fill-outside (queue outer-region cubes min-point max-point) (reduce (lambda (out voxel) - (let ((next-queue (spread-steam voxel out cubes min-point max-point))) + (let ((next-queue (spread-steam voxel + (available-p + (append out cubes) min-point max-point)))) (fill-outside next-queue (append next-queue out) cubes min-point max-point))) |