Skip to content

Instantly share code, notes, and snippets.

@craftybones
Last active June 26, 2016 12:06
Show Gist options
  • Save craftybones/8bad0e6f850dc9c23e0ed17f7c7ad466 to your computer and use it in GitHub Desktop.
Save craftybones/8bad0e6f850dc9c23e0ed17f7c7ad466 to your computer and use it in GitHub Desktop.
(ns Player
(:gen-class))
(def xDirs {1 "E" 0 "" -1 "W"})
(def yDirs {1 "S" 0 "" -1 "N"})
(def offsets {1 inc 0 identity -1 dec})
(defn -main [& args]
(let [[lightX lightY initialTX initialTY] (repeatedly 4 read)
tX (atom initialTX)
tY (atom initialTY)]
(while true
(let [remainingTurns (read)
[yIndex xIndex] (map compare [lightY lightX] [@tY @tX])
dir (str (yDirs yIndex) (xDirs xIndex))]
(swap! tX (offsets xIndex))
(swap! tY (offsets yIndex))
(println dir)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment