From 27ee27db3cb4a0c05acc39cf5934781e262c1292 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Thu, 14 Dec 2023 09:44:51 +0100 Subject: for loop rewrite --- AoC2023/day10/solver.lisp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/AoC2023/day10/solver.lisp b/AoC2023/day10/solver.lisp index 1abe7ef..950752e 100644 --- a/AoC2023/day10/solver.lisp +++ b/AoC2023/day10/solver.lisp @@ -113,17 +113,16 @@ LJ.LJ") insidep) (correct-start map) (loop for row across map - for y from 0 do - (setf insidep nil) + for y from 0 + for insidep = nil sum (loop for col across row for x from 0 for point = (list y x) - when (and (gethash point loop-tiles) - (member col '(#\F #\| #\7))) - do (setf insidep (not insidep)) - count (and (not (gethash point loop-tiles)) - insidep))))) + if (gethash point loop-tiles) do + (when (member col '(#\F #\| #\7)) + (setf insidep (not insidep))) + else count insidep)))) (fiveam:test solution (fiveam:is (= 8 (solver1 (uiop:split-string eg-input :separator '(#\Newline))))) -- cgit v1.2.3