commit d2acc5d04156c20564f7a69ecb395d930c192279 parent b80049b66156a9cbb8f881dc7a18b7c4a1642138 Author: Lukas Henkel <lh@entf.net> Date: Mon, 16 Dec 2024 08:06:16 +0100 Simplify direction list cycling Diffstat:
M | src/day-16.lisp | | | 14 | ++++++-------- |
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/day-16.lisp b/src/day-16.lisp @@ -3,10 +3,10 @@ (:export #:day-16)) (in-package #:aoc/day-16) -(defparameter *directions-clockwise* '((1 . 0) (0 . 1) - (-1 . 0) (0 . -1))) -(defparameter *directions-counterclockwise* '((1 . 0) (0 . -1) - (-1 . 0) (0 . 1))) +(defparameter *directions-clockwise* '(#1=(1 . 0) (0 . 1) + (-1 . 0) (0 . -1) #1#)) +(defparameter *directions-counterclockwise* '(#2=(1 . 0) (0 . -1) + (-1 . 0) (0 . 1) #2#)) (defstruct node position @@ -61,13 +61,11 @@ when (char/= (map-cell map next) #\#) do (process-next open-list closed-list next current-dir (1+ current-cost) current) do (process-next open-list closed-list current-pos - (or (cadr (member current-dir *directions-clockwise* :test #'equal)) - (first *directions-clockwise*)) + (cadr (member current-dir *directions-clockwise* :test #'equal)) (+ current-cost 1000) current) (process-next open-list closed-list current-pos - (or (cadr (member current-dir *directions-counterclockwise* :test #'equal)) - (first *directions-counterclockwise*)) + (cadr (member current-dir *directions-counterclockwise* :test #'equal)) (+ current-cost 1000) current)))