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
@@ -1,5 +1,7 @@
1
1
  # Markdown
2
2
 
3
+ Refactor a Markdown parser.
4
+
3
5
  The markdown exercise is a refactoring exercise. There is code that parses a
4
6
  given string with [Markdown
5
7
  syntax](https://guides.github.com/features/mastering-markdown/) and returns the
@@ -12,6 +14,21 @@ It would be helpful if you made notes of what you did in your refactoring in
12
14
  comments so reviewers can see that, but it isn't strictly necessary. The most
13
15
  important thing is to make the code better!
14
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
+
15
32
  ## Submitting Exercises
16
33
 
17
34
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -21,5 +38,6 @@ For example, if you're submitting `bob.py` for the Bob exercise, the submit comm
21
38
  For more detailed information about running tests, code style and linting,
22
39
  please see the [help page](http://exercism.io/languages/python).
23
40
 
41
+
24
42
  ## Submitting Incomplete Solutions
25
43
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -40,6 +40,21 @@ And its columns:
40
40
  - 8, 3, 6
41
41
  - 7, 2, 7
42
42
 
43
+ ## Exception messages
44
+
45
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
46
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
47
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
48
+ a message.
49
+
50
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
51
+ `raise Exception`, you shold write:
52
+
53
+ ```python
54
+ raise Exception("Meaningful message indicating the source of the error")
55
+ ```
56
+
57
+
43
58
  ## Submitting Exercises
44
59
 
45
60
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -2,25 +2,44 @@
2
2
 
3
3
  Calculate the date of meetups.
4
4
 
5
- Typically meetups happen on the same day of the week. In this exercise, you will take
6
- a description of a meetup date, and return the actual meetup date.
5
+ Typically meetups happen on the same day of the week. In this exercise, you
6
+ will take a description of a meetup date, and return the actual meetup date.
7
7
 
8
8
  Examples of general descriptions are:
9
9
 
10
- - the first Monday of January 2017
11
- - the third Tuesday of January 2017
12
- - the Wednesteenth of January 2017
13
- - the last Thursday of January 2017
10
+ - The first Monday of January 2017
11
+ - The third Tuesday of January 2017
12
+ - The wednesteenth of January 2017
13
+ - The last Thursday of January 2017
14
14
 
15
- Note that "Monteenth", "Tuesteenth", etc are all made up words. There
16
- was a meetup whose members realized that there are exactly 7 numbered days in a month that
17
- end in '-teenth'. Therefore, one is guaranteed that each day of the week
15
+ The descriptors you are expected to parse are:
16
+ first, second, third, fourth, fifth, last, monteenth, tuesteenth, wednesteenth,
17
+ thursteenth, friteenth, saturteenth, sunteenth
18
+
19
+ Note that "monteenth", "tuesteenth", etc are all made up words. There was a
20
+ meetup whose members realized that there are exactly 7 numbered days in a month
21
+ that end in '-teenth'. Therefore, one is guaranteed that each day of the week
18
22
  (Monday, Tuesday, ...) will have exactly one date that is named with '-teenth'
19
23
  in every month.
20
24
 
21
- Given examples of a meetup dates, each containing a month, day, year, and descriptor
22
- (first, second, teenth, etc), calculate the date of the actual meetup.
23
- For example, if given "First Monday of January 2017", the correct meetup date is 2017/1/2
25
+ Given examples of a meetup dates, each containing a month, day, year, and
26
+ descriptor calculate the date of the actual meetup. For example, if given
27
+ "The first Monday of January 2017", the correct meetup date is 2017/1/2.
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
+
24
43
 
25
44
  ## Submitting Exercises
26
45
 
@@ -399,9 +399,19 @@ class MeetupTest(unittest.TestCase):
399
399
  meetup_day(2015, 3, 'Monday', '5th'), date(2015, 3, 30))
400
400
 
401
401
  def test_nonexistent_fifth_monday_of_february_2015(self):
402
- with self.assertRaises(MeetupDayException):
402
+ with self.assertRaisesWithMessage(MeetupDayException):
403
403
  meetup_day(2015, 2, 'Monday', '5th')
404
404
 
405
+ # Utility functions
406
+ def setUp(self):
407
+ try:
408
+ self.assertRaisesRegex = self.assertRaisesRegexp
409
+ except AttributeError:
410
+ pass
411
+
412
+ def assertRaisesWithMessage(self, exception):
413
+ return self.assertRaisesRegex(exception, r".+")
414
+
405
415
 
406
416
  if __name__ == '__main__':
407
417
  unittest.main()
@@ -26,6 +26,21 @@ into this:
26
26
  | 111 |
27
27
  +-----+
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.
@@ -139,14 +139,24 @@ class MinesweeperTest(unittest.TestCase):
139
139
  inp = [" ",
140
140
  "* ",
141
141
  " "]
142
- with self.assertRaises(ValueError):
142
+ with self.assertRaisesWithMessage(ValueError):
143
143
  board(inp)
144
144
 
145
145
  def test_invalid_char(self):
146
146
  inp = ["X * "]
147
- with self.assertRaises(ValueError):
147
+ with self.assertRaisesWithMessage(ValueError):
148
148
  board(inp)
149
149
 
150
+ # Utility functions
151
+ def setUp(self):
152
+ try:
153
+ self.assertRaisesRegex = self.assertRaisesRegexp
154
+ except AttributeError:
155
+ pass
156
+
157
+ def assertRaisesWithMessage(self, exception):
158
+ return self.assertRaisesRegex(exception, r".+")
159
+
150
160
 
151
161
  if __name__ == '__main__':
152
162
  unittest.main()
@@ -8,6 +8,21 @@ the 6th prime is 13.
8
8
  If your language provides methods in the standard library to deal with prime
9
9
  numbers, pretend they don't exist and implement them yourself.
10
10
 
11
+ ## Exception messages
12
+
13
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
14
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
15
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
16
+ a message.
17
+
18
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
19
+ `raise Exception`, you shold write:
20
+
21
+ ```python
22
+ raise Exception("Meaningful message indicating the source of the error")
23
+ ```
24
+
25
+
11
26
  ## Submitting Exercises
12
27
 
13
28
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -19,7 +19,7 @@ class NthPrimeTests(unittest.TestCase):
19
19
  self.assertEqual(nth_prime(10001), 104743)
20
20
 
21
21
  def test_there_is_no_zeroth_prime(self):
22
- with self.assertRaises(ValueError):
22
+ with self.assertRaisesWithMessage(ValueError):
23
23
  nth_prime(0)
24
24
 
25
25
  # additional track specific test
@@ -28,6 +28,16 @@ class NthPrimeTests(unittest.TestCase):
28
28
  37, 41, 43, 47, 53, 59, 61, 67, 71],
