Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Langtons-ant/Clojure/langtons-ant.clj
Normal file
14
Task/Langtons-ant/Clojure/langtons-ant.clj
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(let [bounds (set (range 100))
|
||||
xs [1 0 -1 0] ys [0 -1 0 1]]
|
||||
(loop [dir 0 x 50 y 50
|
||||
grid {[x y] false}]
|
||||
(if (and (bounds x) (bounds y))
|
||||
(let [cur (not (grid [x y]))
|
||||
dir (mod (+ dir (if cur -1 1)) 4)]
|
||||
(recur dir (+ x (xs dir)) (+ y (ys dir))
|
||||
(merge grid {[x y] cur})))
|
||||
(doseq [col (range 100)]
|
||||
(println
|
||||
(apply str
|
||||
(map #(if (grid [% col]) \# \.)
|
||||
(range 100))))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue