working on test suite
This commit is contained in:
parent
c611d65437
commit
ae69d78d64
6 changed files with 22 additions and 14 deletions
|
@ -115,7 +115,6 @@
|
||||||
|
|
||||||
(defun guard-path (labo guard &optional (path (make-hash-table :size 10000)) (extra-block nil))
|
(defun guard-path (labo guard &optional (path (make-hash-table :size 10000)) (extra-block nil))
|
||||||
(let ((hash (guard-hash guard)))
|
(let ((hash (guard-hash guard)))
|
||||||
(format t "~A~%" guard)
|
|
||||||
(cond
|
(cond
|
||||||
((not guard) (remove-duplicates (loop for k being the hash-keys of path collect (floor (/ k 10)))))
|
((not guard) (remove-duplicates (loop for k being the hash-keys of path collect (floor (/ k 10)))))
|
||||||
((gethash hash path) nil)
|
((gethash hash path) nil)
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
(defpackage :aoc/2024/08
|
(defpackage :aoc/2024/08
|
||||||
(:use :cl :aoc :alexandria :trivia :lla)
|
(:use :cl :aoc :alexandria :trivia :lla)
|
||||||
(:export
|
(:export
|
||||||
|
#:parse-line
|
||||||
|
#:parse-input
|
||||||
|
#:sample-text
|
||||||
#:sample-data
|
#:sample-data
|
||||||
#:sample-data2
|
#:sample-data2
|
||||||
#:part1
|
#:part1
|
||||||
|
@ -19,7 +22,6 @@
|
||||||
|
|
||||||
|
|
||||||
(defun parse-line (line)
|
(defun parse-line (line)
|
||||||
"return an equation with the result and the operands in reverse order as in the text"
|
|
||||||
(loop
|
(loop
|
||||||
for x from 0 to (1- (length line))
|
for x from 0 to (1- (length line))
|
||||||
for c = (aref line x)
|
for c = (aref line x)
|
||||||
|
|
|
@ -172,7 +172,7 @@ MMMISSJEEE
|
||||||
))
|
))
|
||||||
|
|
||||||
(defun part2 (data)
|
(defun part2 (data)
|
||||||
(format nil "~A" (calculate-costs (calculate-info (scan-regions data) #'si))))
|
(format nil "~A" (calculate-costs (calculate-info (scan-regions data) #'sides))))
|
||||||
|
|
||||||
(defun solve-day ()
|
(defun solve-day ()
|
||||||
(format t "part1: ~A~%" (part1 input-data))
|
(format t "part1: ~A~%" (part1 input-data))
|
||||||
|
|
|
@ -15,6 +15,6 @@
|
||||||
|
|
||||||
(define-test+run test-part2
|
(define-test+run test-part2
|
||||||
:parent suite-2024-06
|
:parent suite-2024-06
|
||||||
(true (equalp "6" (part2 sample-data2))))
|
(true (equalp "6" (part2 sample-data))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(defpackage :aoc/2024/08/tests
|
(defpackage :aoc/2024/08/tests
|
||||||
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/08))
|
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/08)
|
||||||
|
(:export :run-tests))
|
||||||
|
|
||||||
(in-package :aoc/2024/08/tests)
|
(in-package :aoc/2024/08/tests)
|
||||||
|
|
||||||
|
@ -11,20 +12,18 @@
|
||||||
|
|
||||||
(define-test+run test-part1
|
(define-test+run test-part1
|
||||||
:parent suite-2024-08
|
:parent suite-2024-08
|
||||||
(true (equalp '( '()) (part1 sample-data))))
|
(is equal "14" (part1 sample-data)))
|
||||||
|
|
||||||
(define-test+run test-part2
|
(define-test+run test-part2
|
||||||
:parent suite-2024-08
|
:parent suite-2024-08
|
||||||
(true
|
(is equalp "34" (part2 sample-data))
|
||||||
(equalp "34" (part2 sample-data)))
|
(is equalp "9" (part2 sample-data2)))
|
||||||
(true
|
|
||||||
(equalp "9" (part2 sample-data2))))
|
|
||||||
|
|
||||||
|
|
||||||
(define-test test-parse-line
|
(define-test test-parse-line
|
||||||
:parent suite-2024-08
|
:parent suite-2024-08
|
||||||
(is equalp '() (parse-line (first sample-data)))
|
(is equalp '() (parse-line (first sample-text)))
|
||||||
(is equalp '((8 #\0)) (parse-line (second sample-data)))
|
(is equalp '((8 #\0)) (parse-line (second sample-text))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
(defun run-tests ()
|
||||||
|
(test 'suite-2024-08))
|
||||||
|
|
|
@ -7,3 +7,11 @@
|
||||||
|
|
||||||
(define-test suite-2024
|
(define-test suite-2024
|
||||||
:parent 'aoc-suite)
|
:parent 'aoc-suite)
|
||||||
|
|
||||||
|
|
||||||
|
(define-test test-day08
|
||||||
|
:parent 'suite-2024
|
||||||
|
(aoc/2024/08/tests:run-tests))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue