Repository: exercism/clojure
Pull request #187 (2017-09-23 01:17:59)

Implementing spiral-matrix
Well, the only concern about this that i have, is that the algorithm that i implemented is a translation of the one in here [http://rosettacode.org/wiki/Spiral_matrix#Common_Lisp](http://rosettacode.org/wiki/Spiral_matrix#Common_Lisp) that it is in Common Lisp. And i couldn't find anything about if its allowed or not , but on the other hand , is not even the same code is just a translation.


Patch:
diff --git a/config.json b/config.json
index 625c926..e7bc31c 100644
--- a/config.json
+++ b/config.json
@@ -295,6 +295,16 @@
 
       ]
     },
+    {
+      "uuid": "d42g42d7-21b1-4daf-8ddc-a2ab9ee07c98",
+      "slug": "spiral-matrix",
+      "core": false,
+      "unlocked_by": null,
+      "difficulty": 1,
+      "topics": [
+        "recursivity"
+      ]
+    },
     {
       "uuid": "068a0997-d333-48cb-a82a-c5082e85115d",
       "slug": "prime-factors",
diff --git a/exercises/collatz-conjecture/README.md b/exercises/collatz-conjecture/README.md
index 2c5a451..e6f2703 100644
--- a/exercises/collatz-conjecture/README.md
+++ b/exercises/collatz-conjecture/README.md
@@ -28,7 +28,7 @@ Resulting in 9 steps. So for input n = 12, the return value would be 9.
 ## Source
 
 An unsolved problem in mathematics named after mathematician Lothar Collatz
-see more at [collatz conjecture wikipedia](https://en.wikipedia.org/wiki/3x_%2B_1_problem)
+see more at [collatz conjecture wikipedia]("https://en.wikipedia.org/wiki/3x_%2B_1_problem")
 
 ## Submitting Incomplete Solutions
 It's possible to submit an incomplete solution so you can see how others have completed the exercise.
diff --git a/exercises/spiral-matrix/README.md b/exercises/spiral-matrix/README.md
new file mode 100644
index 0000000..7e04041
--- /dev/null
+++ b/exercises/spiral-matrix/README.md
@@ -0,0 +1,32 @@
+Given the size, return a square matrix of numbers in spiral order.
+
+The matrix should be filled with natural numbers, starting from 1
+in the top-left corner, increasing in an inward, clockwise spiral order,
+like these examples:
+
+###### Spiral matrix of size 3
+
+```plain
+1 2 3
+8 9 4
+7 6 5
+```
+
+###### Spiral matrix of size 4
+
+```plain
+ 1  2  3 4
+12 13 14 5
+11 16 15 6
+10  9  8 7
+```
+
+
+## Source
+
+Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension
+[https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/](https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/)
+
+## Submitting Incomplete Solutions
+It's possible to submit an incomplete solution so you can see how others have
+completed the exercise.
diff --git a/exercises/spiral-matrix/project.clj b/exercises/spiral-matrix/project.clj
new file mode 100644
index 0000000..5624012
--- /dev/null
+++ b/exercises/spiral-matrix/project.clj
@@ -0,0 +1,4 @@
+(defproject spiral-matrix "0.1.0-SNAPSHOT"
+  :description "spiral-matrix exercise"
+  :url "https://github.com/exercism/xclojure/tree/master/exercises/spiral-matrix"
+  :dependencies [[org.clojure/clojure "1.8.0"]])
diff --git a/exercises/spiral-matrix/src/example.clj b/exercises/spiral-matrix/src/example.clj
new file mode 100644
index 0000000..37c5db8
--- /dev/null
+++ b/exercises/spiral-matrix/src/example.clj
@@ -0,0 +1,11 @@
+(ns spiral-matrix)
+
+(defn spiral-matrix [m n & [s]]
+  (let [row (list (map #(+ s %) (range m)))]
+    (if (= 1 n) row
+      (->> (spiral-matrix (dec n) m (+ s m))
+           (apply map list)
+           (map reverse)
+           (concat row)))))
+
+(defn spiral [n] (if (zero? n) '() (spiral-matrix n n 1)))
diff --git a/exercises/spiral-matrix/src/spiral_matrix.clj b/exercises/spiral-matrix/src/spiral_matrix.clj
new file mode 100644
index 0000000..687a0c7
--- /dev/null
+++ b/exercises/spiral-matrix/src/spiral_matrix.clj
@@ -0,0 +1,3 @@
+(ns spiral-matrix)
+
+(defn spiral [n])


Test patch:
diff --git a/exercises/spiral-matrix/test/spiral_matrix_test.clj b/exercises/spiral-matrix/test/spiral_matrix_test.clj
new file mode 100644
index 0000000..ee3e604
--- /dev/null
+++ b/exercises/spiral-matrix/test/spiral_matrix_test.clj
@@ -0,0 +1,58 @@
+(ns spiral-matrix-test
+  (require [clojure.test  :refer [deftest is testing]]
+           [spiral-matrix :refer [spiral]]))
+
+(deftest spiral-matrix-of-0
+  (testing "spiral matrix of 0"
+    (is (= (spiral 0)
+           '()))))
+
+(deftest spiral-matrix-of-1
+  (testing "spiral matrix of 1"
+    (is (= (spiral 1)
+           '((1))))))
+
+(deftest spiral-matrix-of-2
+  (testing "spiral matrix of 2"
+    (is (= (spiral 2)
+           '((1 2)
+             (4 3))))))
+
+(deftest spiral-matrix-of-3
+  (testing "spiral matrix of 3"
+    (is (= (spiral 3)
+           '((1 2 3)
+             (8 9 4)
+             (7 6 5))))))
+
+(deftest spiral-matrix-of-4
+  (testing "spiral matrix of 4"
+    (is (= (spiral 4)
+           '((1  2  3  4)
+             (12 13 14 5)
+             (11 16 15 6)
+             (10 9  8  7))))))
+
+(deftest spiral-matrix-of-20
+  (testing "spiral matrix of 20"
+    (is (= (spiral 20)
+           '((1  2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20)
+             (76 77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  21)
+             (75 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 95  22)
+             (74 143 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 161 96  23)
+             (73 142 203 256 257 258 259 260 261 262 263 264 265 266 267 268 219 162 97  24)
+             (72 141 202 255 300 301 302 303 304 305 306 307 308 309 310 269 220 163 98  25)
+             (71 140 201 254 299 336 337 338 339 340 341 342 343 344 311 270 221 164 99  26)
+             (70 139 200 253 298 335 364 365 366 367 368 369 370 345 312 271 222 165 100 27)
+             (69 138 199 252 297 334 363 384 385 386 387 388 371 346 313 272 223 166 101 28)
+             (68 137 198 251 296 333 362 383 396 397 398 389 372 347 314 273 224 167 102 29)
+             (67 136 197 250 295 332 361 382 395 400 399 390 373 348 315 274 225 168 103 30)
+             (66 135 196 249 294 331 360 381 394 393 392 391 374 349 316 275 226 169 104 31)
+             (65 134 195 248 293 330 359 380 379 378 377 376 375 350 317 276 227 170 105 32)
+             (64 133 194 247 292 329 358 357 356 355 354 353 352 351 318 277 228 171 106 33)
+             (63 132 193 246 291 328 327 326 325 324 323 322 321 320 319 278 229 172 107 34)
+             (62 131 192 245 290 289 288 287 286 285 284 283 282 281 280 279 230 173 108 35)
+             (61 130 191 244 243 242 241 240 239 238 237 236 235 234 233 232 231 174 109 36)
+             (60 129 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 110 37)
+             (59 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 38)
+             (58 57  56  55  54  53  52  51  50  49  48  47  46  45  44  43  42  41  40  39))))))