September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -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)
|
||||
8
Task/Spiral-matrix/Clojure/spiral-matrix-2.clj
Normal file
8
Task/Spiral-matrix/Clojure/spiral-matrix-2.clj
Normal 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))
|
||||
Loading…
Add table
Add a link
Reference in a new issue