commit bc03c52ea7e3331698d0639a1ebee50b38e88e2e from: Lukas Henkel date: Fri Dec 20 18:49:48 2024 UTC Remove the hashtable, not needed commit - 76606032191318be848eff2c2afe48de3bdd02e2 commit + bc03c52ea7e3331698d0639a1ebee50b38e88e2e blob - 7203a2a34996844e71e223b9f78152226c28dc68 blob + eee65c5dd9a1a6560f80c4e73d7c4f1d519fec7d --- src/day-20.lisp +++ 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