-
-
Save amalloy/8206664 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn dijkstra | |
([a] | |
(dijkstra a (find-walls a) (find-lowest a))) | |
([a closed open-cells] | |
(loop [open open-cells] | |
(when (seq open) | |
(recur (reduce (fn [newly-open [i v]] | |
(reduce (fn [acc dir] | |
(if (or (closed dir) (open dir) | |
(>= (inc v) (hiphip/aget a n))) | |
acc | |
(do (hiphip/aset a n (inc v)) | |
(assoc acc n (inc v))))) | |
newly-open, [(- i wide) | |
(+ i wide) | |
(- i 1) | |
(+ i 1)])) | |
{}, open)))) | |
a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment