62 lines
1.8 KiB
Common Lisp
62 lines
1.8 KiB
Common Lisp
(defpackage :aoc/2024/21/tests
|
|
(:use :cl :aoc :aoc/tests :aoc/maze :aoc/2024/tests :parachute :aoc/2024/21))
|
|
|
|
(in-package :aoc/2024/21/tests)
|
|
|
|
(define-test suite-2024-21
|
|
;:parent suite-2024
|
|
)
|
|
|
|
(define-test test-key-to-pos
|
|
:parent suite-2024-21
|
|
(is equalp (make-pos :x 1 :y 0) (key-to-pos #\0))
|
|
(is equalp (make-pos :x 2 :y 0) (key-to-pos #\A))
|
|
(is equalp (make-pos :x 0 :y 1) (key-to-pos #\1))
|
|
(is equalp (make-pos :x 1 :y 2) (key-to-pos #\5))
|
|
(is equalp (make-pos :x 2 :y 3) (key-to-pos #\9))
|
|
(is equalp (make-pos :x 1 :y 0) (key-to-pos #\^))
|
|
(is equalp (make-pos :x 0 :y 1) (key-to-pos #\<))
|
|
(is equalp (make-pos :x 1 :y 1) (key-to-pos #\v))
|
|
(is equalp (make-pos :x 2 :y 1) (key-to-pos #\>))
|
|
)
|
|
|
|
|
|
|
|
(define-test test-press-key
|
|
:parent suite-2024-21
|
|
(is equal "<A" (press-key #\A #\0))
|
|
(is equal "^A" (press-key #\0 #\2))
|
|
(is equal ">^^A" (press-key #\2 #\9))
|
|
(is equal "vvvA" (press-key #\9 #\A))
|
|
)
|
|
|
|
(define-test test-type-code
|
|
:parent suite-2024-21
|
|
(is equal "<A^A>^^AvvvA" (type-code "029A"))
|
|
(is equal "v<<A>>^A<A>AvA^<AA>Av<AAA>^A" (type-code (type-code "029A") nil)))
|
|
|
|
(define-test test-complexity
|
|
:parent suite-2024-21
|
|
(is = (* 68 29) (complexity "029A" 3))
|
|
(is = (* 60 980) (complexity "980A" 3))
|
|
(is = (* 68 179) (complexity "179A" 3))
|
|
(is = (* 64 456) (complexity "456A" 3))
|
|
(is = (* 64 379) (complexity "379A" 3)))
|
|
|
|
(define-test test-fewest-presses
|
|
:parent suite-2024-21
|
|
(fill-leg-table 3)
|
|
(is = 68 (fewest-presses 3 "029A"))
|
|
(is = 60 (fewest-presses 3 "980A"))
|
|
(is = 68 (fewest-presses 3 "179A"))
|
|
(is = 64 (fewest-presses 3 "456A"))
|
|
(is = 64 (fewest-presses 3 "379A")))
|
|
|
|
|
|
(define-test+run test-part1
|
|
:parent suite-2024-21
|
|
(is equal 126384 (part1 sample-data)))
|
|
|
|
|
|
;; 143919110618572
|
|
;; 167389793580400
|