September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -3,7 +3,7 @@
(->> (range (dec n) 0 -1)
(mapcat #(repeat 2 %))
(cons n)
#(mapcat repeat % cyc)
(mapcat #(repeat %2 %) cyc)
(reductions +)
(map vector (range 0 (* n n)))
(sort-by second)

View file

@ -0,0 +1,8 @@
(defn spiral-matrix [m n & [start]]
(let [row (list (map #(+ start %) (range m)))]
(if (= 1 n) row
(concat row (map reverse
(apply map list
(spiral-matrix (dec n) m (+ start m))))))))
(defn spiral [n m] (spiral-matrix n m 1))