trackler 2.2.1.53 → 2.2.1.54

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/nth-prime/canonical-data.json +2 -7
  4. data/problem-specifications/exercises/zebra-puzzle/canonical-data.json +16 -0
  5. data/tracks/c/config.json +11 -1
  6. data/tracks/c/docs/C_STYLE_GUIDE.md +142 -0
  7. data/tracks/c/exercises/collatz-conjecture/README.md +65 -0
  8. data/tracks/c/exercises/collatz-conjecture/makefile +15 -0
  9. data/tracks/c/exercises/collatz-conjecture/src/collatz_conjecture.h +8 -0
  10. data/tracks/c/exercises/collatz-conjecture/src/example.c +23 -0
  11. data/tracks/c/exercises/collatz-conjecture/test/test_collatz_conjecture.c +48 -0
  12. data/tracks/c/exercises/collatz-conjecture/test/vendor/unity.c +1300 -0
  13. data/tracks/c/exercises/collatz-conjecture/test/vendor/unity.h +274 -0
  14. data/tracks/c/exercises/collatz-conjecture/test/vendor/unity_internals.h +701 -0
  15. data/tracks/cfml/tasks/GenerateReadme.cfc +5 -5
  16. data/tracks/erlang/testgen/src/testgen.erl +99 -17
  17. data/tracks/erlang/testgen/src/tg_file_tools.erl +3 -3
  18. data/tracks/erlang/testgen/src/tgen.erl +15 -7
  19. data/tracks/haskell/config.json +15 -3
  20. data/tracks/java/scripts/canonical_data_check.sh +1 -1
  21. data/tracks/javascript/config.json +12 -0
  22. data/tracks/javascript/exercises/difference-of-squares/README.md +1 -1
  23. data/tracks/javascript/exercises/sum-of-multiples/README.md +1 -1
  24. data/tracks/javascript/exercises/zipper/README.md +55 -0
  25. data/tracks/javascript/exercises/zipper/example.js +100 -0
  26. data/tracks/javascript/exercises/zipper/zipper.spec.js +77 -0
  27. data/tracks/julia/config.json +12 -0
  28. data/tracks/julia/exercises/triangle/README.md +30 -0
  29. data/tracks/julia/exercises/triangle/example.jl +25 -0
  30. data/tracks/julia/exercises/triangle/runtests.jl +64 -0
  31. data/tracks/julia/exercises/triangle/triangle.jl +8 -0
  32. data/tracks/kotlin/exercises/leap/.meta/version +1 -1
  33. data/tracks/kotlin/exercises/leap/src/test/kotlin/LeapTest.kt +1 -1
  34. data/tracks/kotlin/scripts/canonical_data_check.sh +1 -1
  35. data/tracks/perl6/bin/README.md +1 -4
  36. data/tracks/perl6/bin/exercise-gen.pl6 +3 -4
  37. data/tracks/perl6/exercises/accumulate/example.yaml +2 -2
  38. data/tracks/perl6/exercises/all-your-base/example.yaml +9 -9
  39. data/tracks/perl6/exercises/allergies/example.yaml +7 -7
  40. data/tracks/perl6/exercises/anagram/example.yaml +3 -3
  41. data/tracks/perl6/exercises/atbash-cipher/example.yaml +3 -3
  42. data/tracks/perl6/exercises/bob/example.yaml +4 -4
  43. data/tracks/perl6/exercises/clock/example.yaml +6 -6
  44. data/tracks/perl6/exercises/flatten-array/example.yaml +4 -4
  45. data/tracks/perl6/exercises/grade-school/example.yaml +6 -6
  46. data/tracks/perl6/exercises/grains/example.yaml +3 -3
  47. data/tracks/perl6/exercises/hello-world/example.yaml +5 -5
  48. data/tracks/perl6/exercises/leap/example.yaml +4 -4
  49. data/tracks/perl6/exercises/linked-list/example.yaml +14 -14
  50. data/tracks/perl6/exercises/luhn/example.yaml +3 -3
  51. data/tracks/perl6/exercises/phone-number/example.yaml +3 -3
  52. data/tracks/perl6/exercises/raindrops/example.yaml +3 -3
  53. data/tracks/perl6/exercises/rna-transcription/example.yaml +3 -3
  54. data/tracks/perl6/exercises/robot-name/example.yaml +8 -8
  55. data/tracks/perl6/exercises/scrabble-score/example.yaml +3 -3
  56. data/tracks/perl6/exercises/space-age/example.yaml +8 -8
  57. data/tracks/perl6/exercises/word-count/example.yaml +3 -3
  58. data/tracks/perl6/exercises/wordy/example.yaml +3 -3
  59. data/tracks/python/config.json +14 -0
  60. data/tracks/python/config/maintainers.json +30 -0
  61. data/tracks/python/docs/EXERCISE_README_INSERT.md +1 -2
  62. data/tracks/python/exercises/accumulate/README.md +1 -5
  63. data/tracks/python/exercises/acronym/README.md +1 -3
  64. data/tracks/python/exercises/all-your-base/README.md +2 -3
  65. data/tracks/python/exercises/all-your-base/all_your_base_test.py +13 -13
  66. data/tracks/python/exercises/allergies/README.md +1 -3
  67. data/tracks/python/exercises/alphametics/README.md +3 -4
  68. data/tracks/python/exercises/anagram/README.md +1 -2
  69. data/tracks/python/exercises/atbash-cipher/README.md +3 -3
  70. data/tracks/python/exercises/beer-song/README.md +2 -3
  71. data/tracks/python/exercises/binary-search/README.md +1 -2
  72. data/tracks/python/exercises/binary/README.md +3 -2
  73. data/tracks/python/exercises/bob/README.md +1 -2
  74. data/tracks/python/exercises/book-store/README.md +6 -7
  75. data/tracks/python/exercises/bracket-push/README.md +1 -2
  76. data/tracks/python/exercises/change/README.md +2 -3
  77. data/tracks/python/exercises/circular-buffer/README.md +14 -8
  78. data/tracks/python/exercises/clock/README.md +1 -2
  79. data/tracks/python/exercises/clock/clock_test.py +2 -0
  80. data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +3 -0
  81. data/tracks/python/exercises/collatz-conjecture/README.md +6 -19
  82. data/tracks/python/exercises/complex-numbers/README.md +28 -2
  83. data/tracks/python/exercises/crypto-square/README.md +11 -10
  84. data/tracks/python/exercises/diamond/README.md +7 -8
  85. data/tracks/python/exercises/difference-of-squares/README.md +1 -2
  86. data/tracks/python/exercises/diffie-hellman/.meta/hints.md +1 -1
  87. data/tracks/python/exercises/diffie-hellman/README.md +3 -2
  88. data/tracks/python/exercises/error-handling/.meta/hints.md +8 -0
  89. data/tracks/python/exercises/error-handling/README.md +10 -2
  90. data/tracks/python/exercises/error-handling/error_handling_test.py +15 -3
  91. data/tracks/python/exercises/etl/README.md +3 -2
  92. data/tracks/python/exercises/flatten-array/README.md +2 -4
  93. data/tracks/python/exercises/food-chain/README.md +3 -4
  94. data/tracks/python/exercises/forth/README.md +2 -6
  95. data/tracks/python/exercises/gigasecond/README.md +1 -2
  96. data/tracks/python/exercises/grade-school/README.md +1 -3
  97. data/tracks/python/exercises/grains/README.md +1 -3
  98. data/tracks/python/exercises/grep/README.md +13 -14
  99. data/tracks/python/exercises/hamming/README.md +1 -2
  100. data/tracks/python/exercises/hamming/hamming_test.py +6 -6
  101. data/tracks/python/exercises/hello-world/README.md +1 -2
  102. data/tracks/python/exercises/hexadecimal/README.md +1 -2
  103. data/tracks/python/exercises/hexadecimal/example.py +6 -6
  104. data/tracks/python/exercises/house/README.md +2 -4
  105. data/tracks/python/exercises/isogram/README.md +3 -3
  106. data/tracks/python/exercises/kindergarten-garden/README.md +14 -15
  107. data/tracks/python/exercises/largest-series-product/README.md +1 -2
  108. data/tracks/python/exercises/leap/README.md +2 -3
  109. data/tracks/python/exercises/linked-list/README.md +11 -12
  110. data/tracks/python/exercises/list-ops/README.md +1 -2
  111. data/tracks/python/exercises/luhn/README.md +8 -9
  112. data/tracks/python/exercises/markdown/README.md +1 -6
  113. data/tracks/python/exercises/matrix/README.md +7 -6
  114. data/tracks/python/exercises/meetup/README.md +2 -4
  115. data/tracks/python/exercises/minesweeper/README.md +1 -2
  116. data/tracks/python/exercises/nth-prime/README.md +1 -2
  117. data/tracks/python/exercises/nucleotide-count/README.md +9 -24
  118. data/tracks/python/exercises/ocr-numbers/README.md +6 -7
  119. data/tracks/python/exercises/octal/README.md +7 -4
  120. data/tracks/python/exercises/palindrome-products/README.md +16 -18
  121. data/tracks/python/exercises/pangram/README.md +2 -3
  122. data/tracks/python/exercises/pascals-triangle/README.md +2 -3
  123. data/tracks/python/exercises/perfect-numbers/README.md +3 -4
  124. data/tracks/python/exercises/phone-number/README.md +4 -4
  125. data/tracks/python/exercises/pig-latin/README.md +1 -2
  126. data/tracks/python/exercises/point-mutations/README.md +1 -2
  127. data/tracks/python/exercises/poker/README.md +1 -2
  128. data/tracks/python/exercises/prime-factors/README.md +1 -2
  129. data/tracks/python/exercises/protein-translation/README.md +5 -7
  130. data/tracks/python/exercises/proverb/README.md +12 -11
  131. data/tracks/python/exercises/pythagorean-triplet/README.md +4 -5
  132. data/tracks/python/exercises/queen-attack/README.md +2 -3
  133. data/tracks/python/exercises/rail-fence-cipher/README.md +13 -9
  134. data/tracks/python/exercises/raindrops/README.md +1 -2
  135. data/tracks/python/exercises/rectangles/README.md +8 -9
  136. data/tracks/python/exercises/rectangles/example.py +3 -3
  137. data/tracks/python/exercises/rna-transcription/README.md +1 -2
  138. data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +4 -3
  139. data/tracks/python/exercises/robot-name/README.md +1 -2
  140. data/tracks/python/exercises/robot-simulator/README.md +1 -2
  141. data/tracks/python/exercises/roman-numerals/README.md +2 -3
  142. data/tracks/python/exercises/rotational-cipher/README.md +3 -3
  143. data/tracks/python/exercises/run-length-encoding/README.md +5 -6
  144. data/tracks/python/exercises/run-length-encoding/example.py +2 -2
  145. data/tracks/python/exercises/saddle-points/README.md +2 -3
  146. data/tracks/python/exercises/say/README.md +1 -2
  147. data/tracks/python/exercises/scale-generator/README.md +1 -3
  148. data/tracks/python/exercises/scrabble-score/README.md +4 -3
  149. data/tracks/python/exercises/secret-handshake/README.md +2 -3
  150. data/tracks/python/exercises/series/README.md +1 -2
  151. data/tracks/python/exercises/sieve/README.md +1 -2
  152. data/tracks/python/exercises/simple-cipher/README.md +3 -4
  153. data/tracks/python/exercises/space-age/README.md +2 -3
  154. data/tracks/python/exercises/space-age/space_age_test.py +18 -29
  155. data/tracks/python/exercises/strain/README.md +1 -2
  156. data/tracks/python/exercises/sublist/README.md +1 -2
  157. data/tracks/python/exercises/sum-of-multiples/README.md +1 -5
  158. data/tracks/python/exercises/tournament/README.md +6 -7
  159. data/tracks/python/exercises/transpose/README.md +8 -9
  160. data/tracks/python/exercises/tree-building/README.md +25 -0
  161. data/tracks/python/exercises/tree-building/example.py +46 -0
  162. data/tracks/python/exercises/tree-building/tree_building.py +50 -0
  163. data/tracks/python/exercises/tree-building/tree_building_test.py +183 -0
  164. data/tracks/python/exercises/triangle/README.md +10 -8
  165. data/tracks/python/exercises/trinary/README.md +2 -3
  166. data/tracks/python/exercises/twelve-days/README.md +2 -3
  167. data/tracks/python/exercises/two-bucket/README.md +4 -5
  168. data/tracks/python/exercises/two-bucket/two_bucket_test.py +2 -0
  169. data/tracks/python/exercises/two-fer/README.md +4 -5
  170. data/tracks/python/exercises/two-fer/two_fer_test.py +5 -2
  171. data/tracks/python/exercises/variable-length-quantity/README.md +7 -9
  172. data/tracks/python/exercises/word-count/README.md +2 -4
  173. data/tracks/python/exercises/word-search/README.md +2 -3
  174. data/tracks/python/exercises/wordy/README.md +1 -7
  175. data/tracks/python/exercises/wordy/example.py +8 -8
  176. data/tracks/python/exercises/wordy/wordy_test.py +36 -32
  177. data/tracks/python/exercises/zebra-puzzle/README.md +1 -2
  178. data/tracks/python/requirements-travis.txt +1 -1
  179. data/tracks/ruby/config.json +11 -0
  180. data/tracks/ruby/docs/TESTS.md +6 -0
  181. data/tracks/ruby/exercises/pangram/.meta/.version +1 -1
  182. data/tracks/ruby/exercises/pangram/.meta/solutions/pangram.rb +1 -1
  183. data/tracks/ruby/exercises/pangram/pangram_test.rb +11 -4
  184. data/tracks/ruby/exercises/two-fer/.meta/.version +1 -0
  185. data/tracks/ruby/exercises/two-fer/.meta/generator/two_fer_case.rb +12 -0
  186. data/tracks/ruby/exercises/two-fer/.meta/solutions/two_fer.rb +9 -0
  187. data/tracks/ruby/exercises/two-fer/README.md +69 -0
  188. data/tracks/ruby/exercises/two-fer/two_fer_test.rb +42 -0
  189. data/tracks/rust/config.json +12 -0
  190. data/tracks/rust/exercises/binary-search/.meta/hints.md +38 -0
  191. data/tracks/rust/exercises/binary-search/Cargo.lock +4 -0
  192. data/tracks/rust/exercises/binary-search/Cargo.toml +6 -0
  193. data/tracks/rust/exercises/binary-search/README.md +113 -0
  194. data/tracks/rust/exercises/binary-search/example.rs +29 -0
  195. data/tracks/rust/exercises/binary-search/src/lib.rs +0 -0
  196. data/tracks/rust/exercises/binary-search/tests/binary-search.rs +96 -0
  197. data/tracks/typescript/common/package.json +6 -6
  198. data/tracks/typescript/common/yarn.lock +929 -610
  199. data/tracks/typescript/exercises/acronym/package.json +6 -6
  200. data/tracks/typescript/exercises/acronym/yarn.lock +929 -610
  201. data/tracks/typescript/exercises/anagram/package.json +6 -6
  202. data/tracks/typescript/exercises/anagram/yarn.lock +929 -610
  203. data/tracks/typescript/exercises/beer-song/package.json +6 -6
  204. data/tracks/typescript/exercises/beer-song/yarn.lock +929 -610
  205. data/tracks/typescript/exercises/binary-search-tree/package.json +6 -6
  206. data/tracks/typescript/exercises/binary-search-tree/yarn.lock +929 -610
  207. data/tracks/typescript/exercises/binary-search/package.json +6 -6
  208. data/tracks/typescript/exercises/binary-search/yarn.lock +929 -610
  209. data/tracks/typescript/exercises/bob/package.json +6 -6
  210. data/tracks/typescript/exercises/bob/yarn.lock +929 -610
  211. data/tracks/typescript/exercises/circular-buffer/package.json +6 -6
  212. data/tracks/typescript/exercises/circular-buffer/yarn.lock +929 -610
  213. data/tracks/typescript/exercises/clock/package.json +6 -6
  214. data/tracks/typescript/exercises/clock/yarn.lock +929 -610
  215. data/tracks/typescript/exercises/difference-of-squares/package.json +6 -6
  216. data/tracks/typescript/exercises/difference-of-squares/yarn.lock +929 -610
  217. data/tracks/typescript/exercises/etl/package.json +6 -6
  218. data/tracks/typescript/exercises/etl/yarn.lock +929 -610
  219. data/tracks/typescript/exercises/food-chain/package.json +6 -6
  220. data/tracks/typescript/exercises/food-chain/yarn.lock +929 -610
  221. data/tracks/typescript/exercises/gigasecond/package.json +6 -6
  222. data/tracks/typescript/exercises/gigasecond/yarn.lock +929 -610
  223. data/tracks/typescript/exercises/grade-school/package.json +6 -6
  224. data/tracks/typescript/exercises/grade-school/yarn.lock +929 -610
  225. data/tracks/typescript/exercises/hamming/package.json +6 -6
  226. data/tracks/typescript/exercises/hamming/yarn.lock +929 -610
  227. data/tracks/typescript/exercises/hello-world/README.md +354 -0
  228. data/tracks/typescript/exercises/hello-world/package.json +6 -6
  229. data/tracks/typescript/exercises/hello-world/yarn.lock +929 -610
  230. data/tracks/typescript/exercises/largest-series-product/package.json +6 -6
  231. data/tracks/typescript/exercises/largest-series-product/yarn.lock +929 -610
  232. data/tracks/typescript/exercises/leap/package.json +6 -6
  233. data/tracks/typescript/exercises/leap/yarn.lock +929 -610
  234. data/tracks/typescript/exercises/linked-list/package.json +6 -6
  235. data/tracks/typescript/exercises/linked-list/yarn.lock +929 -610
  236. data/tracks/typescript/exercises/nth-prime/package.json +6 -6
  237. data/tracks/typescript/exercises/nth-prime/yarn.lock +929 -610
  238. data/tracks/typescript/exercises/pangram/package.json +6 -6
  239. data/tracks/typescript/exercises/pangram/yarn.lock +929 -610
  240. data/tracks/typescript/exercises/pascals-triangle/package.json +6 -6
  241. data/tracks/typescript/exercises/pascals-triangle/yarn.lock +929 -610
  242. data/tracks/typescript/exercises/phone-number/package.json +6 -6
  243. data/tracks/typescript/exercises/phone-number/yarn.lock +929 -610
  244. data/tracks/typescript/exercises/prime-factors/package.json +6 -6
  245. data/tracks/typescript/exercises/prime-factors/yarn.lock +929 -610
  246. data/tracks/typescript/exercises/raindrops/package.json +6 -6
  247. data/tracks/typescript/exercises/raindrops/yarn.lock +929 -610
  248. data/tracks/typescript/exercises/rna-transcription/package.json +6 -6
  249. data/tracks/typescript/exercises/rna-transcription/yarn.lock +929 -610
  250. data/tracks/typescript/exercises/robot-name/package.json +6 -6
  251. data/tracks/typescript/exercises/robot-name/yarn.lock +929 -610
  252. data/tracks/typescript/exercises/robot-simulator/package.json +6 -6
  253. data/tracks/typescript/exercises/robot-simulator/yarn.lock +929 -610
  254. data/tracks/typescript/exercises/rotational-cipher/package.json +6 -6
  255. data/tracks/typescript/exercises/rotational-cipher/yarn.lock +929 -610
  256. data/tracks/typescript/exercises/say/package.json +6 -6
  257. data/tracks/typescript/exercises/say/yarn.lock +929 -610
  258. data/tracks/typescript/exercises/scrabble-score/package.json +6 -6
  259. data/tracks/typescript/exercises/scrabble-score/yarn.lock +929 -610
  260. data/tracks/typescript/exercises/series/package.json +6 -6
  261. data/tracks/typescript/exercises/series/yarn.lock +929 -610
  262. data/tracks/typescript/exercises/space-age/package.json +6 -6
  263. data/tracks/typescript/exercises/space-age/yarn.lock +929 -610
  264. data/tracks/typescript/exercises/strain/package.json +6 -6
  265. data/tracks/typescript/exercises/strain/yarn.lock +929 -610
  266. data/tracks/typescript/exercises/sum-of-multiples/package.json +6 -6
  267. data/tracks/typescript/exercises/sum-of-multiples/yarn.lock +929 -610
  268. data/tracks/typescript/exercises/triangle/package.json +6 -6
  269. data/tracks/typescript/exercises/triangle/yarn.lock +929 -610
  270. data/tracks/typescript/exercises/word-count/package.json +6 -6
  271. data/tracks/typescript/exercises/word-count/yarn.lock +929 -610
  272. data/tracks/typescript/exercises/wordy/package.json +6 -6
  273. data/tracks/typescript/exercises/wordy/yarn.lock +929 -610
  274. metadata +37 -2
