trackler 2.2.1.74 → 2.2.1.75

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/fixtures/tracks/fruit/docs/something.md +0 -0
  3. data/lib/trackler/version.rb +1 -1
  4. data/problem-specifications/README.md +8 -4
  5. data/problem-specifications/exercises/acronym/canonical-data.json +19 -7
  6. data/problem-specifications/exercises/all-your-base/canonical-data.json +106 -64
  7. data/problem-specifications/exercises/allergies/canonical-data.json +37 -13
  8. data/tracks/c/config.json +176 -176
  9. data/tracks/clojure/config.json +17 -1
  10. data/tracks/clojure/exercises/isbn-verifier/README.md +43 -0
  11. data/tracks/clojure/exercises/isbn-verifier/project.clj +4 -0
  12. data/tracks/clojure/exercises/isbn-verifier/src/example.clj +17 -0
  13. data/tracks/clojure/exercises/isbn-verifier/src/isbn_verifier.clj +3 -0
  14. data/tracks/clojure/exercises/isbn-verifier/test/isbn_verifier_test.clj +42 -0
  15. data/tracks/clojure/exercises/proverb/README.md +15 -0
  16. data/tracks/clojure/exercises/proverb/project.clj +4 -0
  17. data/tracks/clojure/exercises/proverb/src/example.clj +15 -0
  18. data/tracks/clojure/exercises/proverb/src/proverb.clj +3 -0
  19. data/tracks/clojure/exercises/proverb/test/proverb_test.clj +14 -0
  20. data/tracks/common-lisp/docs/LEARNING.md +4 -3
  21. data/tracks/common-lisp/docs/RESOURCES.md +11 -0
  22. data/tracks/delphi/.gitignore +1 -0
  23. data/tracks/delphi/config.json +24 -0
  24. data/tracks/delphi/docs/INSTALLATION.md +1 -1
  25. data/tracks/delphi/exercises/isbn-verifier/ISBNVerifier.dpr +60 -0
  26. data/tracks/delphi/exercises/isbn-verifier/README.md +68 -0
  27. data/tracks/delphi/exercises/isbn-verifier/uISBNVerifierExample.pas +46 -0
  28. data/tracks/delphi/exercises/isbn-verifier/uTestISBNVerifier.pas +136 -0
  29. data/tracks/delphi/exercises/secret-handshake/README.md +56 -0
  30. data/tracks/delphi/exercises/secret-handshake/SecretHandshake.dpr +60 -0
  31. data/tracks/delphi/exercises/secret-handshake/uSecretHandshakeExample.pas +56 -0
  32. data/tracks/delphi/exercises/secret-handshake/uTestSecretHandshake.pas +215 -0
  33. data/tracks/ecmascript/docs/ABOUT.md +13 -9
  34. data/tracks/factor/exercises/two-fer/README.md +1 -1
  35. data/tracks/fsharp/docs/RESOURCES.md +1 -1
  36. data/tracks/fsharp/generators/{Input.fs → CanonicalData.fs} +5 -10
  37. data/tracks/fsharp/generators/Exercise.fs +11 -10
  38. data/tracks/fsharp/generators/{Output.fs → Formatting.fs} +2 -56
  39. data/tracks/fsharp/generators/Generators.fs +93 -93
  40. data/tracks/fsharp/generators/Generators.fsproj +9 -4
  41. data/tracks/fsharp/generators/Options.fs +1 -1
  42. data/tracks/fsharp/generators/Program.fs +3 -3
  43. data/tracks/fsharp/generators/Rendering.fs +57 -0
  44. data/tracks/go/exercises/all-your-base/.meta/gen.go +80 -0
  45. data/tracks/go/exercises/all-your-base/.meta/hints.md +13 -0
  46. data/tracks/go/exercises/all-your-base/README.md +16 -1
  47. data/tracks/go/exercises/all-your-base/all_your_base_test.go +12 -163
  48. data/tracks/go/exercises/all-your-base/cases_test.go +183 -0
  49. data/tracks/go/exercises/all-your-base/example.go +25 -29
  50. data/tracks/java/CONTRIBUTING.md +1 -1
  51. data/tracks/java/POLICIES.md +15 -1
  52. data/tracks/java/exercises/flatten-array/.meta/hints.md +58 -0
  53. data/tracks/java/exercises/flatten-array/README.md +62 -0
  54. data/tracks/java/exercises/hamming/src/main/java/Hamming.java +1 -1
  55. data/tracks/java/exercises/matrix/.meta/src/reference/java/Matrix.java +6 -6
  56. data/tracks/java/exercises/meetup/.meta/src/reference/java/Meetup.java +2 -2
  57. data/tracks/java/exercises/meetup/.meta/src/reference/java/MeetupSchedule.java +1 -1
  58. data/tracks/java/exercises/meetup/src/main/java/MeetupSchedule.java +1 -1
  59. data/tracks/java/exercises/pig-latin/.meta/hints.md +58 -0
  60. data/tracks/java/exercises/pig-latin/README.md +61 -0
  61. data/tracks/java/exercises/reverse-string/src/main/java/ReverseString.java +2 -2
  62. data/tracks/java/exercises/secret-handshake/README.md +1 -1
  63. data/tracks/javascript/.eslintignore +0 -3
  64. data/tracks/javascript/exercises/food-chain/example.js +50 -37
  65. data/tracks/javascript/exercises/octal/example.js +1 -1
  66. data/tracks/javascript/exercises/robot-name/robot-name.spec.js +7 -7
  67. data/tracks/javascript/package-lock.json +1846 -0
  68. data/tracks/python/docs/EXERCISE_README_INSERT.md +15 -0
  69. data/tracks/python/exercises/accumulate/README.md +15 -0
  70. data/tracks/python/exercises/acronym/README.md +15 -0
  71. data/tracks/python/exercises/all-your-base/README.md +15 -0
  72. data/tracks/python/exercises/all-your-base/all_your_base_test.py +19 -9
  73. data/tracks/python/exercises/allergies/README.md +15 -0
  74. data/tracks/python/exercises/alphametics/README.md +15 -0
  75. data/tracks/python/exercises/anagram/README.md +15 -0
  76. data/tracks/python/exercises/atbash-cipher/README.md +15 -0
  77. data/tracks/python/exercises/beer-song/README.md +16 -1
  78. data/tracks/python/exercises/binary-search-tree/README.md +16 -2
  79. data/tracks/python/exercises/binary-search/README.md +15 -0
  80. data/tracks/python/exercises/binary-search/binary_search_test.py +14 -4
  81. data/tracks/python/exercises/binary/README.md +15 -0
  82. data/tracks/python/exercises/binary/binary_test.py +14 -4
  83. data/tracks/python/exercises/bob/README.md +15 -0
  84. data/tracks/python/exercises/book-store/README.md +15 -0
  85. data/tracks/python/exercises/bracket-push/README.md +15 -0
  86. data/tracks/python/exercises/change/README.md +15 -0
  87. data/tracks/python/exercises/circular-buffer/README.md +15 -0
  88. data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +15 -5
  89. data/tracks/python/exercises/circular-buffer/example.py +2 -2
  90. data/tracks/python/exercises/clock/README.md +15 -0
  91. data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +1 -1
  92. data/tracks/python/exercises/collatz-conjecture/README.md +15 -0
  93. data/tracks/python/exercises/complex-numbers/README.md +15 -0
  94. data/tracks/python/exercises/connect/README.md +18 -3
  95. data/tracks/python/exercises/crypto-square/README.md +15 -0
  96. data/tracks/python/exercises/diamond/README.md +15 -0
  97. data/tracks/python/exercises/difference-of-squares/README.md +15 -0
  98. data/tracks/python/exercises/diffie-hellman/README.md +14 -0
  99. data/tracks/python/exercises/dominoes/README.md +16 -1
  100. data/tracks/python/exercises/error-handling/README.md +17 -0
  101. data/tracks/python/exercises/error-handling/error_handling_test.py +13 -3
  102. data/tracks/python/exercises/error-handling/example.py +1 -1
  103. data/tracks/python/exercises/etl/README.md +16 -1
  104. data/tracks/python/exercises/flatten-array/README.md +15 -0
  105. data/tracks/python/exercises/food-chain/README.md +15 -0
  106. data/tracks/python/exercises/forth/README.md +15 -0
  107. data/tracks/python/exercises/forth/example.py +7 -9
  108. data/tracks/python/exercises/forth/forth_test.py +107 -17
  109. data/tracks/python/exercises/gigasecond/README.md +15 -0
  110. data/tracks/python/exercises/go-counting/README.md +21 -3
  111. data/tracks/python/exercises/grade-school/README.md +15 -0
  112. data/tracks/python/exercises/grains/README.md +15 -0
  113. data/tracks/python/exercises/grains/grains_test.py +16 -6
  114. data/tracks/python/exercises/grep/README.md +15 -0
  115. data/tracks/python/exercises/hamming/README.md +15 -0
  116. data/tracks/python/exercises/hamming/hamming_test.py +12 -2
  117. data/tracks/python/exercises/hello-world/README.md +15 -0
  118. data/tracks/python/exercises/hexadecimal/README.md +15 -0
  119. data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +11 -1
  120. data/tracks/python/exercises/house/README.md +16 -1
  121. data/tracks/python/exercises/isogram/README.md +15 -0
  122. data/tracks/python/exercises/kindergarten-garden/README.md +18 -3
  123. data/tracks/python/exercises/largest-series-product/README.md +15 -0
  124. data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +14 -4
  125. data/tracks/python/exercises/leap/README.md +15 -0
  126. data/tracks/python/exercises/linked-list/README.md +15 -0
  127. data/tracks/python/exercises/list-ops/README.md +15 -0
  128. data/tracks/python/exercises/luhn/README.md +15 -0
  129. data/tracks/python/exercises/markdown/README.md +18 -0
  130. data/tracks/python/exercises/matrix/README.md +15 -0
  131. data/tracks/python/exercises/meetup/README.md +31 -12
  132. data/tracks/python/exercises/meetup/meetup_test.py +11 -1
  133. data/tracks/python/exercises/minesweeper/README.md +15 -0
  134. data/tracks/python/exercises/minesweeper/minesweeper_test.py +12 -2
  135. data/tracks/python/exercises/nth-prime/README.md +15 -0
  136. data/tracks/python/exercises/nth-prime/nth_prime_test.py +11 -1
  137. data/tracks/python/exercises/nucleotide-count/README.md +17 -2
  138. data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +11 -1
  139. data/tracks/python/exercises/ocr-numbers/README.md +16 -1
  140. data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +12 -2
  141. data/tracks/python/exercises/octal/README.md +15 -0
  142. data/tracks/python/exercises/octal/octal_test.py +16 -3
  143. data/tracks/python/exercises/palindrome-products/README.md +16 -1
  144. data/tracks/python/exercises/pangram/README.md +15 -0
  145. data/tracks/python/exercises/pascals-triangle/README.md +16 -1
  146. data/tracks/python/exercises/perfect-numbers/README.md +15 -0
  147. data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +13 -3
  148. data/tracks/python/exercises/phone-number/README.md +16 -2
  149. data/tracks/python/exercises/phone-number/example.py +1 -1
  150. data/tracks/python/exercises/phone-number/phone_number_test.py +17 -7
  151. data/tracks/python/exercises/pig-latin/README.md +15 -0
  152. data/tracks/python/exercises/point-mutations/README.md +15 -0
  153. data/tracks/python/exercises/poker/README.md +15 -0
  154. data/tracks/python/exercises/pov/README.md +20 -2
  155. data/tracks/python/exercises/pov/example.py +2 -2
  156. data/tracks/python/exercises/pov/pov_test.py +15 -5
  157. data/tracks/python/exercises/prime-factors/README.md +15 -0
  158. data/tracks/python/exercises/protein-translation/README.md +15 -0
  159. data/tracks/python/exercises/protein-translation/protein_translation_test.py +10 -0
  160. data/tracks/python/exercises/proverb/README.md +14 -0
  161. data/tracks/python/exercises/pythagorean-triplet/README.md +15 -0
  162. data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +11 -1
  163. data/tracks/python/exercises/queen-attack/README.md +15 -0
  164. data/tracks/python/exercises/queen-attack/queen_attack_test.py +17 -7
  165. data/tracks/python/exercises/rail-fence-cipher/README.md +15 -0
  166. data/tracks/python/exercises/raindrops/README.md +15 -0
  167. data/tracks/python/exercises/react/README.md +15 -1
  168. data/tracks/python/exercises/rectangles/README.md +24 -9
  169. data/tracks/python/exercises/rna-transcription/.meta/hints.md +1 -0
  170. data/tracks/python/exercises/rna-transcription/README.md +18 -5
  171. data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +13 -3
  172. data/tracks/python/exercises/robot-name/README.md +15 -0
  173. data/tracks/python/exercises/robot-simulator/README.md +15 -0
  174. data/tracks/python/exercises/roman-numerals/README.md +15 -0
  175. data/tracks/python/exercises/rotational-cipher/README.md +15 -0
  176. data/tracks/python/exercises/run-length-encoding/README.md +15 -0
  177. data/tracks/python/exercises/saddle-points/README.md +15 -0
  178. data/tracks/python/exercises/saddle-points/saddle_points_test.py +11 -1
  179. data/tracks/python/exercises/say/README.md +15 -0
  180. data/tracks/python/exercises/say/say_test.py +12 -2
  181. data/tracks/python/exercises/scale-generator/README.md +15 -0
  182. data/tracks/python/exercises/scale-generator/example.py +3 -3
  183. data/tracks/python/exercises/scale-generator/scale_generator_test.py +11 -1
  184. data/tracks/python/exercises/scrabble-score/README.md +15 -0
  185. data/tracks/python/exercises/secret-handshake/README.md +16 -1
  186. data/tracks/python/exercises/series/README.md +15 -0
  187. data/tracks/python/exercises/series/series_test.py +12 -2
  188. data/tracks/python/exercises/sieve/README.md +15 -0
  189. data/tracks/python/exercises/simple-cipher/.meta/hints.md +6 -6
  190. data/tracks/python/exercises/simple-cipher/README.md +17 -1
  191. data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +12 -2
  192. data/tracks/python/exercises/simple-linked-list/{hints.md → .meta/hints.md} +10 -10
  193. data/tracks/python/exercises/simple-linked-list/README.md +16 -0
  194. data/tracks/python/exercises/simple-linked-list/example.py +2 -2
  195. data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +13 -3
  196. data/tracks/python/exercises/space-age/README.md +15 -0
  197. data/tracks/python/exercises/strain/README.md +16 -3
  198. data/tracks/python/exercises/sublist/README.md +15 -0
  199. data/tracks/python/exercises/sum-of-multiples/README.md +18 -3
  200. data/tracks/python/exercises/tournament/README.md +15 -0
  201. data/tracks/python/exercises/transpose/README.md +15 -0
  202. data/tracks/python/exercises/tree-building/README.md +30 -0
  203. data/tracks/python/exercises/tree-building/example.py +3 -5
  204. data/tracks/python/exercises/tree-building/tree_building_test.py +16 -6
  205. data/tracks/python/exercises/triangle/README.md +15 -0
  206. data/tracks/python/exercises/triangle/example.py +1 -1
  207. data/tracks/python/exercises/triangle/triangle_test.py +15 -5
  208. data/tracks/python/exercises/trinary/README.md +15 -0
  209. data/tracks/python/exercises/twelve-days/README.md +15 -0
  210. data/tracks/python/exercises/two-bucket/README.md +22 -7
  211. data/tracks/python/exercises/two-fer/README.md +16 -0
  212. data/tracks/python/exercises/variable-length-quantity/README.md +15 -0
  213. data/tracks/python/exercises/variable-length-quantity/variable_length_quantity_test.py +12 -2
  214. data/tracks/python/exercises/word-count/README.md +15 -0
  215. data/tracks/python/exercises/word-search/README.md +15 -0
  216. data/tracks/python/exercises/wordy/README.md +15 -0
  217. data/tracks/python/exercises/wordy/wordy_test.py +14 -4
  218. data/tracks/python/exercises/zebra-puzzle/README.md +15 -0
  219. data/tracks/python/exercises/zipper/README.md +16 -3
  220. data/tracks/rust/config.json +11 -0
  221. data/tracks/rust/exercises/saddle-points/.gitignore +8 -0
  222. data/tracks/rust/exercises/saddle-points/Cargo.toml +5 -0
  223. data/tracks/rust/exercises/saddle-points/README.md +66 -0
  224. data/tracks/rust/exercises/saddle-points/example.rs +24 -0
  225. data/tracks/rust/exercises/saddle-points/src/lib.rs +3 -0
  226. data/tracks/rust/exercises/saddle-points/tests/saddle-points.rs +60 -0
  227. metadata +38 -5