29
29
  [nth_prime(n) for n in range(1, 21)])
30
30
 
31
+ # Utility functions
32
+ def setUp(self):
33
+ try:
34
+ self.assertRaisesRegex = self.assertRaisesRegexp
35
+ except AttributeError:
36
+ pass
37
+
38
+ def assertRaisesWithMessage(self, exception):
39
+ return self.assertRaisesRegex(exception, r".+")
40
+
31
41
 
32
42
  if __name__ == '__main__':
33
43
  unittest.main()
@@ -2,8 +2,8 @@
2
2
 
3
3
  Given a single stranded DNA string, compute how many times each nucleotide occurs in the string.
4
4
 
5
- The genetic language of every living thing on the planet is DNA.
6
- DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides.
5
+ The genetic language of every living thing on the planet is DNA.
6
+ DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides.
7
7
  4 types exist in DNA and these differ only slightly and can be represented as the following symbols: 'A' for adenine, 'C' for cytosine, 'G' for guanine, and 'T' thymine.
8
8
 
9
9
  Here is an analogy:
@@ -12,6 +12,21 @@ Here is an analogy:
12
12
  - legos are to lego houses as
13
13
  - words are to sentences as...
14
14
 
15
+ ## Exception messages
16
+
17
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
18
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
19
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
20
+ a message.
21
+
22
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
23
+ `raise Exception`, you shold write:
24
+
25
+ ```python
26
+ raise Exception("Meaningful message indicating the source of the error")
27
+ ```
28
+
29
+
15
30
  ## Submitting Exercises
16
31
 
17
32
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -28,7 +28,7 @@ class DNATest(unittest.TestCase):
28
28
  self.assertEqual(count('GGGGGTAACCCGG', 'T'), 1)
29
29
 
30
30
  def test_validates_nucleotides(self):
31
- with self.assertRaises(ValueError):
31
+ with self.assertRaisesWithMessage(ValueError):
32
32
  count("GACT", 'X')
33
33
 
34
34
  def test_counts_all_nucleotides(self):
@@ -37,6 +37,16 @@ class DNATest(unittest.TestCase):
37
37
  expected = {'A': 20, 'T': 21, 'G': 17, 'C': 12}
38
38
  self.assertEqual(nucleotide_counts(dna), expected)
39
39
 
40
+ # Utility functions
41
+ def setUp(self):
42
+ try:
43
+ self.assertRaisesRegex = self.assertRaisesRegexp
44
+ except AttributeError:
45
+ pass
46
+
47
+ def assertRaisesWithMessage(self, exception):
48
+ return self.assertRaisesRegex(exception, r".+")
49
+
40
50
 
41
51
  if __name__ == '__main__':
42
52
  unittest.main()
@@ -1,4 +1,4 @@
1
- # Ocr Numbers
1
+ # OCR Numbers
2
2
 
3
3
  Given a 3 x 4 grid of pipes, underscores, and spaces, determine which number is
4
4
  represented, or whether it is garbled.
@@ -78,6 +78,21 @@ Update your program to handle multiple numbers, one per line. When converting se
78
78
 
79
79
  Is converted to "123,456,789"
80
80
 
81
+ ## Exception messages
82
+
83
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
84
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
85
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
86
+ a message.
87
+
88
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
89
+ `raise Exception`, you shold write:
90
+
91
+ ```python
92
+ raise Exception("Meaningful message indicating the source of the error")
93
+ ```
94
+
95
+
81
96
  ## Submitting Exercises
