aoc-cl/tests/2024/day12-test.lisp

136 lines
4.2 KiB
Common Lisp
Raw Normal View History

2024-12-11 21:12:25 +01:00
(defpackage :aoc/2024/12/tests
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/12))
(in-package :aoc/2024/12/tests)
(define-test suite-2024-12
2024-12-12 09:04:24 +01:00
;
;:parent suite-2024
;)
)
2024-12-11 21:12:25 +01:00
2024-12-12 09:04:24 +01:00
(define-test test-find-same-neighbors
:parent suite-2024-12
(is equal '((1 . 0) (0 . 1)) (find-same-neighbors sample-data 0 0))
(is equal '((2 . 2) (3 . 1) (4 . 2)) (find-same-neighbors sample-data 3 2))
)
2024-12-11 21:12:25 +01:00
(define-test test-bar
2024-12-12 09:04:24 +01:00
:parent suite-2024-12)
2024-12-11 21:12:25 +01:00
2024-12-12 14:22:21 +01:00
(define-test test-top-side-p
:parent suite-2024-12
2024-12-13 06:01:50 +01:00
(false (top-side-p (make-array '(3 3) :initial-contents '((0 0 0)
(0 0 0)
(0 0 0))) 1 1))
2024-12-12 14:22:21 +01:00
(true (top-side-p (make-array '(3 3) :initial-contents '((1 0 0)
(1 1 1)
(1 1 1))) 1 1))
(false (top-side-p (make-array '(3 3) :initial-contents '((0 0 0)
(1 1 1)
(1 1 1))) 1 1))
(true (top-side-p (make-array '(3 3) :initial-contents '((0 0 0)
(0 1 1)
(1 1 1))) 1 1))
(false (top-side-p (make-array '(3 3) :initial-contents '((0 1 0)
(0 1 1)
2024-12-13 06:01:50 +01:00
(1 1 1))) 1 1))
(true (top-side-p (make-array '(3 3) :initial-contents '((0 1 0)
(1 1 1)
(1 1 1))) 1 0))
(false (top-side-p (make-array '(3 3) :initial-contents '((1 1 0)
(1 1 1)
(1 1 1))) 1 0))
)
(define-test test-bottom-side-p
:parent suite-2024-12
(false (bottom-side-p (make-array '(3 3) :initial-contents '((0 0 0)
(0 0 0)
(0 0 0))) 1 1))
(true (bottom-side-p (make-array '(3 3) :initial-contents '((1 1 1)
(1 1 1)
(1 0 0))) 1 1))
(false (bottom-side-p (make-array '(3 3) :initial-contents '((1 1 1)
(1 1 1)
(0 0 0))) 1 1))
(true (bottom-side-p (make-array '(3 3) :initial-contents '((0 0 0)
(0 1 1)
(0 0 0))) 1 1))
(false (bottom-side-p (make-array '(3 3) :initial-contents '((0 1 1)
(0 1 1)
(0 1 0))) 1 1))
(true (bottom-side-p (make-array '(3 3) :initial-contents '((0 1 0)
(1 1 1)
(0 1 0))) 1 2))
(false (bottom-side-p (make-array '(3 3) :initial-contents '((1 1 0)
(1 1 1)
(1 1 1))) 1 2))
)
(define-test test-left-side-p
:parent suite-2024-12
(false (left-side-p (make-array '(3 3) :initial-contents '((0 0 0)
(0 0 0)
(0 0 0))) 1 1))
(true (left-side-p (make-array '(3 3) :initial-contents '((1 1 1)
(0 1 1)
(0 1 1))) 1 1))
(false (left-side-p (make-array '(3 3) :initial-contents '((0 1 1)
(0 1 1)
(1 1 1))) 1 1))
(true (left-side-p (make-array '(3 3) :initial-contents '((0 0 1)
(0 1 1)
(1 1 1))) 1 1))
(false (left-side-p (make-array '(3 3) :initial-contents '((0 1 0)
(1 1 1)
(0 1 1))) 1 1)))
(define-test test-right-side-p
:parent suite-2024-12
(false (right-side-p (make-array '(3 3) :initial-contents '((0 0 0)
(0 0 0)
(0 0 0))) 1 1))
(true (right-side-p (make-array '(3 3) :initial-contents '((1 1 1)
(1 1 0)
(1 1 0))) 1 1))
(false (right-side-p (make-array '(3 3) :initial-contents '((1 1 0)
(1 1 0)
(1 1 1))) 1 1))
(true (right-side-p (make-array '(3 3) :initial-contents '((1 0 0)
(1 1 0)
(1 1 1))) 1 1))
(false (right-side-p (make-array '(3 3) :initial-contents '((0 1 0)
(1 1 1)
(1 1 0))) 1 1)))
(define-test test-sides
(is = 4 (sides (make-array '(3 3) :initial-contents '((0 0 0)
(0 1 0)
(0 0 0))) 1 1))
(is = 1 (sides (make-array '(3 3) :initial-contents '((0 1 0)
(0 1 0)
(0 0 0))) 1 1))
(is = 3 (sides (make-array '(3 3) :initial-contents '((0 0 0)
(0 1 0)
(0 1 0))) 1 1))
(is = 1 (sides (make-array '(3 3) :initial-contents '((0 0 0)
(1 1 0)
(0 0 0))) 1 1))
(is = 3 (sides (make-array '(3 3) :initial-contents '((0 0 0)
(0 1 1)
(0 0 0))) 1 1)) )
2024-12-12 14:22:21 +01:00
2024-12-11 21:12:25 +01:00
(define-test+run test-part1
2024-12-12 09:04:24 +01:00
:parent suite-2024-12
2024-12-12 13:23:19 +01:00
(is equal "1930" (part1 sample-data)))
2024-12-11 21:12:25 +01:00
(define-test+run test-part2
2024-12-12 09:04:24 +01:00
:parent suite-2024-12
2024-12-12 14:22:21 +01:00
(is equal "1206" (part2 sample-data)))