Last active
June 26, 2016 12:06
-
-
Save craftybones/8bad0e6f850dc9c23e0ed17f7c7ad466 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
(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