@@ -26,6 +26,21 @@ are some additional things you could try:
26
26
  Then please share your thoughts in a comment on the submission. Did this
27
27
  experiment make the code better? Worse? Did you learn anything from it?
28
28
 
29
+ ## Exception messages
30
+
31
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
32
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
33
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
34
+ a message.
35
+
36
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
37
+ `raise Exception`, you shold write:
38
+
39
+ ```python
40
+ raise Exception("Meaningful message indicating the source of the error")
41
+ ```
42
+
43
+
29
44
  ## Submitting Exercises
30
45
 
31
46
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -31,26 +31,36 @@ class GrainsTest(unittest.TestCase):
31
31
  self.assertEqual(on_square(64), 9223372036854775808)
32
32
 
33
33
  def test_square_0_raises_exception(self):
34
- with self.assertRaises(ValueError):
34
+ with self.assertRaisesWithMessage(ValueError):
35
35
  on_square(0)
36
- with self.assertRaises(ValueError):
36
+ with self.assertRaisesWithMessage(ValueError):
37
37
  total_after(0)
38
38
 
39
39
  def test_square_negative_raises_exception(self):
40
- with self.assertRaises(ValueError):
40
+ with self.assertRaisesWithMessage(ValueError):
41
41
  on_square(-1)
42
- with self.assertRaises(ValueError):
42
+ with self.assertRaisesWithMessage(ValueError):
43
43
  total_after(-1)
