From bf1e61288bc8d5723251187f14ada5a7c39a9006 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Wed, 11 Jan 2023 01:37:18 +0100 Subject: property based distance test --- AoC2022/18/solver.lisp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- cgit v1.2.3