working on test suite

This commit is contained in:
Peter Tillemans 2024-12-19 13:08:17 +01:00
parent c611d65437
commit ae69d78d64
6 changed files with 22 additions and 14 deletions

View file

@ -115,7 +115,6 @@
(defun guard-path (labo guard &optional (path (make-hash-table :size 10000)) (extra-block nil))
(let ((hash (guard-hash guard)))
(format t "~A~%" guard)
(cond
((not guard) (remove-duplicates (loop for k being the hash-keys of path collect (floor (/ k 10)))))
((gethash hash path) nil)

View file

@ -1,6 +1,9 @@
(defpackage :aoc/2024/08
(:use :cl :aoc :alexandria :trivia :lla)
(:export
#:parse-line
#:parse-input
#:sample-text
#:sample-data
#:sample-data2
#:part1
@ -19,7 +22,6 @@
(defun parse-line (line)
"return an equation with the result and the operands in reverse order as in the text"
(loop
for x from 0 to (1- (length line))
for c = (aref line x)

View file

@ -172,7 +172,7 @@ MMMISSJEEE
))
(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 ()
(format t "part1: ~A~%" (part1 input-data))

View file

@ -15,6 +15,6 @@
(define-test+run test-part2
:parent suite-2024-06
(true (equalp "6" (part2 sample-data2))))
(true (equalp "6" (part2 sample-data))))

View file

@ -1,5 +1,6 @@
(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)
@ -11,20 +12,18 @@
(define-test+run test-part1
:parent suite-2024-08
(true (equalp '( '()) (part1 sample-data))))
(is equal "14" (part1 sample-data)))
(define-test+run test-part2
:parent suite-2024-08
(true
(equalp "34" (part2 sample-data)))
(true
(equalp "9" (part2 sample-data2))))
(is equalp "34" (part2 sample-data))
(is equalp "9" (part2 sample-data2)))
(define-test test-parse-line
:parent suite-2024-08
(is equalp '() (parse-line (first sample-data)))
(is equalp '((8 #\0)) (parse-line (second sample-data)))
)
(is equalp '() (parse-line (first sample-text)))
(is equalp '((8 #\0)) (parse-line (second sample-text))))
(defun run-tests ()
(test 'suite-2024-08))

View file

@ -7,3 +7,11 @@
(define-test suite-2024
:parent 'aoc-suite)
(define-test test-day08
:parent 'suite-2024
(aoc/2024/08/tests:run-tests))