44
44
 
45
45
  def test_square_gt_64_raises_exception(self):
46
- with self.assertRaises(ValueError):
46
+ with self.assertRaisesWithMessage(ValueError):
47
47
  on_square(65)
48
- with self.assertRaises(ValueError):
48
+ with self.assertRaisesWithMessage(ValueError):
49
49
  total_after(65)
50
50
 
51
51
  def test_total(self):
52
52
  self.assertEqual(total_after(64), 18446744073709551615)
53
53
 
54
+ # Utility functions
55
+ def setUp(self):
56
+ try:
57
+ self.assertRaisesRegex = self.assertRaisesRegexp
58
+ except AttributeError:
59
+ pass
60
+
61
+ def assertRaisesWithMessage(self, exception):
62
+ return self.assertRaisesRegex(exception, r".+")
63
+
54
64
 
55
65
  if __name__ == '__main__':
56
66
  unittest.main()
@@ -64,6 +64,21 @@ The `grep` command should support multiple flags at once.
64
64
  For example, running `grep -l -v "hello" file1.txt file2.txt` should
65
65
  print the names of files that do not contain the string "hello".
66
66
 
67
+ ## Exception messages
68
+
69
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
70
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
71
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
72
+ a message.
73
+
74
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
75
+ `raise Exception`, you shold write:
76
+
77
+ ```python
78
+ raise Exception("Meaningful message indicating the source of the error")
79
+ ```
80
+
81
+
67
82
  ## Submitting Exercises
