2024-12-19 13:02:16 +01:00
|
|
|
(defpackage :aoc/2024/19/tests
|
|
|
|
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/19))
|
|
|
|
|
|
|
|
(in-package :aoc/2024/19/tests)
|
|
|
|
|
|
|
|
(define-test suite-2024-19
|
|
|
|
;:parent suite-2024
|
|
|
|
)
|
|
|
|
|
|
|
|
(define-test test-possible-patterns
|
|
|
|
:parent suite-2024-19
|
|
|
|
(reset-patterns)
|
|
|
|
(let ((tt (onsen-towels sample-data)))
|
|
|
|
(is = 0 (possible-patterns tt "z"))
|
|
|
|
(is = 1 (possible-patterns tt "r"))
|
|
|
|
(is = 2 (possible-patterns tt "rb"))
|
|
|
|
(is = 0 (possible-patterns tt "bw"))
|
|
|
|
(is = 2 (possible-patterns tt "gbb"))
|
|
|
|
|
|
|
|
;;brwrr can be made with a br towel, then a wr towel, and then finally an r towel.
|
|
|
|
(is = 2 (possible-patterns tt "brwrr"))
|
|
|
|
;;bggr can be made with a b towel, two g towels, and then an r towel.
|
|
|
|
(is = 1 (possible-patterns tt "bggr"))
|
|
|
|
;; gbbr can be made with a gb towel and then a br towel.
|
|
|
|
(is = 4 (possible-patterns tt "gbbr"))
|
|
|
|
;; rrbgbr can be made with r, rb, g, and br.
|
|
|
|
(is = 6 (possible-patterns tt "rrbgbr"))
|
|
|
|
;; ubwu is impossible.
|
|
|
|
(is = 0 (possible-patterns tt "ubwu"))
|
|
|
|
;; bwurrg can be made with bwu, r, r, and g.
|
|
|
|
(is = 1 (possible-patterns tt "bwurrg"))
|
|
|
|
;; brgr can be made with br, g, and r.
|
|
|
|
(is = 2 (possible-patterns tt "brgr"))
|
|
|
|
;; bbrgwb is impossible.
|
|
|
|
(is = 0 (possible-patterns tt "bbrgwb")))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
(define-test+run test-part1
|
2024-12-19 14:20:50 +01:00
|
|
|
:parent suite-2024-19
|
2024-12-19 14:40:19 +01:00
|
|
|
(reset-patterns)
|
2024-12-19 14:20:50 +01:00
|
|
|
(is equal "6" (part1 sample-data)))
|
2024-12-19 13:02:16 +01:00
|
|
|
|
|
|
|
(define-test+run test-part2
|
2024-12-19 14:20:50 +01:00
|
|
|
:parent suite-2024-19
|
2024-12-19 14:40:19 +01:00
|
|
|
(reset-patterns)
|
2024-12-19 14:20:50 +01:00
|
|
|
(is equal "16" (part2 sample-data)))
|
2024-12-19 13:02:16 +01:00
|
|
|
|
|
|
|
(defun run-tests ()
|
|
|
|
(test 'suite-2024-19))
|