trackler 2.2.1.100 → 2.2.1.101

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/kindergarten-garden/canonical-data.json +37 -19
  4. data/problem-specifications/exercises/ocr-numbers/canonical-data.json +144 -110
  5. data/problem-specifications/exercises/palindrome-products/canonical-data.json +49 -25
  6. data/problem-specifications/exercises/poker/canonical-data.json +171 -115
  7. data/problem-specifications/exercises/prime-factors/canonical-data.json +22 -8
  8. data/problem-specifications/exercises/protein-translation/canonical-data.json +70 -24
  9. data/problem-specifications/exercises/proverb/canonical-data.json +24 -12
  10. data/problem-specifications/exercises/queen-attack/canonical-data.json +115 -91
  11. data/problem-specifications/exercises/rail-fence-cipher/canonical-data.json +25 -13
  12. data/problem-specifications/exercises/raindrops/canonical-data.json +55 -19
  13. data/problem-specifications/exercises/rational-numbers/canonical-data.json +374 -0
  14. data/problem-specifications/exercises/rational-numbers/description.md +27 -0
  15. data/problem-specifications/exercises/rational-numbers/metadata.yml +4 -0
  16. data/problem-specifications/exercises/rectangles/canonical-data.json +93 -67
  17. data/problem-specifications/exercises/reverse-string/canonical-data.json +16 -6
  18. data/problem-specifications/exercises/rna-transcription/metadata.yml +3 -3
  19. data/problem-specifications/exercises/roman-numerals/canonical-data.json +10 -2
  20. data/tracks/bash/config.json +11 -11
  21. data/tracks/c/exercises/roman-numerals/test/test_roman_numerals.c +7 -0
  22. data/tracks/clojure/exercises/armstrong-numbers/README.md +1 -1
  23. data/tracks/delphi/config.json +11 -0
  24. data/tracks/delphi/exercises/clock/uClockExample.pas +6 -1
  25. data/tracks/delphi/exercises/clock/uClockTest.pas +22 -19
  26. data/tracks/delphi/exercises/isbn-verifier/README.md +1 -1
  27. data/tracks/delphi/exercises/reverse-string/README.md +1 -1
  28. data/tracks/delphi/exercises/rna-transcription/README.md +1 -1
  29. data/tracks/delphi/exercises/roman-numerals/uRomanNumeralsTest.pas +14 -0
  30. data/tracks/delphi/exercises/space-age/README.md +45 -0
  31. data/tracks/delphi/exercises/space-age/SpaceAge.dpr +60 -0
  32. data/tracks/delphi/exercises/space-age/uSpaceAgeExample.pas +120 -0
  33. data/tracks/delphi/exercises/space-age/uSpaceAgeTests.pas +135 -0
  34. data/tracks/delphi/exercises/two-fer/README.md +1 -1
  35. data/tracks/elixir/exercises/nth-prime/nth_prime.exs +0 -1
  36. data/tracks/fsharp/exercises/pov/PovTest.fs +66 -53
  37. data/tracks/fsharp/exercises/space-age/Example.fs +11 -11
  38. data/tracks/fsharp/exercises/space-age/SpaceAge.fs +1 -1
  39. data/tracks/fsharp/exercises/space-age/SpaceAgeTest.fs +21 -34
  40. data/tracks/fsharp/exercises/triangle/Example.fs +11 -16
  41. data/tracks/fsharp/exercises/triangle/Triangle.fs +4 -5
  42. data/tracks/fsharp/exercises/triangle/TriangleTest.fs +44 -31
  43. data/tracks/fsharp/generators/Generators.fs +121 -0
  44. data/tracks/go/config.json +12 -0
  45. data/tracks/go/exercises/clock/.meta/gen.go +37 -13
  46. data/tracks/go/exercises/clock/cases_test.go +10 -10
  47. data/tracks/go/exercises/clock/clock_test.go +16 -2
  48. data/tracks/go/exercises/clock/example.go +4 -0
  49. data/tracks/go/exercises/clock/example_clock_test.go +3 -3
  50. data/tracks/go/exercises/parallel-letter-frequency/.meta/hints.md +33 -0
  51. data/tracks/go/exercises/parallel-letter-frequency/README.md +35 -0
  52. data/tracks/go/exercises/raindrops/.meta/hints.md +7 -4
  53. data/tracks/go/exercises/raindrops/README.md +12 -0
  54. data/tracks/go/exercises/roman-numerals/.meta/gen.go +4 -2
  55. data/tracks/go/exercises/roman-numerals/cases_test.go +3 -2
  56. data/tracks/go/exercises/space-age/.meta/hints.md +10 -0
  57. data/tracks/go/exercises/space-age/README.md +14 -1
  58. data/tracks/go/exercises/twelve-days/README.md +2 -5
  59. data/tracks/go/exercises/two-bucket/.meta/gen.go +62 -0
  60. data/tracks/go/exercises/two-bucket/.meta/hints.md +16 -0
  61. data/tracks/go/exercises/two-bucket/README.md +72 -0
  62. data/tracks/go/exercises/two-bucket/cases_test.go +44 -0
  63. data/tracks/go/exercises/two-bucket/example.go +198 -0
  64. data/tracks/go/exercises/two-bucket/two_bucket_test.go +61 -0
  65. data/tracks/idris/.travis.yml +3 -2
  66. data/tracks/idris/bin/fetch-idris-testing.sh +11 -0
  67. data/tracks/idris/bin/solve_exercises.sh +2 -2
  68. data/tracks/idris/config.json +11 -0
  69. data/tracks/idris/config/exercise_readme.go.tmpl +0 -3
  70. data/tracks/idris/docs/INSTALLATION.md +22 -0
  71. data/tracks/idris/docs/TESTS.md +12 -4
  72. data/tracks/idris/exercises/accumulate/src/Accumulate.idr +5 -0
  73. data/tracks/idris/exercises/hamming/Hamming.ipkg +2 -0
  74. data/tracks/idris/exercises/hamming/src/{example.idr → Example.idr} +5 -1
  75. data/tracks/idris/exercises/hamming/src/Hamming.idr +13 -5
  76. data/tracks/idris/exercises/hamming/src/Test/Hamming.idr +31 -58
  77. data/tracks/idris/exercises/hello-world/HelloWorld.ipkg +2 -0
  78. data/tracks/idris/exercises/hello-world/src/Example.idr +9 -0
  79. data/tracks/idris/exercises/hello-world/src/HelloWorld.idr +6 -1
  80. data/tracks/idris/exercises/hello-world/src/Test/HelloWorld.idr +18 -18
  81. data/tracks/idris/exercises/leap/Leap.ipkg +2 -0
  82. data/tracks/idris/exercises/leap/src/{example.idr → Example.idr} +4 -0
  83. data/tracks/idris/exercises/leap/src/Leap.idr +5 -1
  84. data/tracks/idris/exercises/leap/src/Test/Leap.idr +21 -30
  85. data/tracks/idris/exercises/rna-transcription/Makefile +23 -0
  86. data/tracks/idris/exercises/rna-transcription/README.md +27 -0
  87. data/tracks/idris/exercises/rna-transcription/RnaTranscription.ipkg +5 -0
  88. data/tracks/idris/exercises/rna-transcription/src/RnaTranscription.idr +17 -0
  89. data/tracks/idris/exercises/rna-transcription/src/Test/RnaTranscription.idr +27 -0
  90. data/tracks/idris/exercises/rna-transcription/src/example.idr +35 -0
  91. data/tracks/java/exercises/etl/.meta/version +1 -0
  92. data/tracks/java/exercises/gigasecond/.meta/version +1 -0
  93. data/tracks/java/exercises/isbn-verifier/README.md +1 -1
  94. data/tracks/java/exercises/nucleotide-count/.meta/src/reference/java/NucleotideCounter.java +7 -1
  95. data/tracks/java/exercises/nucleotide-count/.meta/version +1 -0
  96. data/tracks/java/exercises/nucleotide-count/src/test/java/NucleotideCounterTest.java +19 -54
  97. data/tracks/java/exercises/proverb/.meta/version +1 -0
  98. data/tracks/java/exercises/reverse-string/README.md +1 -1
  99. data/tracks/java/exercises/rna-transcription/README.md +1 -1
  100. data/tracks/java/exercises/sum-of-multiples/.meta/version +1 -0
  101. data/tracks/java/exercises/sum-of-multiples/src/test/java/SumOfMultiplesTest.java +13 -1
  102. data/tracks/kotlin/config/exercise_readme.go.tmpl +0 -3
  103. data/tracks/kotlin/docs/TESTS.md +1 -1
  104. data/tracks/objective-c/config.json +11 -0
  105. data/tracks/objective-c/exercises/collatz-conjecture/CollatzConjectureExample.h +7 -0
  106. data/tracks/objective-c/exercises/collatz-conjecture/CollatzConjectureExample.m +26 -0
  107. data/tracks/objective-c/exercises/collatz-conjecture/CollatzConjectureTest.m +39 -0
  108. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +31 -1
  109. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/xcshareddata/xcschemes/OCLint.xcscheme +3 -1
  110. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/xcshareddata/xcschemes/xobjectivecTest.xcscheme +3 -1
  111. data/tracks/ocaml/exercises/forth/example.ml +9 -9
  112. data/tracks/ocaml/tools/test-generator/Makefile +3 -9
  113. data/tracks/ocaml/tools/test-generator/src/test_gen.ml +18 -16
  114. data/tracks/perl6/exercises/acronym/.meta/exercise-data.yaml +1 -1
  115. data/tracks/perl6/exercises/acronym/acronym.t +4 -14
  116. data/tracks/perl6/exercises/all-your-base/all-your-base.t +0 -2
  117. data/tracks/perl6/exercises/allergies/allergies.t +0 -2
  118. data/tracks/perl6/exercises/anagram/.meta/exercise-data.yaml +1 -1
  119. data/tracks/perl6/exercises/anagram/anagram.t +2 -40
  120. data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +0 -1
  121. data/tracks/perl6/exercises/bob/bob.t +0 -2
  122. data/tracks/perl6/exercises/clock/.meta/exercise-data.yaml +15 -11
  123. data/tracks/perl6/exercises/clock/.meta/solutions/Clock.pm6 +5 -1
  124. data/tracks/perl6/exercises/clock/Clock.pm6 +1 -1
  125. data/tracks/perl6/exercises/clock/clock.t +314 -217
  126. data/tracks/perl6/exercises/etl/etl.t +0 -2
  127. data/tracks/perl6/exercises/flatten-array/flatten-array.t +0 -2
  128. data/tracks/perl6/exercises/grains/grains.t +0 -2
  129. data/tracks/perl6/exercises/hamming/.meta/exercise-data.yaml +2 -2
  130. data/tracks/perl6/exercises/hamming/hamming.t +63 -35
  131. data/tracks/perl6/exercises/hello-world/hello-world.t +2 -3
  132. data/tracks/perl6/exercises/leap/.meta/exercise-data.yaml +1 -1
  133. data/tracks/perl6/exercises/leap/leap.t +14 -8
  134. data/tracks/perl6/exercises/luhn/luhn.t +0 -2
  135. data/tracks/perl6/exercises/nucleotide-count/.meta/exercise-data.yaml +2 -2
  136. data/tracks/perl6/exercises/nucleotide-count/nucleotide-count.t +18 -10
  137. data/tracks/perl6/exercises/pangram/.meta/exercise-data.yaml +1 -1
  138. data/tracks/perl6/exercises/pangram/pangram.t +32 -14
  139. data/tracks/perl6/exercises/phone-number/.meta/exercise-data.yaml +4 -4
  140. data/tracks/perl6/exercises/phone-number/.meta/solutions/Phone.pm6 +1 -1
  141. data/tracks/perl6/exercises/phone-number/Phone.pm6 +1 -1
  142. data/tracks/perl6/exercises/phone-number/phone-number.t +59 -21
  143. data/tracks/perl6/exercises/raindrops/raindrops.t +0 -2
  144. data/tracks/perl6/exercises/rna-transcription/.meta/exercise-data.yaml +1 -1
  145. data/tracks/perl6/exercises/rna-transcription/README.md +1 -1
  146. data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +17 -9
  147. data/tracks/perl6/exercises/roman-numerals/.meta/exercise-data.yaml +3 -3
  148. data/tracks/perl6/exercises/roman-numerals/.meta/solutions/RomanNumerals.pm6 +1 -1
  149. data/tracks/perl6/exercises/roman-numerals/RomanNumerals.pm6 +1 -1
  150. data/tracks/perl6/exercises/roman-numerals/roman-numerals.t +66 -24
  151. data/tracks/perl6/exercises/scrabble-score/.meta/exercise-data.yaml +1 -1
  152. data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +35 -15
  153. data/tracks/perl6/exercises/space-age/.meta/exercise-data.yaml +1 -1
  154. data/tracks/perl6/exercises/space-age/space-age.t +34 -20
  155. data/tracks/perl6/exercises/two-fer/.meta/exercise-data.yaml +2 -2
  156. data/tracks/perl6/exercises/two-fer/two-fer.t +15 -11
  157. data/tracks/perl6/exercises/word-count/.meta/exercise-data.yaml +1 -1
  158. data/tracks/perl6/exercises/word-count/word-count.t +46 -26
  159. data/tracks/perl6/exercises/wordy/.meta/exercise-data.yaml +2 -2
  160. data/tracks/perl6/exercises/wordy/wordy.t +51 -21
  161. data/tracks/perl6/lib/Exercism/Generator.pm6 +1 -1
  162. data/tracks/perl6/t/generated-tests.t +1 -1
  163. data/tracks/perl6/templates/test.mustache +0 -1
  164. data/tracks/python/config.json +12 -0
  165. data/tracks/python/exercises/forth/example.py +1 -1
  166. data/tracks/python/exercises/forth/forth_test.py +43 -38
  167. data/tracks/python/exercises/spiral-matrix/README.md +42 -0
  168. data/tracks/python/exercises/spiral-matrix/example.py +11 -0
  169. data/tracks/python/exercises/spiral-matrix/spiral_matrix.py +2 -0
  170. data/tracks/python/exercises/spiral-matrix/spiral_matrix_test.py +40 -0
  171. data/tracks/racket/config/exercise_readme.go.tmpl +24 -4
  172. data/tracks/racket/exercises/accumulate/README.md +3 -6
  173. data/tracks/racket/exercises/acronym/README.md +3 -4
  174. data/tracks/racket/exercises/allergies/README.md +3 -4
  175. data/tracks/racket/exercises/anagram/README.md +3 -3
  176. data/tracks/racket/exercises/bob/README.md +5 -3
  177. data/tracks/racket/exercises/collatz-conjecture/README.md +3 -3
  178. data/tracks/racket/exercises/difference-of-squares/README.md +3 -3
  179. data/tracks/racket/exercises/etl/README.md +6 -4
  180. data/tracks/racket/exercises/gigasecond/README.md +3 -3
  181. data/tracks/racket/exercises/grains/README.md +3 -4
  182. data/tracks/racket/exercises/grep/README.md +15 -15
  183. data/tracks/racket/exercises/hamming/README.md +3 -3
  184. data/tracks/racket/exercises/hello-world/README.md +1 -1
  185. data/tracks/racket/exercises/leap/README.md +4 -4
  186. data/tracks/racket/exercises/list-ops/README.md +3 -4
  187. data/tracks/racket/exercises/meetup/README.md +19 -15
  188. data/tracks/racket/exercises/nucleotide-count/README.md +11 -25
  189. data/tracks/racket/exercises/perfect-numbers/README.md +5 -5
  190. data/tracks/racket/exercises/phone-number/README.md +7 -6
  191. data/tracks/racket/exercises/raindrops/README.md +3 -3
  192. data/tracks/racket/exercises/rna-transcription/README.md +4 -4
  193. data/tracks/racket/exercises/roman-numerals/README.md +4 -4
  194. data/tracks/racket/exercises/say/README.md +3 -3
  195. data/tracks/racket/exercises/scrabble-score/README.md +6 -4
  196. data/tracks/racket/exercises/word-count/README.md +4 -5
  197. data/tracks/scheme/config/exercise_readme.go.tmpl +0 -3
  198. data/tracks/scheme/docs/INSTALLATION.md +23 -14
  199. metadata +40 -9
  200. data/tracks/idris/docs/EXERCISE_README_INSERT.md +0 -0
  201. data/tracks/idris/exercises/hello-world/src/example.idr +0 -5
  202. data/tracks/kotlin/config/exercise-readme-insert.md +0 -1
  203. data/tracks/racket/docs/EXERCISE_README_INSERT.md +0 -23
  204. data/tracks/scheme/docs/EXERCISE_README_INSERT.md +0 -0
