all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,8 @@
(defn spiral [n]
(let [fmt (str " ~{~<~%~," (* n 3) ":;~2d ~>~}~%")
counts (cons n (mapcat #(repeat 2 %) (range (dec n) 0 -1)))
ones-and-ns (mapcat #(repeat %1 %2) counts (cycle [1 n -1 (- n)]))]
(->> (map vector (range 0 (* n n)) (reductions + ones-and-ns))
(sort-by second)
(map first)
(clojure.pprint/cl-format true fmt))))