135 lines
4.2 KiB
Common Lisp
135 lines
4.2 KiB
Common Lisp
(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
|
|
;
|
|
;:parent suite-2024
|
|
;)
|
|
)
|
|
|
|
(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))
|
|
)
|
|
|
|
|
|
(define-test test-bar
|
|
:parent suite-2024-12)
|
|
|
|
|
|
(define-test test-top-side-p
|
|
:parent suite-2024-12
|
|
(false (top-side-p (make-array '(3 3) :initial-contents '((0 0 0)
|
|
(0 0 0)
|
|
(0 0 0))) 1 1))
|
|
(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)
|
|
(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)) )
|
|
|
|
(define-test+run test-part1
|
|
:parent suite-2024-12
|
|
(is equal "1930" (part1 sample-data)))
|
|
|
|
(define-test+run test-part2
|
|
:parent suite-2024-12
|
|
(is equal "1206" (part2 sample-data)))
|