commit bc03c52ea7e3331698d0639a1ebee50b38e88e2e
parent 76606032191318be848eff2c2afe48de3bdd02e2
Author: Lukas Henkel <lh@entf.net>
Date: Fri, 20 Dec 2024 19:49:48 +0100
Remove the hashtable, not needed
Diffstat:
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/day-20.lisp b/src/day-20.lisp
@@ -27,21 +27,18 @@
with pos = start
with last = nil
with steps = nil
- with position-picoseconds = (make-hash-table :test #'equal)
with task-1 = 0
with task-2 = 0
for picoseconds from 0
- do (setf (gethash pos position-picoseconds) picoseconds)
- (loop for pos-2 in steps
+ do (loop for (pos-2 . picoseconds-2) in steps
for distance = (manhattan-distance pos pos-2)
- for picoseconds-2 = (gethash pos-2 position-picoseconds)
for saved = (- picoseconds (+ picoseconds-2 distance))
do (when (>= saved 100)
(when (<= distance 2)
(incf task-1))
(when (<= distance 20)
(incf task-2))))
- (push pos steps)
+ (push (cons pos picoseconds) steps)
when (equal pos end)
do (return (values task-1 task-2))
do (psetf last pos