68
83
 
69
84
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -35,6 +35,21 @@ The Hamming distance is only defined for sequences of equal length. This means
35
35
  that based on the definition, each language could deal with getting sequences
36
36
  of equal length differently.
37
37
 
38
+ ## Exception messages
39
+
40
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
41
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
42
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
43
+ a message.
44
+
45
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
46
+ `raise Exception`, you shold write:
47
+
48
+ ```python
49
+ raise Exception("Meaningful message indicating the source of the error")
50
+ ```
51
+
52
+
38
53
  ## Submitting Exercises
39
54
 
40
55
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -47,13 +47,23 @@ class HammingTest(unittest.TestCase):
47
47
  self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)
48
48
 
49
49
  def test_disallow_first_strand_longer(self):
50
- with self.assertRaises(ValueError):
50
+ with self.assertRaisesWithMessage(ValueError):
51
51
  hamming.distance("AATG", "AAA")
52
52
 
53
53
  def test_disallow_second_strand_longer(self):
54
- with self.assertRaises(ValueError):
54
+ with self.assertRaisesWithMessage(ValueError):
55
55
  hamming.distance("ATA", "AGTG")
56
56
 
57
+ # Utility functions
58
+ def setUp(self):
59
+ try:
60
+ self.assertRaisesRegex = self.assertRaisesRegexp
61
+ except AttributeError:
62
+ pass
63
+
64
+ def assertRaisesWithMessage(self, exception):
65
+ return self.assertRaisesRegex(exception, r".+")
66
+
57
67
 
