commit - ddf4527960184f991ca2d6abda4882b6c351312e
commit + 5cd36c441567ae4b5c7bd4bc399e39eea75e1206
blob - b2cf768455c8a52a6ceb50af7f6d1c4dd085205f
blob + 8463eca572917772cc0d753516a2ff486c87d515
--- src/day-18.lisp
+++ src/day-18.lisp
until (null line)
collect (parse-coordinate line)))
+(declaim (inline fall-byte unfall-byte))
+
(defun fall-byte (map position)
(setf (map-cell map position) #\#))
+(defun unfall-byte (map position)
+ (setf (map-cell map position) #\.))
+
(defun draw-map (map visited)
(loop for y from 0 below *height*
do (loop for x from 0 below *width*
(defun task-2 (map coordinates)
(loop for byte in coordinates
- do (fall-byte map byte)
- unless (bfs map)
+ do (fall-byte map byte))
+ (loop for byte in (nreverse coordinates)
+ do (unfall-byte map byte)
+ when (bfs map)
do (return byte)))
(defun day-18 (input)