@@ -3,20 +3,20 @@
3
3
  To try and encourage more sales of different books from a popular 5 book
4
4
  series, a bookshop has decided to offer discounts on multiple book purchases.
5
5
 
6
- One copy of any of the five books costs $8.
6
+ One copy of any of the five books costs $8.
7
7
 
8
8
  If, however, you buy two different books, you get a 5%
9
9
  discount on those two books.
10
10
 
11
- If you buy 3 different books, you get a 10% discount.
11
+ If you buy 3 different books, you get a 10% discount.
12
12
 
13
13
  If you buy 4 different books, you get a 20% discount.
14
14
 
15
- If you buy all 5, you get a 25% discount.
15
+ If you buy all 5, you get a 25% discount.
16
16
 
17
17
  Note: that if you buy four books, of which 3 are
18
18
  different titles, you get a 10% discount on the 3 that
19
- form part of a set, but the fourth book still costs $8.
19
+ form part of a set, but the fourth book still costs $8.
20
20
 
21
21
  Your mission is to write a piece of code to calculate the
22
22
  price of any conceivable shopping basket (containing only
@@ -30,7 +30,7 @@ For example, how much does this basket of books cost?
30
30
  - 2 copies of the third book
31
31
  - 1 copy of the fourth book
32
32
  - 1 copy of the fifth book
33
-
33
+
34
34
  One way of grouping these 8 books is:
35
35
 
36
36
  - 1 group of 5 --> 25% discount (1st,2nd,3rd,4th,5th)
@@ -67,13 +67,12 @@ For a total of $51.20
67
67
 
68
68
  And $51.20 is the price with the biggest discount.
69
69
 
70
- ### Submitting Exercises
70
+ ## Submitting Exercises
71
71
 
72
72
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
73
73
 
74
74
  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`.
75
75
 
76
-
77
76
  For more detailed information about running tests, code style and linting,
78
77
  please see the [help page](http://exercism.io/languages/python).
79
78
 
@@ -3,13 +3,12 @@
3
3
  Given a string containing brackets `[]`, braces `{}` and parentheses `()`,
4
4
  verify that all the pairs are matched and nested correctly.
5
5
 
6
- ### Submitting Exercises
6
+ ## Submitting Exercises
7
7
 
8
8
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
9
9
 
10
10
  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`.
11
11
 
12
-
13
12
  For more detailed information about running tests, code style and linting,
14
13
  please see the [help page](http://exercism.io/languages/python).
15
14
 
@@ -16,19 +16,18 @@ that the sum of the coins' value would equal the correct amount of change.
16
16
  - Can you ask for negative change?
17
17
  - Can you ask for a change value smaller than the smallest coin value?
18
18
 
19
- ### Submitting Exercises
19
+ ## Submitting Exercises
20
20
 
21
21
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
22
22
 
23
23
  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`.
24
24
 
25
-
26
25
  For more detailed information about running tests, code style and linting,
27
26
  please see the [help page](http://exercism.io/languages/python).
28
27
 
29
28
  ## Source
30
29
 
31
- Software Craftsmanship - Kata-logue [http://craftsmanship.sv.cmu.edu/exercises/coin-change-kata](http://craftsmanship.sv.cmu.edu/exercises/coin-change-kata)
30
+ Software Craftsmanship - Coin Change Kata [https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata](https://web.archive.org/web/20130115115225/http://craftsmanship.sv.cmu.edu:80/exercises/coin-change-kata)
32
31
 
33
32
  ## Submitting Incomplete Solutions
34
33
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -31,25 +31,31 @@ If the buffer has 7 elements then it is completely full:
31
31
  When the buffer is full an error will be raised, alerting the client
32
32
  that further writes are blocked until a slot becomes free.
33
33
 
34
- The client can opt to overwrite the oldest data with a forced write. In
35
- this case, two more elements — A & B — are added and they overwrite the
36
- 3 & 4:
34
+ When the buffer is full, the client can opt to overwrite the oldest
35
+ data with a forced write. In this case, two more elements — A & B —
36
+ are added and they overwrite the 3 & 4:
37
37
 
38
38
  [6][7][8][9][A][B][5]
39
39
 
40
- Finally, if two elements are now removed then what would be returned is
41
- not 3 & 4 but 5 & 6 because A & B overwrote the 3 & the 4 yielding the
42
- buffer with:
40
+ 3 & 4 have been replaced by A & B making 5 now the oldest data in the
41
+ buffer. Finally, if two elements are removed then what would be
42
+ returned is 5 & 6 yielding the buffer:
43
43
 
44
44
  [ ][7][8][9][A][B][ ]
45
45
 
46
- ### Submitting Exercises
46
+ Because there is space available, if the client again uses overwrite
47
+ to store C & D then the space where 5 & 6 were stored previously will
48
+ be used not the location of 7 & 8. 7 is still the oldest element and
49
+ the buffer is once again full.
50
+
51
+ [D][7][8][9][A][B][C]
52
+
53
+ ## Submitting Exercises
47
54
 
48
55
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
49
56
 
50
57
  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`.
51
58
 
52
-
53
59
  For more detailed information about running tests, code style and linting,
54
60
  please see the [help page](http://exercism.io/languages/python).
55
61
 
@@ -6,13 +6,12 @@ You should be able to add and subtract minutes to it.
6
6
 
7
7
  Two clocks that represent the same time should be equal to each other.
8
8
 
9
- ### Submitting Exercises
9
+ ## Submitting Exercises
10
10
 
11
11
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
12
12
 
13
13
  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`.
14
14
 
15
-
16
15
  For more detailed information about running tests, code style and linting,
17
16
  please see the [help page](http://exercism.io/languages/python).
18
17
 
@@ -2,6 +2,8 @@ import unittest
2
2
 
3
3
  from clock import Clock
4
4
 
5
+ # Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1
6
+
5
7
 
6
8
  class ClockTest(unittest.TestCase):
7
9
  # Test creating a new clock with an initial time.
@@ -0,0 +1,3 @@
1
+ ## Notes
2
+
3
+ The Collatz Conjecture is only concerned with strictly positive integers, so your solution should return `None` if given 0 or a negative integer.
@@ -9,25 +9,8 @@ always reach 1 eventually.
9
9
 
10
10
  Given a number n, return the number of steps required to reach 1.
11
11
 
12
- (Keep in mind that the Conjecture is only concerned with strictly positive
13
- integers, so your solution should return `None` if given 0 or a negative
14
- integer.)
15
-
16
12
  ## Examples
17
13
 
18
- Starting with n = 3, the steps would be as follows:
19
-
20
- 0. 3
21
- 1. 10
22
- 2. 5
23
- 3. 16
24
- 4. 8
25
- 5. 4
26
- 6. 2
27
- 7. 1
28
-
29
- Resulting in 7 steps. So for input n = 3, the return value would be 7.
30
-
31
14
  Starting with n = 12, the steps would be as follows:
32
15
 
33
16
  0. 12
@@ -43,13 +26,17 @@ Starting with n = 12, the steps would be as follows:
43
26
 
44
27
  Resulting in 9 steps. So for input n = 12, the return value would be 9.
45
28
 
46
- ### Submitting Exercises
29
+ ## Notes
30
+
31
+ The Collatz Conjecture is only concerned with strictly positive integers, so your solution should raise a `ValueError` with a meaningful message if given 0 or a negative integer.
32
+
33
+
34
+ ## Submitting Exercises
47
35
 
48
36
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
49
37
 
50
38
  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`.
51
39
 
52
-
53
40
  For more detailed information about running tests, code style and linting,
54
41
  please see the [help page](http://exercism.io/languages/python).
55
42
 
@@ -2,15 +2,41 @@
2
2
 
3
3
  A complex number is a number in the form `a + b * i` where `a` and `b` are real and `i` satisfies `i^2 = -1`.
4
4
 
5
+ `a` is called the real part and `b` is called the imaginary part of `z`.
6
+ The conjugate of the number `a + b * i` is the number `a - b * i`.
7
+ The absolute value of a complex number `z = a + b * i` is a real number `|z| = sqrt(a^2 + b^2)`. The square of the absolute value `|z|^2` is the result of multiplication of `z` by its complex conjugate.
8
+
9
+ The sum/difference of two complex numbers involves adding/subtracting their real and imaginary parts separately:
10
+ `(a + i * b) + (c + i * d) = (a + c) + (b + d) * i`,
11
+ `(a + i * b) - (c + i * d) = (a - c) + (b - d) * i`.
12
+
13
+ Multiplication result is by definition
14
+ `(a + i * b) * (c + i * d) = (a * c - b * d) + (b * c + a * d) * i`.
15
+
16
+ The reciprocal of a non-zero complex number is
17
+ `1 / (a + i * b) = a/(a^2 + b^2) - b/(a^2 + b^2) * i`.
18
+
19
+ Dividing a complex number `a + i * b` by another `c + i * d` gives:
20
+ `(a + i * b) / (c + i * d) = (a * c + b * d)/(c^2 + d^2) + (b * c - a * d)/(c^2 + d^2) * i`.
21
+
22
+ Exponent of a complex number can be expressed as
23
+ `exp(a + i * b) = exp(a) * exp(i * b)`,
24
+ and the last term is given by Euler's formula `exp(i * b) = cos(b) + i * sin(b)`.
25
+
26
+
27
+ Implement the following operations:
28
+ - addition, subtraction, multiplication and division of two complex numbers,
29
+ - conjugate, absolute value, exponent of a given complex number.
30
+
31
+
5
32
  Assume the programming language you are using does not have an implementation of complex numbers.
6
33
 
7
- ### Submitting Exercises
34
+ ## Submitting Exercises
8
35
 
9
36
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
10
37
 
11
38
  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`.
12
39
 
13
-
14
40
  For more detailed information about running tests, code style and linting,
15
41
  please see the [help page](http://exercism.io/languages/python).
16
42
 
@@ -26,7 +26,7 @@ and `r` is the number of rows.
26
26
  Our normalized text is 54 characters long, dictating a rectangle with
27
27
  `c = 8` and `r = 7`:
28
28
 
29
- ```plain
29
+ ```text
30
30
  ifmanwas
31
31
  meanttos
32
32
  tayonthe
@@ -41,22 +41,24 @@ right.
41
41
 
42
42
  The message above is coded as:
43
43
 
44
- ```plain
44
+ ```text
45
45
  imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau
46
46
  ```
47
47
 
48
- Output the encoded text in chunks. Phrases that fill perfect squares
49
- `(r X r)` should be output in `r`-length chunks separated by spaces.
50
- Imperfect squares will have `n` empty spaces. Those spaces should be distributed evenly across the last `n` rows.
48
+ Output the encoded text in chunks. Phrases that fill perfect rectangles
49
+ `(r X c)` should be output `c` chunks of `r` length, separated by spaces.
50
+ Phrases that do not fill perfect rectangles will have `n` empty spaces.
51
+ Those spaces should be distributed evenly, added to the end of the last
52
+ `n` chunks.
51
53
 
52
- ```plain
53
- imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau
54
+ ```text
55
+ imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau
54
56
  ```
55
57
 
56
58
  Notice that were we to stack these, we could visually decode the
57
59
  cyphertext back in to the original message:
58
60
 
59
- ```plain
61
+ ```text
60
62
  imtgdvs
61
63
  fearwer
62
64
  mayoogo
@@ -67,13 +69,12 @@ aohghn
67
69
  sseoau
68
70
  ```
69
71
 
70
- ### Submitting Exercises
72
+ ## Submitting Exercises
71
73
 
72
74
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
73
75
 
74
76
  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`.
75
77
 
76
-
77
78
  For more detailed information about running tests, code style and linting,
78
79
  please see the [help page](http://exercism.io/languages/python).
79
80
 
@@ -1,7 +1,7 @@
1
1
  # Diamond
2
2
 
3
- The diamond kata takes as its input a letter, and outputs it in a diamond
4
- shape. Given a letter, it prints a diamond starting with 'A', with the
3
+ The diamond kata takes as its input a letter, and outputs it in a diamond
4
+ shape. Given a letter, it prints a diamond starting with 'A', with the
5
5
  supplied letter at the widest point.
6
6
 
7
7
  ## Requirements
@@ -15,7 +15,7 @@ supplied letter at the widest point.
15
15
  * The diamond has a square shape (width equals height).
16
16
  * The letters form a diamond shape.
17
17
  * The top half has the letters in ascending order.
18
- * The bottom half has the letters in descending order.
18
+ * The bottom half has the letters in descending order.
19
19
  * The four corners (containing the spaces) are triangles.
20
20
 
21
21
  ## Examples
@@ -24,13 +24,13 @@ In the following examples, spaces are indicated by `·` characters.
24
24
 
25
25
  Diamond for letter 'A':
26
26
 
27
- ```plain
27
+ ```text
28
28
  A
29
29
  ```
30
30
 
31
31
  Diamond for letter 'C':
32
32
 
33
- ```plain
33
+ ```text
34
34
  ··A··
35
35
  ·B·B·
36
36
  C···C
@@ -40,7 +40,7 @@ C···C
40
40
 
41
41
  Diamond for letter 'E':
42
42
 
43
- ```plain
43
+ ```text
44
44
  ····A····
45
45
  ···B·B···
46
46
  ··C···C··
@@ -52,13 +52,12 @@ E·······E
52
52
  ····A····
53
53
  ```
54
54
 
55
- ### Submitting Exercises
55
+ ## Submitting Exercises
56
56
 
57
57
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
58
58
 
59
59
  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`.
60
60
 
61
-
62
61
  For more detailed information about running tests, code style and linting,
63
62
  please see the [help page](http://exercism.io/languages/python).
64
63
 
@@ -12,13 +12,12 @@ Hence the difference between the square of the sum of the first
12
12
  ten natural numbers and the sum of the squares of the first ten
13
13
  natural numbers is 3025 - 385 = 2640.
14
14
 
15
- ### Submitting Exercises
15
+ ## Submitting Exercises
16
16
 
17
17
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
18
18
 
19
19
  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`.
20
20
 
21
-
22
21
  For more detailed information about running tests, code style and linting,
23
22
  please see the [help page](http://exercism.io/languages/python).
24
23
 
@@ -13,4 +13,4 @@ For this reason, in version 3.6, Python introduced the `secrets` module, which g
13
13
  cryptographically strong random numbers that provide the greater security required for cryptography.
14
14
 
15
15
  Since this is only an exercise, `random` is fine to use, but note that **it would be
16
- very insecure if actually used for cryptography.**
16
+ very insecure if actually used for cryptography.**
@@ -54,15 +54,16 @@ cryptographically strong random numbers that provide the greater security requir
54
54
  Since this is only an exercise, `random` is fine to use, but note that **it would be
55
55
  very insecure if actually used for cryptography.**
56
56
 
57
- ### Submitting Exercises
57
+
58
+ ## Submitting Exercises
58
59
 
59
60
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
60
61
 
61
62
  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`.
62
63
 
63
-
64
64
  For more detailed information about running tests, code style and linting,
65
65
  please see the [help page](http://exercism.io/languages/python).
66
+
66
67
  ## Source
67
68
 
68
69
  Wikipedia, 1024 bit key from www.cryptopp.com/wiki. [http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange](http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange)
@@ -0,0 +1,8 @@
1
+ ## Hints
2
+
3
+ For the `filelike_objects_are_closed_on_exception` function, the `filelike_object`
4
+ will be an instance of a custom `FileLike` class defined in the test suite. This
5
+ class implements the following methods:
6
+ - `open` and `close`, for explicit opening and closing.
7
+ - `__enter__` and `__exit__`, for implicit opening and closing.
8
+ - `do_something`, which may or may not throw an `Exception`.
@@ -9,13 +9,21 @@ This exercise requires you to handle various errors. Because error handling
9
9
  is rather programming language specific you'll have to refer to the tests
10
10
  for your track to see what's exactly required.
11
11
 
12
- ### Submitting Exercises
12
+ ## Hints
13
+
14
+ For the `filelike_objects_are_closed_on_exception` function, the `filelike_object`
15
+ will be an instance of a custom `FileLike` class defined in the test suite. This
16
+ class implements the following methods:
17
+ - `open` and `close`, for explicit opening and closing.
18
+ - `__enter__` and `__exit__`, for implicit opening and closing.
19
+ - `do_something`, which may or may not throw an `Exception`.
20
+
21
+ ## Submitting Exercises
13
22
 
14
23
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
15
24
 
16
25
  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`.
17
26
 
18
-
19
27
  For more detailed information about running tests, code style and linting,
20
28
  please see the [help page](http://exercism.io/languages/python).
21
29
 
@@ -4,10 +4,11 @@ import error_handling as er
4
4
 
5
5
 
6
6
  class FileLike(object):
7
- def __init__(self):
7
+ def __init__(self, fail_something=True):
8
8
  self.is_open = False
9
9
  self.was_open = False
10
10
  self.did_something = False
11
+ self.fail_something = fail_something
11
12
 
12
13
  def open(self):
13
14
  self.was_open = False
@@ -26,7 +27,8 @@ class FileLike(object):
26
27
 
27
28
  def do_something(self):
28
29
  self.did_something = True
29
- raise Exception()
30
+ if self.fail_something:
31
+ raise Exception()
30
32
 
31
33
 
32
34
  class ErrorHandlingTest(unittest.TestCase):
@@ -51,7 +53,7 @@ class ErrorHandlingTest(unittest.TestCase):
51
53
  'Invalid input should not be successful')
52
54
 
53
55
  def test_filelike_objects_are_closed_on_exception(self):
54
- filelike_object = FileLike()
56
+ filelike_object = FileLike(fail_something=True)
55
57
  with self.assertRaises(Exception):
56
58
  er.filelike_objects_are_closed_on_exception(filelike_object)
57
59
  self.assertIs(filelike_object.is_open, False,
@@ -61,6 +63,16 @@ class ErrorHandlingTest(unittest.TestCase):
61
63
  self.assertIs(filelike_object.did_something, True,
62
64
  'filelike_object should call do_something()')
63
65
 
66
+ def test_filelike_objects_are_closed_without_exception(self):
67
+ filelike_object = FileLike(fail_something=False)
68
+ er.filelike_objects_are_closed_on_exception(filelike_object)
69
+ self.assertIs(filelike_object.is_open, False,
70
+ 'filelike_object should be closed')
71
+ self.assertIs(filelike_object.was_open, True,
72
+ 'filelike_object should have been opened')
73
+ self.assertIs(filelike_object.did_something, True,
74
+ 'filelike_object should call do_something()')
75
+
64
76
 
65
77
  if __name__ == '__main__':
66
78
  unittest.main()