aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AoC2022/18/solver.lisp10
1 files changed, 10 insertions, 0 deletions
diff --git a/AoC2022/18/solver.lisp b/AoC2022/18/solver.lisp
index 00df016..778843d 100644
--- a/AoC2022/18/solver.lisp
+++ b/AoC2022/18/solver.lisp
@@ -5,6 +5,16 @@
(mapcar (lambda (e1 e2)
(abs (- e1 e2))) a b)))
+(fiveam:test distance
+ (fiveam:for-all* ((n (fiveam:gen-integer :min 1 :max 10))
+ (a (fiveam:gen-list :length (lambda () n)))
+ (b (fiveam:gen-list :length (lambda () n)) (not (equal a b)))
+ (c (fiveam:gen-list :length (lambda () n))))
+ (fiveam:is (zerop (distance-1 a a)))
+ (fiveam:is (plusp (distance-1 a b)))
+ (fiveam:is (= (distance-1 a b) (distance-1 b a)))
+ (fiveam:is (<= (distance-1 a b) (+ (distance-1 a c) (distance-1 c b))))))
+
(defun surface (cubes)
(loop for a in cubes
sum (- 6 (loop for b in cubes