commit d2acc5d04156c20564f7a69ecb395d930c192279 from: Lukas Henkel date: Mon Dec 16 07:06:16 2024 UTC Simplify direction list cycling commit - b80049b66156a9cbb8f881dc7a18b7c4a1642138 commit + d2acc5d04156c20564f7a69ecb395d930c192279 blob - 23476bde48d78b8972f836f9ccd30634a80af512 blob + a400cc67c3a5ca08ee2f743591aa96a47fa94351 --- src/day-16.lisp +++ 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)))