From 9dbbe1df62fb25bd4a2d8623aceb67fbe99be5f7 Mon Sep 17 00:00:00 2001 From: Peter Tillemans Date: Sun, 8 Dec 2024 22:15:56 +0100 Subject: [PATCH] add transducers, some small refactors --- aoc.asd | 1 + src/2024/day06.lisp | 1 + src/2024/day07.lisp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/aoc.asd b/aoc.asd index f06c324..d3f580f 100644 --- a/aoc.asd +++ b/aoc.asd @@ -18,6 +18,7 @@ #:queues.simple-queue #:bt-semaphore ; threads higher level lib #:trivia ; community standard pattern matching + #:transducers ) :components ((:module "src" :components diff --git a/src/2024/day06.lisp b/src/2024/day06.lisp index b919785..30b61bc 100644 --- a/src/2024/day06.lisp +++ b/src/2024/day06.lisp @@ -115,6 +115,7 @@ (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) diff --git a/src/2024/day07.lisp b/src/2024/day07.lisp index 0a804ef..f6e06de 100644 --- a/src/2024/day07.lisp +++ b/src/2024/day07.lisp @@ -54,7 +54,7 @@ "returns simplified equation after applying the * operator or nil if not possible" (let ((r (equation-result equation)) (os (equation-operands equation))) - (and (= (gcd r (first os)) (first os)) + (and (zerop (mod r (first os))) (make-equation :result (/ r (first os)) :operands (cdr os))))) (defun plus-branch (equation)