use cond over nested else if

This commit is contained in:
Adam Jeniski 2024-12-06 09:36:24 -05:00
parent d40e6cfcd8
commit bc60e6246b

View File

@ -35,16 +35,15 @@
(loop [pos start
dir :up
path #{}]
(if (not (in-bounds? pos))
path
(if (path [dir pos])
:cycle
(let [pos' (move dir pos)]
(cond
(not (in-bounds? pos)) path
(path [dir pos]) :cycle
:else (let [pos' (move dir pos)]
(if (= (get-char pos') \#)
(recur pos (turn-right dir) (conj path [dir pos]))
(recur pos'
dir
(conj path [dir pos]))))))))
(conj path [dir pos])))))))
(defn add-obstacle [[row col]]
(update input row assoc col \#))