58
68
  if __name__ == '__main__':
59
69
  unittest.main()
@@ -14,6 +14,21 @@ The objectives are simple:
14
14
 
15
15
  If everything goes well, you will be ready to fetch your first real exercise.
16
16
 
17
+ ## Exception messages
18
+
19
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
20
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
21
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
22
+ a message.
23
+
24
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
25
+ `raise Exception`, you shold write:
26
+
27
+ ```python
28
+ raise Exception("Meaningful message indicating the source of the error")
29
+ ```
30
+
31
+
17
32
  ## Submitting Exercises
18
33
 
19
34
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -7,6 +7,21 @@ teal: 008080, navy: 000080).
7
7
 
8
8
  The program should handle invalid hexadecimal strings.
9
9
 
10
+ ## Exception messages
11
+
12
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
13
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
14
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
15
+ a message.
16
+
17
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
18
+ `raise Exception`, you shold write:
19
+
20
+ ```python
21
+ raise Exception("Meaningful message indicating the source of the error")
22
+ ```
23
+
24
+
10
25
  ## Submitting Exercises
11
26
 
12
27
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -35,9 +35,19 @@ class HexadecimalTest(unittest.TestCase):
35
35
  self.assertEqual(hexa('00fff0'), 65520)
36
36
 
37
37
  def test_invalid_hexa(self):
