Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,8 +1,16 @@
(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))
(let [cyc (cycle [1 n -1 (- n)])]
(->> (range (dec n) 0 -1)
(mapcat #(repeat 2 %))
(cons n)
#(mapcat repeat % cyc)
(reductions +)
(map vector (range 0 (* n n)))
(sort-by second)
(map first)
(clojure.pprint/cl-format true fmt))))
(map first)))
(let [n 5]
(clojure.pprint/cl-format
true
(str " ~{~<~%~," (* n 3) ":;~2d ~>~}~%")
(spiral n)))