aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-01-11 01:37:18 +0100
committerOscar Najera <hi@oscarnajera.com>2023-01-11 01:37:18 +0100
commitbf1e61288bc8d5723251187f14ada5a7c39a9006 (patch)
tree9410029ab35d098bac30aa5194a87ae9a12b1eff
parentc9b54ba38fde531dd16a6ce72e587a8165edda53 (diff)
downloadscratch-bf1e61288bc8d5723251187f14ada5a7c39a9006.tar.gz
scratch-bf1e61288bc8d5723251187f14ada5a7c39a9006.tar.bz2
scratch-bf1e61288bc8d5723251187f14ada5a7c39a9006.zip
property based distance test
-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