38
- with self.assertRaises(ValueError):
38
+ with self.assertRaisesWithMessage(ValueError):
39
39
  hexa('carrot')
40
40
 
41
+ # Utility functions
42
+ def setUp(self):
43
+ try:
44
+ self.assertRaisesRegex = self.assertRaisesRegexp
45
+ except AttributeError:
46
+ pass
47
+
48
+ def assertRaisesWithMessage(self, exception):
49
+ return self.assertRaisesRegex(exception, r".+")
50
+
41
51
 
42
52
  if __name__ == '__main__':
43
53
  unittest.main()
@@ -1,6 +1,6 @@
1
1
  # House
2
2
 
3
- Output the nursery rhyme 'This is the House that Jack Built'.
3
+ Recite the nursery rhyme 'This is the House that Jack Built'.
4
4
 
5
5
  > [The] process of placing a phrase of clause within another phrase of
6
6
  > clause is called embedding. It is through the processes of recursion
@@ -105,6 +105,21 @@ that ate the malt
105
105
  that lay in the house that Jack built.
106
106
  ```
107
107
 
108
+ ## Exception messages
109
+
110
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
111
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
112
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
113
+ a message.
114
+
115
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
116
+ `raise Exception`, you shold write:
117
+
118
+ ```python
119
+ raise Exception("Meaningful message indicating the source of the error")
120
+ ```
121
+
122
+
108
123
  ## Submitting Exercises
109
124
 
110
125
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -13,6 +13,21 @@ Examples of isograms:
13
13
 
14
14
  The word *isograms*, however, is not an isogram, because the s repeats.
15
15
 
16
+ ## Exception messages
17
+
18
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
19
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
20
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
21
+ a message.
22
+
23
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
24
+ `raise Exception`, you shold write:
25
+
26
+ ```python
27
+ raise Exception("Meaningful message indicating the source of the error")
28
+ ```
29
+
30
+
16
31
  ## Submitting Exercises
17
32
 
18
33
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -9,8 +9,8 @@ actual dirt, and grow actual plants.
9
9
 
10
10
  They've chosen to grow grass, clover, radishes, and violets.
11
11
 
12
- To this end, the children have put little cups along the window sills, and
13
- planted one type of plant in each cup, choosing randomly from the available
12
+ To this end, the children have put little cups along the window sills, and
13
+ planted one type of plant in each cup, choosing randomly from the available
14
14
  types of seeds.
15
15
 
16
16
  ```text