82
97
 
83
98
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -33,13 +33,13 @@ class OcrTest(unittest.TestCase):
33
33
  " "]), '?')
34
34
 
35
35
  def test_line_number_not_multiple_of_four(self):
36
- with self.assertRaises(ValueError):
36
+ with self.assertRaisesWithMessage(ValueError):
37
37
  convert([" _ ",
38
38
  "| |",
39
39
  " "])
40
40
 
41
41
  def test_col_number_not_multiple_of_three(self):
42
- with self.assertRaises(ValueError):
42
+ with self.assertRaisesWithMessage(ValueError):
43
43
  convert([" ",
44
44
  " |",
45
45
  " |",
@@ -137,6 +137,16 @@ class OcrTest(unittest.TestCase):
137
137
  ]
138
138
  self.assertEqual(convert(input_grid), "123,456,789")
139
139
 
140
+ # Utility functions
141
+ def setUp(self):
142
+ try:
143
+ self.assertRaisesRegex = self.assertRaisesRegexp
144
+ except AttributeError:
145
+ pass
146
+
147
+ def assertRaisesWithMessage(self, exception):
148
+ return self.assertRaisesRegex(exception, r".+")
149
+
140
150
 
141
151
  if __name__ == '__main__':
142
152
  unittest.main()
@@ -46,6 +46,21 @@ So:
46
46
  = 155
47
47
  ```
48
48
 
49
+ ## Exception messages
50
+
51
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
52
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
53
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
54
+ a message.
55
+
56
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
57
+ `raise Exception`, you shold write:
58
+
59
+ ```python
60
+ raise Exception("Meaningful message indicating the source of the error")
61
+ ```
62
+
63
+
49
64
  ## Submitting Exercises
50
65
 
51
66
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -29,17 +29,30 @@ class OctalTest(unittest.TestCase):
29
29
  self.assertEqual(parse_octal("1234567"), 342391)
30
30
 
31
31
  def test_8_is_seen_as_invalid(self):
32
- self.assertRaises(ValueError, parse_octal, "8")
32
+ with self.assertRaisesWithMessage(ValueError):
33
+ parse_octal("8")
33
34
 
34
35
  def test_invalid_octal_is_recognized(self):
35
- self.assertRaises(ValueError, parse_octal, "carrot")
36
+ with self.assertRaisesWithMessage(ValueError):
37
+ parse_octal("carrot")
36
38
 
37
39
  def test_6789_is_seen_as_invalid(self):
38
- self.assertRaises(ValueError, parse_octal, "6789")
40
+ with self.assertRaisesWithMessage(ValueError):
41
+ parse_octal("6789")
39
42
 
40
43
  def test_valid_octal_formatted_string_011_is_decimal_9(self):
41
44
  self.assertEqual(parse_octal("011"), 9)
42
45
 
46
+ # Utility functions
47
+ def setUp(self):
48
+ try:
49
+ self.assertRaisesRegex = self.assertRaisesRegexp
50
+ except AttributeError:
51
+ pass
52
+
53
+ def assertRaisesWithMessage(self, exception):
54
+ return self.assertRaisesRegex(exception, r".+")
55
+
43
56
 
44
57
  if __name__ == '__main__':
45
58
  unittest.main()
@@ -9,7 +9,7 @@ Given a range of numbers, find the largest and smallest palindromes which
9
9
  are products of numbers within that range.
10
10
 
11
11
  Your solution should return the largest and smallest palindromes, along with the
12
- factors of each within the range. If the largest or smallest palindrome has more
12
+ factors of each within the range. If the largest or smallest palindrome has more
13
13
  than one pair of factors within the range, then return all the pairs.
14
14
 
15
15
  ## Example 1
@@ -32,6 +32,21 @@ Given the range `[10, 99]` (both inclusive)...
32
32
  The smallest palindrome product is `121`. Its factors are `(11, 11)`.
33
33
  The largest palindrome product is `9009`. Its factors are `(91, 99)`.
34
34
 
35
+ ## Exception messages
36
+
37
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
38
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
39
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
40
+ a message.
41
+
42
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
43
+ `raise Exception`, you shold write:
44
+
45
+ ```python
46
+ raise Exception("Meaningful message indicating the source of the error")
47
+ ```
48
+
49
+
35
50
  ## Submitting Exercises
36
51
 
37
52
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -8,6 +8,21 @@ The best known English pangram is:
8
8
  The alphabet used consists of ASCII letters `a` to `z`, inclusive, and is case
9
9
  insensitive. Input will not contain non-ASCII symbols.
10
10
 
11
+ ## Exception messages
12
+
13
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
14
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
15
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
16
+ a message.
17
+
18
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
19
+ `raise Exception`, you shold write:
20
+
21
+ ```python
22
+ raise Exception("Meaningful message indicating the source of the error")
23
+ ```
24
+
25
+
11
26
  ## Submitting Exercises
12
27
 
13
28
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.