diff options
author | Oscar Najera <hi@oscarnajera.com> | 2023-12-14 09:44:51 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2023-12-14 09:44:51 +0100 |
commit | 27ee27db3cb4a0c05acc39cf5934781e262c1292 (patch) | |
tree | 9aa28307d8548714053aed95d4755205df5d03d1 /AoC2023/day10 | |
parent | ea7e004919bb64c27f3dde76af7e020d7f06b519 (diff) | |
download | scratch-27ee27db3cb4a0c05acc39cf5934781e262c1292.tar.gz scratch-27ee27db3cb4a0c05acc39cf5934781e262c1292.tar.bz2 scratch-27ee27db3cb4a0c05acc39cf5934781e262c1292.zip |
for loop rewrite
Diffstat (limited to 'AoC2023/day10')
-rw-r--r-- | AoC2023/day10/solver.lisp | 13 |
1 files 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))))) |