@@ -25,7 +25,7 @@ There are 12 children in the class:
25
25
  - Eve, Fred, Ginny, Harriet,
26
26
  - Ileana, Joseph, Kincaid, and Larry.
27
27
 
28
- Each child gets 4 cups, two on each row. Their teacher assigns cups to
28
+ Each child gets 4 cups, two on each row. Their teacher assigns cups to
29
29
  the children alphabetically by their names.
30
30
 
31
31
  The following diagram represents Alice's plants:
@@ -59,6 +59,21 @@ While asking for Bob's plants would yield:
59
59
 
60
60
  - Clover, grass, clover, clover
61
61
 
62
+ ## Exception messages
63
+
64
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
65
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
66
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
67
+ a message.
68
+
69
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
70
+ `raise Exception`, you shold write:
71
+
72
+ ```python
73
+ raise Exception("Meaningful message indicating the source of the error")
74
+ ```
75
+
76
+
62
77
  ## Submitting Exercises
63
78
 
64
79
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -13,6 +13,21 @@ in the input; the digits need not be *numerically consecutive*.
13
13
  For the input `'73167176531330624919225119674426574742355349194934'`,
14
14
  the largest product for a series of 6 digits is 23520.
15
15
 
16
+ ## Exception messages
17
+
18
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
19
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
20
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
21
+ a message.
22
+
23
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
24
+ `raise Exception`, you shold write:
25
+
26
+ ```python
27
+ raise Exception("Meaningful message indicating the source of the error")
28
+ ```
29
+
30
+
16
31
  ## Submitting Exercises
17
32
 
18
33
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -45,7 +45,7 @@ class SeriesTest(unittest.TestCase):
45
45
  self.assertEqual(largest_product("99099", 3), 0)
46
46
 
47
47
  def test_rejects_span_longer_than_string_length(self):
48
- with self.assertRaises(ValueError):
48
+ with self.assertRaisesWithMessage(ValueError):
49
49
  largest_product("123", 4)