@@ -1280,6 +1280,18 @@
1280
1280
  "sets"
1281
1281
  ]
1282
1282
  },
1283
+ {
1284
+ "uuid": "b0c7cf95-6470-4c1a-8eaa-6775310926a2",
1285
+ "slug": "spiral-matrix",
1286
+ "core": false,
1287
+ "unlocked_by": null,
1288
+ "difficulty": 2,
1289
+ "topics": [
1290
+ "algorithms",
1291
+ "control-flow",
1292
+ "lists"
1293
+ ]
1294
+ },
1283
1295
  {
1284
1296
  "uuid": "e7351e8e-d3ff-4621-b818-cd55cf05bffd",
1285
1297
  "slug": "accumulate",
@@ -18,7 +18,7 @@ def evaluate(input_data):
18
18
  values = input_data.pop(0).split()
19
19
  values.pop()
20
20
  values.pop(0)
21
- key = values.pop(0)
21
+ key = values.pop(0).lower()
22
22
  if is_integer(key):
23
23
  raise ValueError("Integers cannot be redefined")
24
24
  defines[key] = values
@@ -3,20 +3,10 @@ import unittest
3
3
  from forth import evaluate, StackUnderflowError
4
4
 
5
5
 
6
- # Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
6
+ # Tests adapted from `problem-specifications//canonical-data.json` @ v1.4.0
7
7
  # Tests for case-insensitivity are track-specific
8
8
 
9
9
  class ForthParsingTest(unittest.TestCase):
10
- def test_empty_input_empty_stack(self):
11
- input_data = []
12
- expected = []
13
- self.assertEqual(evaluate(input_data), expected)
14
-
15
- def test_empty_line_empty_stack(self):
16
- input_data = [""]
17
- expected = []
18
- self.assertEqual(evaluate(input_data), expected)
19
-
20
10
  def test_numbers_just_get_pushed_to_stack(self):
21
11
  input_data = ["1 2 3 4 5"]
22
12
  expected = [1, 2, 3, 4, 5]
@@ -154,13 +144,13 @@ class ForthCombinedArithmeticTest(unittest.TestCase):
154
144
 
155
145
 
156
146
  class ForthDupTest(unittest.TestCase):
157
- def test_copies_the_top_value_on_the_stack(self):
158
- input_data = ["1 DUP"]
147
+ def test_copies_a_value_on_the_stack(self):
148
+ input_data = ["1 dup"]
159
149
  expected = [1, 1]
160
150
  self.assertEqual(evaluate(input_data), expected)
161
151
 
162
- def test_is_case_insensitive(self):
163
- input_data = ["1 2 Dup"]
152
+ def test_copies_the_top_value_on_the_stack(self):
153
+ input_data = ["1 2 dup"]
164
154
  expected = [1, 2, 2]
165
155
  self.assertEqual(evaluate(input_data), expected)
166
156
 
@@ -191,11 +181,6 @@ class ForthDropTest(unittest.TestCase):
191
181
  expected = [3]
192
182
  self.assertEqual(evaluate(input_data), expected)
193
183
 
194
- def test_is_case_insensitive(self):
195
- input_data = ["1 2 Drop"]
196
- expected = [1]
197
- self.assertEqual(evaluate(input_data), expected)
198
-
199
184
  def test_errors_if_there_is_nothing_on_the_stack(self):
200
185
  input_data = ["drop"]
201
186
  with self.assertRaisesWithMessage(StackUnderflowError):
@@ -223,11 +208,6 @@ class ForthSwapTest(unittest.TestCase):
223
208
  expected = [1, 3, 2]
224
209
  self.assertEqual(evaluate(input_data), expected)
225
210
 
226
- def test_is_case_insensitive(self):
227
- input_data = ["3 4 Swap"]
228
- expected = [4, 3]
229
- self.assertEqual(evaluate(input_data), expected)
230
-
231
211
  def test_errors_if_there_is_nothing_on_the_stack(self):
232
212
  input_data = ["swap"]
233
213
  with self.assertRaisesWithMessage(StackUnderflowError):
@@ -260,11 +240,6 @@ class ForthOverTest(unittest.TestCase):
260
240
  expected = [1, 2, 3, 2]
261
241
  self.assertEqual(evaluate(input_data), expected)
262
242
 
263
- def test_is_case_insensitive(self):
264
- input_data = ["3 4 Over"]
265
- expected = [3, 4, 3]
266
- self.assertEqual(evaluate(input_data), expected)
267
-
268
243
  def test_errors_if_there_is_nothing_on_the_stack(self):
269
244
  input_data = ["over"]
270
245
  with self.assertRaisesWithMessage(StackUnderflowError):
@@ -328,14 +303,6 @@ class ForthUserDefinedWordsTest(unittest.TestCase):
328
303
  expected = [12]
329
304
  self.assertEqual(evaluate(input_data), expected)
330
305
 
331
- def test_is_case_insensitive(self):
332
- input_data = [
333
- ": foo dup ;",
334
- "1 FOO"
335
- ]
336
- expected = [1, 1]
337
- self.assertEqual(evaluate(input_data), expected)
338
-
339
306
  def test_cannot_redefine_numbers(self):
340
307
  input_data = [": 1 2 ;"]
341
308
  with self.assertRaisesWithMessage(ValueError):
@@ -357,5 +324,43 @@ class ForthUserDefinedWordsTest(unittest.TestCase):
357
324
  return self.assertRaisesRegex(exception, r".+")
358
325
 
359
326
 
327
+ class ForthCaseInsensitivityTest(unittest.TestCase):
328
+ def test_dup_is_case_insensitive(self):
329
+ input_data = ["1 DUP Dup dup"]
330
+ expected = [1, 1, 1, 1]
331
+ self.assertEqual(evaluate(input_data), expected)
332
+
333
+ def test_drop_is_case_insensitive(self):
334
+ input_data = ["1 2 3 4 DROP Drop drop"]
335
+ expected = [1]
336
+ self.assertEqual(evaluate(input_data), expected)
337
+
338
+ def test_swap_is_case_insensitive(self):
339
+ input_data = ["1 2 SWAP 3 Swap 4 swap"]
340
+ expected = [2, 3, 4, 1]
341
+ self.assertEqual(evaluate(input_data), expected)
342
+
343
+ def test_over_is_case_insensitive(self):
344
+ input_data = ["1 2 OVER Over over"]
345
+ expected = [1, 2, 1, 2, 1]
346
+ self.assertEqual(evaluate(input_data), expected)
347
+
348
+ def test_user_defined_words_are_case_insensitive(self):
349
+ input_data = [
350
+ ": foo dup ;",
351
+ "1 FOO Foo foo"
352
+ ]
353
+ expected = [1, 1, 1, 1]
354
+ self.assertEqual(evaluate(input_data), expected)
355
+
356
+ def test_definitions_are_case_insensitive(self):
357
+ input_data = [
358
+ ": SWAP DUP Dup dup ;",
359
+ "1 swap"
360
+ ]
361
+ expected = [1, 1, 1, 1]
362
+ self.assertEqual(evaluate(input_data), expected)
363
+
364
+
360
365
  if __name__ == '__main__':
361
366
  unittest.main()
@@ -0,0 +1,42 @@
1
+ # Spiral Matrix
2
+
3
+
4
+ Given the size, return a square matrix of numbers in spiral order.
5
+
6
+ The matrix should be filled with natural numbers, starting from 1
7
+ in the top-left corner, increasing in an inward, clockwise spiral order,
8
+ like these examples:
9
+
10
+ ##### Spiral matrix of size 3
11
+
12
+ ```plain
13
+ 1 2 3
14
+ 8 9 4
15
+ 7 6 5
16
+ ```
17
+
18
+ ##### Spiral matrix of size 4
19
+
20
+ ```plain
21
+ 1 2 3 4
22
+ 12 13 14 5
23
+ 11 16 15 6
24
+ 10 9 8 7
25
+ ```
26
+
27
+ ## Submitting Exercises
28
+
29
+ Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
30
+
31
+ For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
32
+
33
+ For more detailed information about running tests, code style and linting,
34
+ please see the [help page](http://exercism.io/languages/python).
35
+
36
+ ## Source
37
+
38
+ 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/)
39
+
40
+ ## Submitting Incomplete Solutions
41
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
42
+
@@ -0,0 +1,11 @@
1
+ def spiral(size):
2
+ sm = [[0]*size for k in range(size)]
3
+ i, j, el = 0, -1, 1
4
+ di, dj = [0, 1, 0, -1], [1, 0, -1, 0]
5
+ for x in range(2*size - 1):
6
+ for y in range((2*size - x) // 2):
7
+ i += di[x % 4]
8
+ j += dj[x % 4]
9
+ sm[i][j] = el
10
+ el += 1
11
+ return sm
@@ -0,0 +1,2 @@
1
+ def spiral(size):
2
+ pass
@@ -0,0 +1,40 @@
1
+ import unittest
2
+
3
+ from spiral_matrix import spiral
4
+
5
+
6
+ # Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
7
+
8
+
9
+ class SpiralMatrixTest(unittest.TestCase):
10
+ def test_spiral_matrix_with_size_0(self):
11
+ self.assertEqual(spiral(0), [])
12
+
13
+ def test_spiral_matrix_with_size_1(self):
14
+ self.assertEqual(spiral(1), [[1]])
15
+
16
+ def test_spiral_matrix_with_size_2(self):
17
+ self.assertEqual(spiral(2), [[1, 2],
18
+ [4, 3]])
19
+
20
+ def test_spiral_matrix_with_size_3(self):
21
+ self.assertEqual(spiral(3), [[1, 2, 3],
22
+ [8, 9, 4],
23
+ [7, 6, 5]])
24
+
25
+ def test_spiral_matrix_with_size_4(self):
26
+ self.assertEqual(spiral(4), [[1, 2, 3, 4],
27
+ [12, 13, 14, 5],
28
+ [11, 16, 15, 6],
29
+ [10, 9, 8, 7]])
30
+
31
+ def test_spiral_matrix_with_size_5(self):
32
+ self.assertEqual(spiral(5), [[1, 2, 3, 4, 5],
33
+ [16, 17, 18, 19, 6],
34
+ [15, 24, 25, 20, 7],
35
+ [14, 23, 22, 21, 8],
36
+ [13, 12, 11, 10, 9]])
37
+
38
+
39
+ if __name__ == '__main__':
40
+ unittest.main()
@@ -4,10 +4,30 @@
4
4
  {{- with .Hints }}
5
5
  {{ . }}
6
6
  {{ end }}
7
- {{- with .TrackInsert }}
8
- {{ . }}
9
- {{ end }}
10
- {{- with .Spec.Credits -}}
7
+ * * * *
8
+
9
+ For installation and learning resources, refer to the
10
+ [exercism Racket page](http://exercism.io/languages/racket).
11
+
12
+ You can run the provided tests through DrRacket, or via the command line.
13
+
14
+ To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.
15
+
16
+ To run the test from the command line, run the test from the exercise directory with the following command:
17
+
18
+ ```
19
+ raco test {{ .Spec.Slug }}-test.rkt
20
+ ```
21
+
22
+ which will display the following:
23
+
24
+ ```
25
+ raco test: (submod "{{ .Spec.Slug }}-test.rkt" test)
26
+ 2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
27
+ 0
28
+ 2 tests passed
29
+ ```
30
+ {{ with .Spec.Credits }}
11
31
  ## Source
12
32
 
13
33
  {{ . }}
@@ -25,9 +25,6 @@ Keep your hands off that collect/map/fmap/whatchamacallit functionality
25
25
  provided by your standard library!
26
26
  Solve this one yourself using other basic tools instead.
27
27
 
28
- Lisp specific: it's perfectly fine to use `MAPCAR` or the equivalent,
29
- as this is idiomatic Lisp, not a library function.
30
-
31
28
  * * * *
32
29
 
33
30
  For installation and learning resources, refer to the
@@ -37,16 +34,16 @@ You can run the provided tests through DrRacket, or via the command line.
37
34
 
38
35
  To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.
39
36
 
40
- To run the test from the command line, simply run the test from the exercise directory. For example, if the test suite is called `hello-world-test.rkt`, you can run the following command:
37
+ To run the test from the command line, run the test from the exercise directory with the following command:
41
38
 
42
39
  ```
43
- raco test hello-world-test.rkt
40
+ raco test accumulate-test.rkt
44
41
  ```
45
42
 
46
43
  which will display the following:
47
44
 
48
45
  ```
49
- raco test: (submod "hello-world-test.rkt" test)
46
+ raco test: (submod "accumulate-test.rkt" test)
50
47
  2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
51
48
  0
52
49
  2 tests passed
@@ -7,7 +7,6 @@ Techies love their TLA (Three Letter Acronyms)!
7
7
  Help generate some jargon by writing a program that converts a long name
8
8
  like Portable Network Graphics to its acronym (PNG).
9
9
 
10
-
11
10
  * * * *
12
11
 
13
12
  For installation and learning resources, refer to the
@@ -17,16 +16,16 @@ You can run the provided tests through DrRacket, or via the command line.
17
16
 
18
17
  To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.
19
18
 
20
- To run the test from the command line, simply run the test from the exercise directory. For example, if the test suite is called `hello-world-test.rkt`, you can run the following command:
19
+ To run the test from the command line, run the test from the exercise directory with the following command:
21
20
 
22
21
  ```
23
- raco test hello-world-test.rkt
22
+ raco test acronym-test.rkt
24
23
  ```
25
24
 
26
25
  which will display the following:
27
26
 
28
27
  ```
29
- raco test: (submod "hello-world-test.rkt" test)
28
+ raco test: (submod "acronym-test.rkt" test)
30
29
  2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
31
30
  0
32
31
  2 tests passed
@@ -29,7 +29,6 @@ allergens that score 256, 512, 1024, etc.). Your program should
29
29
  ignore those components of the score. For example, if the allergy
30
30
  score is 257, your program should only report the eggs (1) allergy.
31
31
 
32
-
33
32
  * * * *
34
33
 
35
34
  For installation and learning resources, refer to the
@@ -39,16 +38,16 @@ You can run the provided tests through DrRacket, or via the command line.
39
38
 
40
39
  To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.
41
40
 
42
- To run the test from the command line, simply run the test from the exercise directory. For example, if the test suite is called `hello-world-test.rkt`, you can run the following command:
41
+ To run the test from the command line, run the test from the exercise directory with the following command:
43
42
 
44
43
  ```
45
- raco test hello-world-test.rkt
44
+ raco test allergies-test.rkt
46
45
  ```
47
46
 
48
47
  which will display the following:
49
48
 
50
49
  ```
51
- raco test: (submod "hello-world-test.rkt" test)
50
+ raco test: (submod "allergies-test.rkt" test)
52
51
  2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
53
52
  0
54
53
  2 tests passed
@@ -15,16 +15,16 @@ You can run the provided tests through DrRacket, or via the command line.
15
15
 
16
16
  To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.
17
17
 
18
- To run the test from the command line, simply run the test from the exercise directory. For example, if the test suite is called `hello-world-test.rkt`, you can run the following command:
18
+ To run the test from the command line, run the test from the exercise directory with the following command:
19
19
 
20
20
  ```
21
- raco test hello-world-test.rkt
21
+ raco test anagram-test.rkt
22
22
  ```
23
23
 
24
24
  which will display the following:
25
25
 
26
26
  ```
27
- raco test: (submod "hello-world-test.rkt" test)
27
+ raco test: (submod "anagram-test.rkt" test)
28
28
  2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
29
29
  0
30
30
  2 tests passed
@@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question.
6
6
 
7
7
  He answers 'Whoa, chill out!' if you yell at him.
8
8
 
9
+ He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
10
+
9
11
  He says 'Fine. Be that way!' if you address him without actually saying
10
12
  anything.
11
13
 
@@ -20,16 +22,16 @@ You can run the provided tests through DrRacket, or via the command line.
20
22
 
21
23
  To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.
22
24
 
23
- To run the test from the command line, simply run the test from the exercise directory. For example, if the test suite is called `hello-world-test.rkt`, you can run the following command:
25
+ To run the test from the command line, run the test from the exercise directory with the following command:
24
26
 
25
27
  ```
26
- raco test hello-world-test.rkt
28
+ raco test bob-test.rkt
27
29
  ```
28
30
 
29
31
  which will display the following:
30
32
 
31
33
  ```
32
- raco test: (submod "hello-world-test.rkt" test)
34
+ raco test: (submod "bob-test.rkt" test)
33
35
  2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
34
36
  0
35
37
  2 tests passed
@@ -35,16 +35,16 @@ You can run the provided tests through DrRacket, or via the command line.
35
35
 
36
36
  To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right.
37
37
 
38
- To run the test from the command line, simply run the test from the exercise directory. For example, if the test suite is called `hello-world-test.rkt`, you can run the following command:
38
+ To run the test from the command line, run the test from the exercise directory with the following command:
39
39
 
40
40
  ```
41
- raco test hello-world-test.rkt
41
+ raco test collatz-conjecture-test.rkt
42
42
  ```
43
43
 
44
44
  which will display the following:
45
45
 
46
46
  ```
47
- raco test: (submod "hello-world-test.rkt" test)
47
+ raco test: (submod "collatz-conjecture-test.rkt" test)
48
48
  2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
49
49
  0
50
50
  2 tests passed