50
50
 
51
51
  def test_reports_1_for_empty_string_and_empty_product_0_span(self):
@@ -55,15 +55,15 @@ class SeriesTest(unittest.TestCase):
55
55
  self.assertEqual(largest_product("123", 0), 1)
56
56
 
57
57
  def test_rejects_empty_string_and_nonzero_span(self):
58
- with self.assertRaises(ValueError):
58
+ with self.assertRaisesWithMessage(ValueError):
59
59
  largest_product("", 1)
60
60
 
61
61
  def test_rejects_invalid_character_in_digits(self):
62
- with self.assertRaises(ValueError):
62
+ with self.assertRaisesWithMessage(ValueError):
63
63
  largest_product("1234a5", 2)
64
64
 
65
65
  def test_rejects_negative_span(self):
66
- with self.assertRaises(ValueError):
66
+ with self.assertRaisesWithMessage(ValueError):
67
67
  largest_product("12345", -1)
68
68
 
69
69
  @unittest.skip("extra-credit")
@@ -87,6 +87,16 @@ class SeriesTest(unittest.TestCase):
87
87
  "3600823257530420752963450")
88
88
  self.assertEqual(largest_product(series, 13), 23514624000)
89
89
 
90
+ # Utility functions
91
+ def setUp(self):
92
+ try:
93
+ self.assertRaisesRegex = self.assertRaisesRegexp
94
+ except AttributeError:
95
+ pass
96
+
97
+ def assertRaisesWithMessage(self, exception):
98
+ return self.assertRaisesRegex(exception, r".+")
99
+
90
100
 
91
101
  if __name__ == '__main__':
92
102
  unittest.main()
@@ -26,6 +26,21 @@ phenomenon, go watch [this youtube video][video].
26
26
 
27
27
  [video]: http://www.youtube.com/watch?v=xX96xng7sAE
28
28
 
29
+ ## Exception messages
30
+
31
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
32
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
33
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
34
+ a message.
35
+
36
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
37
+ `raise Exception`, you shold write:
38
+
39
+ ```python
40
+ raise Exception("Meaningful message indicating the source of the error")
41
+ ```
42
+
43
+
29
44
  ## Submitting Exercises
30
45
 
31
46
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -27,6 +27,21 @@ empty list.
27
27
 
28
28
  If you want to know more about linked lists, check [Wikipedia](https://en.wikipedia.org/wiki/Linked_list).
29
29
 
30
+ ## Exception messages
31
+
32
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
33
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
34
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
35
+ a message.
36
+
37
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
38
+ `raise Exception`, you shold write:
39
+
40
+ ```python
41
+ raise Exception("Meaningful message indicating the source of the error")
42
+ ```
43
+
44
+
30
45
  ## Submitting Exercises
31
46
 
32
47
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -6,6 +6,21 @@ In functional languages list operations like `length`, `map`, and
6
6
  `reduce` are very common. Implement a series of basic list operations,
7
7
  without using existing functions.
8
8
 
9
+ ## Exception messages
10
+
11
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
12
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
13
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
14
+ a message.
15
+
16
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
17
+ `raise Exception`, you shold write:
18
+
19
+ ```python
20
+ raise Exception("Meaningful message indicating the source of the error")
21
+ ```
22
+
23
+
9
24
  ## Submitting Exercises
10
25
 
11
26
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -64,6 +64,21 @@ Sum the digits
64
64
 
65
65
  57 is not evenly divisible by 10, so this number is not valid.
66
66
 
67
+ ## Exception messages
68
+
69
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
70
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
71
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
72
+ a message.
73
+
74
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
75
+ `raise Exception`, you shold write:
76
+
77
+ ```python
78
+ raise Exception("Meaningful message indicating the source of the error")
79
+ ```
80
+
81
+
67
82
  ## Submitting Exercises
68
83
 
69
84
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.