trackler 2.2.1.59 → 2.2.1.60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/food-chain/canonical-data.json +31 -23
  4. data/problem-specifications/exercises/house/canonical-data.json +45 -33
  5. data/problem-specifications/exercises/house/description.md +1 -1
  6. data/problem-specifications/exercises/kindergarten-garden/description.md +3 -3
  7. data/problem-specifications/exercises/nucleotide-count/description.md +2 -2
  8. data/problem-specifications/exercises/palindrome-products/description.md +1 -1
  9. data/problem-specifications/exercises/rectangles/description.md +9 -9
  10. data/problem-specifications/exercises/twelve-days/canonical-data.json +171 -0
  11. data/problem-specifications/exercises/two-bucket/description.md +7 -7
  12. data/tracks/c/docs/CONTRIBUTING.md +88 -39
  13. data/tracks/c/exercises/phone-number/test/test_phone_number.c +33 -29
  14. data/tracks/c/exercises/triangle/src/example.c +12 -12
  15. data/tracks/c/exercises/triangle/src/example.h +3 -3
  16. data/tracks/c/exercises/triangle/test/test_triangle.c +16 -16
  17. data/tracks/c/exercises/word-count/src/example.c +12 -3
  18. data/tracks/c/exercises/word-count/src/word_count.h +10 -5
  19. data/tracks/c/exercises/word-count/test/test_word_count.c +248 -58
  20. data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +3 -3
  21. data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +2 -2
  22. data/tracks/dart/exercises/phone-number/README.md +1 -1
  23. data/tracks/dart/exercises/phone-number/test/phone_number_test.dart +5 -5
  24. data/tracks/gnu-apl/.dockerignore +5 -0
  25. data/tracks/gnu-apl/.travis.yml +9 -4
  26. data/tracks/gnu-apl/Dockerfiles/release.dockerfile +15 -0
  27. data/tracks/gnu-apl/Dockerfiles/svn.dockerfile +22 -0
  28. data/tracks/gnu-apl/README.md +1 -1
  29. data/tracks/gnu-apl/bin/install-apl +26 -0
  30. data/tracks/gnu-apl/test.apl +7 -6
  31. data/tracks/go/docs/TESTS.md +1 -1
  32. data/tracks/haskell/.travis.yml +1 -1
  33. data/tracks/haskell/config.json +9 -0
  34. data/tracks/haskell/exercises/accumulate/stack.yaml +1 -1
  35. data/tracks/haskell/exercises/acronym/package.yaml +1 -1
  36. data/tracks/haskell/exercises/acronym/stack.yaml +1 -1
  37. data/tracks/haskell/exercises/acronym/test/Tests.hs +3 -0
  38. data/tracks/haskell/exercises/all-your-base/stack.yaml +1 -1
  39. data/tracks/haskell/exercises/allergies/stack.yaml +1 -1
  40. data/tracks/haskell/exercises/alphametics/examples/success-standard/src/Alphametics.hs +2 -1
  41. data/tracks/haskell/exercises/alphametics/stack.yaml +1 -1
  42. data/tracks/haskell/exercises/anagram/stack.yaml +1 -1
  43. data/tracks/haskell/exercises/atbash-cipher/stack.yaml +1 -1
  44. data/tracks/haskell/exercises/bank-account/stack.yaml +1 -1
  45. data/tracks/haskell/exercises/beer-song/stack.yaml +1 -1
  46. data/tracks/haskell/exercises/binary-search-tree/stack.yaml +1 -1
  47. data/tracks/haskell/exercises/binary/stack.yaml +1 -1
  48. data/tracks/haskell/exercises/bob/stack.yaml +1 -1
  49. data/tracks/haskell/exercises/bowling/stack.yaml +1 -1
  50. data/tracks/haskell/exercises/bracket-push/stack.yaml +1 -1
  51. data/tracks/haskell/exercises/change/stack.yaml +1 -1
  52. data/tracks/haskell/exercises/clock/stack.yaml +1 -1
  53. data/tracks/haskell/exercises/collatz-conjecture/stack.yaml +1 -1
  54. data/tracks/haskell/exercises/complex-numbers/stack.yaml +1 -1
  55. data/tracks/haskell/exercises/connect/stack.yaml +1 -1
  56. data/tracks/haskell/exercises/crypto-square/package.yaml +1 -1
  57. data/tracks/haskell/exercises/crypto-square/stack.yaml +1 -1
  58. data/tracks/haskell/exercises/crypto-square/test/Tests.hs +9 -5
  59. data/tracks/haskell/exercises/custom-set/package.yaml +1 -1
  60. data/tracks/haskell/exercises/custom-set/stack.yaml +1 -1
  61. data/tracks/haskell/exercises/custom-set/test/Tests.hs +3 -0
  62. data/tracks/haskell/exercises/diamond/stack.yaml +1 -1
  63. data/tracks/haskell/exercises/difference-of-squares/stack.yaml +1 -1
  64. data/tracks/haskell/exercises/dominoes/README.md +3 -3
  65. data/tracks/haskell/exercises/dominoes/stack.yaml +1 -1
  66. data/tracks/haskell/exercises/etl/stack.yaml +1 -1
  67. data/tracks/haskell/exercises/food-chain/stack.yaml +1 -1
  68. data/tracks/haskell/exercises/forth/stack.yaml +1 -1
  69. data/tracks/haskell/exercises/gigasecond/stack.yaml +1 -1
  70. data/tracks/haskell/exercises/go-counting/stack.yaml +1 -1
  71. data/tracks/haskell/exercises/grade-school/stack.yaml +1 -1
  72. data/tracks/haskell/exercises/grains/stack.yaml +1 -1
  73. data/tracks/haskell/exercises/hamming/package.yaml +1 -1
  74. data/tracks/haskell/exercises/hamming/stack.yaml +1 -1
  75. data/tracks/haskell/exercises/hamming/test/Tests.hs +4 -4
  76. data/tracks/haskell/exercises/hello-world/stack.yaml +1 -1
  77. data/tracks/haskell/exercises/hexadecimal/stack.yaml +1 -1
  78. data/tracks/haskell/exercises/house/README.md +1 -1
  79. data/tracks/haskell/exercises/house/stack.yaml +1 -1
  80. data/tracks/haskell/exercises/isbn-verifier/README.md +96 -0
  81. data/tracks/haskell/exercises/isbn-verifier/examples/success-standard/package.yaml +16 -0
  82. data/tracks/haskell/exercises/isbn-verifier/examples/success-standard/src/IsbnVerifier.hs +10 -0
  83. data/tracks/haskell/exercises/isbn-verifier/package.yaml +20 -0
  84. data/tracks/haskell/exercises/isbn-verifier/src/IsbnVerifier.hs +4 -0
  85. data/tracks/haskell/exercises/isbn-verifier/stack.yaml +1 -0
  86. data/tracks/haskell/exercises/isbn-verifier/test/Tests.hs +74 -0
  87. data/tracks/haskell/exercises/isogram/stack.yaml +1 -1
  88. data/tracks/haskell/exercises/kindergarten-garden/README.md +3 -3
  89. data/tracks/haskell/exercises/kindergarten-garden/stack.yaml +1 -1
  90. data/tracks/haskell/exercises/largest-series-product/stack.yaml +1 -1
  91. data/tracks/haskell/exercises/leap/package.yaml +1 -1
  92. data/tracks/haskell/exercises/leap/stack.yaml +1 -1
  93. data/tracks/haskell/exercises/leap/test/Tests.hs +1 -1
  94. data/tracks/haskell/exercises/lens-person/stack.yaml +1 -1
  95. data/tracks/haskell/exercises/linked-list/stack.yaml +1 -1
  96. data/tracks/haskell/exercises/list-ops/stack.yaml +1 -1
  97. data/tracks/haskell/exercises/luhn/stack.yaml +1 -1
  98. data/tracks/haskell/exercises/matrix/stack.yaml +1 -1
  99. data/tracks/haskell/exercises/meetup/stack.yaml +1 -1
  100. data/tracks/haskell/exercises/minesweeper/stack.yaml +1 -1
  101. data/tracks/haskell/exercises/nth-prime/package.yaml +1 -1
  102. data/tracks/haskell/exercises/nth-prime/stack.yaml +1 -1
  103. data/tracks/haskell/exercises/nucleotide-count/README.md +2 -2
  104. data/tracks/haskell/exercises/nucleotide-count/package.yaml +1 -1
  105. data/tracks/haskell/exercises/nucleotide-count/stack.yaml +1 -1
  106. data/tracks/haskell/exercises/nucleotide-count/test/Tests.hs +6 -0
  107. data/tracks/haskell/exercises/ocr-numbers/stack.yaml +1 -1
  108. data/tracks/haskell/exercises/octal/stack.yaml +1 -1
  109. data/tracks/haskell/exercises/palindrome-products/README.md +1 -1
  110. data/tracks/haskell/exercises/palindrome-products/stack.yaml +1 -1
  111. data/tracks/haskell/exercises/pangram/package.yaml +1 -1
  112. data/tracks/haskell/exercises/pangram/stack.yaml +1 -1
  113. data/tracks/haskell/exercises/pangram/test/Tests.hs +6 -2
  114. data/tracks/haskell/exercises/parallel-letter-frequency/stack.yaml +1 -1
  115. data/tracks/haskell/exercises/pascals-triangle/stack.yaml +1 -1
  116. data/tracks/haskell/exercises/perfect-numbers/stack.yaml +1 -1
  117. data/tracks/haskell/exercises/phone-number/README.md +1 -1
  118. data/tracks/haskell/exercises/phone-number/stack.yaml +1 -1
  119. data/tracks/haskell/exercises/pig-latin/stack.yaml +1 -1
  120. data/tracks/haskell/exercises/pov/stack.yaml +1 -1
  121. data/tracks/haskell/exercises/prime-factors/stack.yaml +1 -1
  122. data/tracks/haskell/exercises/pythagorean-triplet/stack.yaml +1 -1
  123. data/tracks/haskell/exercises/queen-attack/stack.yaml +1 -1
  124. data/tracks/haskell/exercises/raindrops/stack.yaml +1 -1
  125. data/tracks/haskell/exercises/rna-transcription/stack.yaml +1 -1
  126. data/tracks/haskell/exercises/robot-name/stack.yaml +1 -1
  127. data/tracks/haskell/exercises/robot-simulator/stack.yaml +1 -1
  128. data/tracks/haskell/exercises/roman-numerals/stack.yaml +1 -1
  129. data/tracks/haskell/exercises/rotational-cipher/stack.yaml +1 -1
  130. data/tracks/haskell/exercises/run-length-encoding/stack.yaml +1 -1
  131. data/tracks/haskell/exercises/saddle-points/stack.yaml +1 -1
  132. data/tracks/haskell/exercises/say/stack.yaml +1 -1
  133. data/tracks/haskell/exercises/scrabble-score/stack.yaml +1 -1
  134. data/tracks/haskell/exercises/secret-handshake/stack.yaml +1 -1
  135. data/tracks/haskell/exercises/series/stack.yaml +1 -1
  136. data/tracks/haskell/exercises/sgf-parsing/stack.yaml +1 -1
  137. data/tracks/haskell/exercises/sieve/stack.yaml +1 -1
  138. data/tracks/haskell/exercises/simple-cipher/stack.yaml +1 -1
  139. data/tracks/haskell/exercises/simple-linked-list/stack.yaml +1 -1
  140. data/tracks/haskell/exercises/space-age/stack.yaml +1 -1
  141. data/tracks/haskell/exercises/spiral-matrix/stack.yaml +1 -1
  142. data/tracks/haskell/exercises/strain/stack.yaml +1 -1
  143. data/tracks/haskell/exercises/sublist/stack.yaml +1 -1
  144. data/tracks/haskell/exercises/sum-of-multiples/stack.yaml +1 -1
  145. data/tracks/haskell/exercises/triangle/stack.yaml +1 -1
  146. data/tracks/haskell/exercises/trinary/stack.yaml +1 -1
  147. data/tracks/haskell/exercises/word-count/stack.yaml +1 -1
  148. data/tracks/haskell/exercises/wordy/examples/success-standard/src/WordProblem.hs +6 -5
  149. data/tracks/haskell/exercises/wordy/stack.yaml +1 -1
  150. data/tracks/haskell/exercises/zebra-puzzle/package.yaml +1 -1
  151. data/tracks/haskell/exercises/zebra-puzzle/stack.yaml +1 -1
  152. data/tracks/haskell/exercises/zipper/README.md +1 -1
  153. data/tracks/haskell/exercises/zipper/stack.yaml +1 -1
  154. data/tracks/javascript/.eslintignore +43 -0
  155. data/tracks/javascript/.travis.yml +2 -1
  156. data/tracks/javascript/exercises/bowling/README.md +5 -5
  157. data/tracks/javascript/exercises/crypto-square/example.js +2 -1
  158. data/tracks/javascript/exercises/diffie-hellman/diffie-hellman.spec.js +20 -20
  159. data/tracks/javascript/exercises/diffie-hellman/example.js +10 -10
  160. data/tracks/javascript/exercises/largest-series-product/example.js +2 -1
  161. data/tracks/javascript/exercises/sieve/example.js +5 -2
  162. data/tracks/javascript/package-lock.json +129 -76
  163. data/tracks/javascript/package.json +6 -5
  164. data/tracks/ocaml/config.json +10 -0
  165. data/tracks/ocaml/exercises/hamming/test.ml +3 -3
  166. data/tracks/ocaml/exercises/leap/test.ml +2 -2
  167. data/tracks/ocaml/exercises/pangram/test.ml +3 -3
  168. data/tracks/ocaml/exercises/rectangles/.merlin +5 -0
  169. data/tracks/ocaml/exercises/rectangles/Makefile +11 -0
  170. data/tracks/ocaml/exercises/rectangles/example.ml +30 -0
  171. data/tracks/ocaml/exercises/rectangles/rectangles.mli +1 -0
  172. data/tracks/ocaml/exercises/rectangles/test.ml +72 -0
  173. data/tracks/ocaml/tools/test-generator/templates/ocaml/leap/test.ml +1 -1
  174. data/tracks/ocaml/tools/test-generator/templates/ocaml/rectangles/test.ml +15 -0
  175. data/tracks/pony/README.md +1 -1
  176. data/tracks/pony/exercises/atbash-cipher/example.pony +6 -10
  177. data/tracks/pony/exercises/difference-of-squares/example.pony +3 -7
  178. data/tracks/rust/_test/count-ignores.sh +2 -2
  179. data/tracks/rust/config.json +24 -0
  180. data/tracks/rust/config/maintainers.json +10 -0
  181. data/tracks/rust/exercises/acronym/README.md +0 -1
  182. data/tracks/rust/exercises/all-your-base/README.md +1 -1
  183. data/tracks/rust/exercises/allergies/README.md +0 -1
  184. data/tracks/rust/exercises/alphametics/README.md +2 -2
  185. data/tracks/rust/exercises/atbash-cipher/README.md +2 -1
  186. data/tracks/rust/exercises/beer-song/README.md +1 -1
  187. data/tracks/rust/exercises/bowling/README.md +20 -6
  188. data/tracks/rust/exercises/circular-buffer/README.md +13 -6
  189. data/tracks/rust/exercises/crypto-square/README.md +10 -8
  190. data/tracks/rust/exercises/dominoes/Cargo.toml +1 -1
  191. data/tracks/rust/exercises/etl/README.md +2 -0
  192. data/tracks/rust/exercises/grade-school/README.md +0 -1
  193. data/tracks/rust/exercises/grains/README.md +0 -1
  194. data/tracks/rust/exercises/isbn-verifier/Cargo.lock +4 -0
  195. data/tracks/rust/exercises/isbn-verifier/Cargo.toml +3 -0
  196. data/tracks/rust/exercises/isbn-verifier/README.md +74 -0
  197. data/tracks/rust/exercises/isbn-verifier/example.rs +44 -0
  198. data/tracks/rust/exercises/isbn-verifier/src/lib.rs +4 -0
  199. data/tracks/rust/exercises/isbn-verifier/tests/isbn-verifier.rs +83 -0
  200. data/tracks/rust/exercises/isogram/README.md +3 -2
  201. data/tracks/rust/exercises/leap/README.md +1 -1
  202. data/tracks/rust/exercises/luhn/README.md +7 -7
  203. data/tracks/rust/exercises/nucleotide-count/README.md +8 -22
  204. data/tracks/rust/exercises/ocr-numbers/README.md +5 -5
  205. data/tracks/rust/exercises/pangram/README.md +1 -1
  206. data/tracks/rust/exercises/pascals-triangle/README.md +1 -1
  207. data/tracks/rust/exercises/perfect-numbers/README.md +2 -2
  208. data/tracks/rust/exercises/phone-number/README.md +3 -2
  209. data/tracks/rust/exercises/protein-translation/README.md +4 -5
  210. data/tracks/rust/exercises/proverb/README.md +13 -11
  211. data/tracks/rust/exercises/proverb/example.rs +14 -15
  212. data/tracks/rust/exercises/proverb/tests/proverb.rs +40 -13
  213. data/tracks/rust/exercises/pythagorean-triplet/README.md +3 -3
  214. data/tracks/rust/exercises/queen-attack/README.md +1 -1
  215. data/tracks/rust/exercises/rectangles/README.md +7 -7
  216. data/tracks/rust/exercises/roman-numerals/README.md +1 -1
  217. data/tracks/rust/exercises/rotational-cipher/README.md +2 -1
  218. data/tracks/rust/exercises/run-length-encoding/README.md +4 -4
  219. data/tracks/rust/exercises/scrabble-score/README.md +3 -1
  220. data/tracks/rust/exercises/space-age/README.md +1 -1
  221. data/tracks/rust/exercises/tournament/README.md +5 -5
  222. data/tracks/rust/exercises/triangle/README.md +9 -6
  223. data/tracks/rust/exercises/two-bucket/Cargo.lock +4 -0
  224. data/tracks/rust/exercises/two-bucket/Cargo.toml +3 -0
  225. data/tracks/rust/exercises/two-bucket/README.md +69 -0
  226. data/tracks/rust/exercises/two-bucket/example.rs +129 -0
  227. data/tracks/rust/exercises/two-bucket/src/lib.rs +26 -0
  228. data/tracks/rust/exercises/two-bucket/tests/two-bucket.rs +68 -0
  229. data/tracks/rust/exercises/variable-length-quantity/README.md +6 -7
  230. data/tracks/rust/exercises/word-count/README.md +1 -2
  231. data/tracks/rust/exercises/wordy/README.md +0 -5
  232. metadata +33 -4
  233. data/tracks/go/.github/PULL_REQUEST_TEMPLATE.md +0 -23
  234. data/tracks/ruby/.github/PULL_REQUEST_TEMPLATE.md +0 -40
@@ -2,23 +2,26 @@
2
2
 
3
3
  Determine if a triangle is equilateral, isosceles, or scalene.
4
4
 
5
- An _equilateral_ triangle has all three sides the same length.<br/>
5
+ An _equilateral_ triangle has all three sides the same length.
6
+
6
7
  An _isosceles_ triangle has at least two sides the same length. (It is sometimes
7
8
  specified as having exactly two sides the same length, but for the purposes of
8
- this exercise we'll say at least two.)<br/>
9
+ this exercise we'll say at least two.)
10
+
9
11
  A _scalene_ triangle has all sides of different lengths.
10
12
 
11
13
  ## Note
12
14
 
13
- For a shape to be a triangle at all, all sides have to be of length > 0, and
14
- the sum of the lengths of any two sides must be greater than or equal to the
15
+ For a shape to be a triangle at all, all sides have to be of length > 0, and
16
+ the sum of the lengths of any two sides must be greater than or equal to the
15
17
  length of the third side. See [Triangle Inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
16
18
 
17
19
  ## Dig Deeper
18
20
 
19
- The case where the sum of the lengths of two sides _equals_ that of the
20
- third is known as a _degenerate_ triangle - it has zero area and looks like
21
+ The case where the sum of the lengths of two sides _equals_ that of the
22
+ third is known as a _degenerate_ triangle - it has zero area and looks like
21
23
  a single line. Feel free to add your own code/tests to check for degenerate triangles.
24
+
22
25
  # Triangle in Rust
23
26
 
24
27
  - [Result](https://doc.rust-lang.org/std/result/index.html)
@@ -0,0 +1,4 @@
1
+ [root]
2
+ name = "two-bucket"
3
+ version = "1.0.0"
4
+
@@ -0,0 +1,3 @@
1
+ [package]
2
+ name = "two-bucket"
3
+ version = "1.0.0"
@@ -0,0 +1,69 @@
1
+ # Two Bucket
2
+
3
+ Given two buckets of different size, demonstrate how to measure an exact number of liters by strategically transferring liters of fluid between the buckets.
4
+
5
+ Since this mathematical problem is fairly subject to interpretation / individual approach, the tests have been written specifically to expect one overarching solution.
6
+
7
+ To help, the tests provide you with which bucket to fill first. That means, when starting with the larger bucket full, you are NOT allowed at any point to have the smaller bucket full and the larger bucket empty (aka, the opposite starting point); that would defeat the purpose of comparing both approaches!
8
+
9
+ Your program will take as input:
10
+ - the size of bucket one, passed as a numeric value
11
+ - the size of bucket two, passed as a numeric value
12
+ - the desired number of liters to reach, passed as a numeric value
13
+ - which bucket to fill first, passed as a Bucket (either Bucket::One or Bucket::Two)
14
+
15
+ Your program should determine:
16
+ - the total number of "moves" it should take to reach the desired number of liters, including the first fill - expects a numeric value
17
+ - which bucket should end up with the desired number of liters (let's say this is bucket A) - expects a Bucket (either Bucket::One or Bucket::Two)
18
+ - how many liters are left in the other bucket (bucket B) - expects a numeric value
19
+
20
+ Note: any time a change is made to either or both buckets counts as one (1) move.
21
+
22
+ Example:
23
+ Bucket one can hold up to 7 liters, and bucket two can hold up to 11 liters. Let's say bucket one, at a given step, is holding 7 liters, and bucket two is holding 8 liters (7,8). If you empty bucket one and make no change to bucket two, leaving you with 0 liters and 8 liters respectively (0,8), that counts as one "move". Instead, if you had poured from bucket one into bucket two until bucket two was full, leaving you with 4 liters in bucket one and 11 liters in bucket two (4,11), that would count as only one "move" as well.
24
+
25
+ To conclude, the only valid moves are:
26
+ - pouring from one bucket to another
27
+ - emptying one bucket and doing nothing to the other
28
+ - filling one bucket and doing nothing to the other
29
+
30
+ Written with <3 at [Fullstack Academy](http://www.fullstackacademy.com/) by [Lindsay](http://lindsaylevine.com).
31
+
32
+ ## Rust Installation
33
+
34
+ Refer to the [exercism help page][help-page] for Rust installation and learning
35
+ resources.
36
+
37
+ ## Writing the Code
38
+
39
+ Execute the tests with:
40
+
41
+ ```bash
42
+ $ cargo test
43
+ ```
44
+
45
+ All but the first test have been ignored. After you get the first test to
46
+ pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
47
+ to pass again. The test file is located in the `tests` directory. You can
48
+ also remove the ignore flag from all the tests to get them to run all at once
49
+ if you wish.
50
+
51
+ Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
52
+ haven't already, it will help you with organizing your files.
53
+
54
+ ## Feedback, Issues, Pull Requests
55
+
56
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
57
+
58
+ If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
59
+
60
+ [help-page]: http://exercism.io/languages/rust
61
+ [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
62
+ [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
63
+
64
+ ## Source
65
+
66
+ Water Pouring Problem [http://demonstrations.wolfram.com/WaterPouringProblem/](http://demonstrations.wolfram.com/WaterPouringProblem/)
67
+
68
+ ## Submitting Incomplete Solutions
69
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,129 @@
1
+ use std::collections::{HashSet, VecDeque};
2
+
3
+ // We can turn this problem into a simple graph searching problem. Each move represents an
4
+ // edge in our graph; the buckets' fill states form the graph's vertices. For example, say bucket
5
+ // one holds up to 7 liters, and bucket two holds up to 11 liters, and at the current step, bucket
6
+ // one has 7 liters and bucket two has 8 liters: (7, 8). By emptying the first bucket, we form an
7
+ // edge (7, 8) -> (0, 8). Similarly, by pouring the first bucket into the second, we form an edge
8
+ // (7, 8) -> (4, 11).
9
+ //
10
+ // Since we want to minimize the number of moves, we search the graph breadth-first, starting with
11
+ // the configuration provided as the problem input. Note that, to avoid cheating, we mark both
12
+ // possible starting configurations as visited; otherwise, our search might just empty the initial
13
+ // bucket and fill the other one.
14
+
15
+ #[derive(PartialEq, Eq, Debug)]
16
+ pub enum Bucket {
17
+ One,
18
+ Two
19
+ }
20
+
21
+ /// A struct to hold your results in.
22
+ #[derive(PartialEq, Eq, Debug)]
23
+ pub struct BucketStats {
24
+ /// The total number of "moves" it should take to reach the desired number of liters, including
25
+ /// the first fill.
26
+ pub moves: u8,
27
+ /// Which bucket should end up with the desired number of liters? (Either "one" or "two")
28
+ pub goal_bucket: Bucket,
29
+ /// How many liters are left in the other bucket?
30
+ pub other_bucket: u8,
31
+ }
32
+
33
+ /// Solve the bucket problem
34
+ pub fn solve(capacity_1: u8,
35
+ capacity_2: u8,
36
+ goal: u8,
37
+ start_bucket: &Bucket) -> BucketStats
38
+ {
39
+ let state = match *start_bucket {
40
+ Bucket::One => (capacity_1, 0),
41
+ Bucket::Two => (0, capacity_2),
42
+ };
43
+
44
+ let mut next_search = VecDeque::new();
45
+ let mut visited = HashSet::new();
46
+ let mut moves = 1;
47
+
48
+ next_search.push_front(state);
49
+
50
+ // "Visit" both starting states. This will ensure that we don't cheat, i.e.
51
+ // empty our starting bucket completely and fill the other bucket.
52
+ visited.insert((capacity_1, 0));
53
+ visited.insert((0, capacity_2));
54
+
55
+ loop {
56
+ let mut current_search = next_search;
57
+ next_search = VecDeque::new();
58
+
59
+ for state in current_search.drain(0..) {
60
+ let (bucket_1, bucket_2) = state;
61
+
62
+ if bucket_1 == goal {
63
+ return BucketStats {
64
+ moves: moves,
65
+ goal_bucket: Bucket::One,
66
+ other_bucket: bucket_2,
67
+ };
68
+ } else if bucket_2 == goal {
69
+ return BucketStats {
70
+ moves: moves,
71
+ goal_bucket: Bucket::Two,
72
+ other_bucket: bucket_1,
73
+ };
74
+ }
75
+
76
+ // Empty the first bucket
77
+ let empty_1 = (0, bucket_2);
78
+ if !visited.contains(&empty_1) {
79
+ next_search.push_front(empty_1);
80
+ visited.insert(empty_1);
81
+ }
82
+
83
+ // Empty the second bucket
84
+ let empty_2 = (bucket_1, 0);
85
+ if !visited.contains(&empty_2) {
86
+ next_search.push_front(empty_2);
87
+ visited.insert(empty_2);
88
+ }
89
+
90
+ // Fill the first bucket
91
+ let fill_1 = (capacity_1, bucket_2);
92
+ if !visited.contains(&fill_1) {
93
+ next_search.push_front(fill_1);
94
+ visited.insert(fill_1);
95
+ }
96
+
97
+ // Fill the second bucket
98
+ let fill_2 = (bucket_1, capacity_2);
99
+ if !visited.contains(&fill_2) {
100
+ next_search.push_front(fill_2);
101
+ visited.insert(fill_2);
102
+ }
103
+
104
+ // Pour the first bucket into the second bucket
105
+ let pour_1_into_2 = if bucket_1 + bucket_2 <= capacity_1 {
106
+ (bucket_1 + bucket_2, 0)
107
+ } else {
108
+ (capacity_1, bucket_1 + bucket_2 - capacity_1)
109
+ };
110
+ if !visited.contains(&pour_1_into_2) {
111
+ next_search.push_front(pour_1_into_2);
112
+ visited.insert(pour_1_into_2);
113
+ }
114
+
115
+ // Pour the second bucket into the first bucket
116
+ let pour_2_into_1 = if bucket_1 + bucket_2 <= capacity_2 {
117
+ (0, bucket_1 + bucket_2)
118
+ } else {
119
+ (bucket_1 + bucket_2 - capacity_2, capacity_2)
120
+ };
121
+ if !visited.contains(&pour_2_into_1) {
122
+ next_search.push_front(pour_2_into_1);
123
+ visited.insert(pour_2_into_1);
124
+ }
125
+ }
126
+
127
+ moves += 1;
128
+ }
129
+ }
@@ -0,0 +1,26 @@
1
+ #[derive(PartialEq, Eq, Debug)]
2
+ pub enum Bucket {
3
+ One,
4
+ Two
5
+ }
6
+
7
+ /// A struct to hold your results in.
8
+ #[derive(PartialEq, Eq, Debug)]
9
+ pub struct BucketStats {
10
+ /// The total number of "moves" it should take to reach the desired number of liters, including
11
+ /// the first fill.
12
+ pub moves: u8,
13
+ /// Which bucket should end up with the desired number of liters? (Either "one" or "two")
14
+ pub goal_bucket: Bucket,
15
+ /// How many liters are left in the other bucket?
16
+ pub other_bucket: u8,
17
+ }
18
+
19
+ /// Solve the bucket problem
20
+ pub fn solve(capacity_1: u8,
21
+ capacity_2: u8,
22
+ goal: u8,
23
+ start_bucket: &Bucket) -> BucketStats
24
+ {
25
+ unimplemented!();
26
+ }
@@ -0,0 +1,68 @@
1
+ extern crate two_bucket;
2
+
3
+ use two_bucket::{solve, BucketStats, Bucket};
4
+
5
+ #[test]
6
+ fn test_case_1() {
7
+ assert_eq!(solve(3, 5, 1, &Bucket::One),
8
+ BucketStats {
9
+ moves: 4,
10
+ goal_bucket: Bucket::One,
11
+ other_bucket: 5,
12
+ });
13
+ }
14
+
15
+ #[test]
16
+ #[ignore]
17
+ fn test_case_2() {
18
+ assert_eq!(solve(3, 5, 1, &Bucket::Two),
19
+ BucketStats {
20
+ moves: 8,
21
+ goal_bucket: Bucket::Two,
22
+ other_bucket: 3,
23
+ });
24
+ }
25
+
26
+ #[test]
27
+ #[ignore]
28
+ fn test_case_3() {
29
+ assert_eq!(solve(7, 11, 2, &Bucket::One),
30
+ BucketStats {
31
+ moves: 14,
32
+ goal_bucket: Bucket::One,
33
+ other_bucket: 11,
34
+ });
35
+ }
36
+
37
+ #[test]
38
+ #[ignore]
39
+ fn test_case_4() {
40
+ assert_eq!(solve(7, 11, 2, &Bucket::Two),
41
+ BucketStats {
42
+ moves: 18,
43
+ goal_bucket: Bucket::Two,
44
+ other_bucket: 7,
45
+ });
46
+ }
47
+
48
+ #[test]
49
+ #[ignore]
50
+ fn test_case_5() {
51
+ assert_eq!(solve(1, 3, 3, &Bucket::Two),
52
+ BucketStats {
53
+ moves: 1,
54
+ goal_bucket: Bucket::Two,
55
+ other_bucket: 0,
56
+ });
57
+ }
58
+
59
+ #[test]
60
+ #[ignore]
61
+ fn test_case_6() {
62
+ assert_eq!(solve(2, 3, 3, &Bucket::One),
63
+ BucketStats {
64
+ moves: 2,
65
+ goal_bucket: Bucket::Two,
66
+ other_bucket: 2,
67
+ });
68
+ }
@@ -5,18 +5,17 @@ Implement variable length quantity encoding and decoding.
5
5
  The goal of this exercise is to implement [VLQ](https://en.wikipedia.org/wiki/Variable-length_quantity) encoding/decoding.
6
6
 
7
7
  In short, the goal of this encoding is to encode integer values in a way that would save bytes.
8
- Only the first 7 bits of each byte is significant (right-justified; sort of like an ASCII byte).
9
- So, if you have a 32-bit value, you have to unpack it into a series of 7-bit bytes.
10
- Of course, you will have a variable number of bytes depending upon your integer.
8
+ Only the first 7 bits of each byte is significant (right-justified; sort of like an ASCII byte).
9
+ So, if you have a 32-bit value, you have to unpack it into a series of 7-bit bytes.
10
+ Of course, you will have a variable number of bytes depending upon your integer.
11
11
  To indicate which is the last byte of the series, you leave bit #7 clear.
12
- In all of the preceding bytes, you set bit #7.
12
+ In all of the preceding bytes, you set bit #7.
13
13
 
14
- So, if an integer is between `0-127`, it can be represented as one byte.
14
+ So, if an integer is between `0-127`, it can be represented as one byte.
15
15
  Although VLQ can deal with numbers of arbitrary sizes, for this exercise we will restrict ourselves to only numbers that fit in a 32-bit unsigned integer.
16
16
  Here are examples of integers as 32-bit values, and the variable length quantities that they translate to:
17
17
 
18
-
19
- ```
18
+ ```text
20
19
  NUMBER VARIABLE QUANTITY
21
20
  00000000 00
22
21
  00000040 40
@@ -4,14 +4,13 @@ Given a phrase, count the occurrences of each word in that phrase.
4
4
 
5
5
  For example for the input `"olly olly in come free"`
6
6
 
7
- ```plain
7
+ ```text
8
8
  olly: 2
9
9
  in: 1
10
10
  come: 1
11
11
  free: 1
12
12
  ```
13
13
 
14
-
15
14
  ## Rust Installation
16
15
 
17
16
  Refer to the [exercism help page][help-page] for Rust installation and learning
@@ -2,7 +2,6 @@
2
2
 
3
3
  Parse and evaluate simple math word problems returning the answer as an integer.
4
4
 
5
-
6
5
  ## Iteration 1 — Addition
7
6
 
8
7
  Add two numbers together.
@@ -13,7 +12,6 @@ Evaluates to 18.
13
12
 
14
13
  Handle large numbers and negative numbers.
15
14
 
16
-
17
15
  ## Iteration 2 — Subtraction, Multiplication and Division
18
16
 
19
17
  Now, perform the other three operations.
@@ -30,7 +28,6 @@ Now, perform the other three operations.
30
28
 
31
29
  5
32
30
 
33
-
34
31
  ## Iteration 3 — Multiple Operations
35
32
 
36
33
  Handle a set of operations, in sequence.
@@ -46,7 +43,6 @@ left-to-right, _ignoring the typical order of operations._
46
43
 
47
44
  15 (i.e. not 9)
48
45
 
49
-
50
46
  ## Bonus — Exponentials
51
47
 
52
48
  If you'd like, handle exponentials.
@@ -55,7 +51,6 @@ If you'd like, handle exponentials.
55
51
 
56
52
  32
57
53
 
58
-
59
54
  ## Rust Installation
60
55
 
61
56
  Refer to the [exercism help page][help-page] for Rust installation and learning
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.59
4
+ version: 2.2.1.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-02 00:00:00.000000000 Z
11
+ date: 2017-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -544,6 +544,7 @@ files:
544
544
  - problem-specifications/exercises/trinary/canonical-data.json
545
545
  - problem-specifications/exercises/trinary/description.md
546
546
  - problem-specifications/exercises/trinary/metadata.yml
547
+ - problem-specifications/exercises/twelve-days/canonical-data.json
547
548
  - problem-specifications/exercises/twelve-days/description.md
548
549
  - problem-specifications/exercises/twelve-days/metadata.yml
549
550
  - problem-specifications/exercises/two-bucket/canonical-data.json
@@ -5547,13 +5548,17 @@ files:
5547
5548
  - tracks/fsharp/generators/Templates/_TestMethod.liquid
5548
5549
  - tracks/fsharp/generators/Templates/_TestMethodBody.liquid
5549
5550
  - tracks/fsharp/img/icon.png
5551
+ - tracks/gnu-apl/.dockerignore
5550
5552
  - tracks/gnu-apl/.git
5551
5553
  - tracks/gnu-apl/.gitignore
5552
5554
  - tracks/gnu-apl/.travis.yml
5553
5555
  - tracks/gnu-apl/.travis/.gnu-apl/preferences
5556
+ - tracks/gnu-apl/Dockerfiles/release.dockerfile
5557
+ - tracks/gnu-apl/Dockerfiles/svn.dockerfile
5554
5558
  - tracks/gnu-apl/LICENSE
5555
5559
  - tracks/gnu-apl/README.md
5556
5560
  - tracks/gnu-apl/bin/fetch-configlet
5561
+ - tracks/gnu-apl/bin/install-apl
5557
5562
  - tracks/gnu-apl/bin/run-all-tests
5558
5563
  - tracks/gnu-apl/config.json
5559
5564
  - tracks/gnu-apl/config/exercise-readme-insert.md
@@ -5589,7 +5594,6 @@ files:
5589
5594
  - tracks/gnu-apl/img/.keep
5590
5595
  - tracks/gnu-apl/test.apl
5591
5596
  - tracks/go/.git
5592
- - tracks/go/.github/PULL_REQUEST_TEMPLATE.md
5593
5597
  - tracks/go/.gitignore
5594
5598
  - tracks/go/.travis.yml
5595
5599
  - tracks/go/LICENSE
@@ -6390,6 +6394,13 @@ files:
6390
6394
  - tracks/haskell/exercises/house/src/House.hs
6391
6395
  - tracks/haskell/exercises/house/stack.yaml
6392
6396
  - tracks/haskell/exercises/house/test/Tests.hs
6397
+ - tracks/haskell/exercises/isbn-verifier/README.md
6398
+ - tracks/haskell/exercises/isbn-verifier/examples/success-standard/package.yaml
6399
+ - tracks/haskell/exercises/isbn-verifier/examples/success-standard/src/IsbnVerifier.hs
6400
+ - tracks/haskell/exercises/isbn-verifier/package.yaml
6401
+ - tracks/haskell/exercises/isbn-verifier/src/IsbnVerifier.hs
6402
+ - tracks/haskell/exercises/isbn-verifier/stack.yaml
6403
+ - tracks/haskell/exercises/isbn-verifier/test/Tests.hs
6393
6404
  - tracks/haskell/exercises/isogram/README.md
6394
6405
  - tracks/haskell/exercises/isogram/examples/success-standard/package.yaml
6395
6406
  - tracks/haskell/exercises/isogram/examples/success-standard/src/Isogram.hs
@@ -7423,6 +7434,7 @@ files:
7423
7434
  - tracks/java/scripts/insert-ignores.sh
7424
7435
  - tracks/java/scripts/prune-extra-keep-files.sh
7425
7436
  - tracks/javascript/.editorconfig
7437
+ - tracks/javascript/.eslintignore
7426
7438
  - tracks/javascript/.eslintrc.json
7427
7439
  - tracks/javascript/.git
7428
7440
  - tracks/javascript/.github/stale.yml
@@ -9352,6 +9364,11 @@ files:
9352
9364
  - tracks/ocaml/exercises/react/example.ml
9353
9365
  - tracks/ocaml/exercises/react/react.mli
9354
9366
  - tracks/ocaml/exercises/react/test.ml
9367
+ - tracks/ocaml/exercises/rectangles/.merlin
9368
+ - tracks/ocaml/exercises/rectangles/Makefile
9369
+ - tracks/ocaml/exercises/rectangles/example.ml
9370
+ - tracks/ocaml/exercises/rectangles/rectangles.mli
9371
+ - tracks/ocaml/exercises/rectangles/test.ml
9355
9372
  - tracks/ocaml/exercises/rna-transcription/.merlin
9356
9373
  - tracks/ocaml/exercises/rna-transcription/Makefile
9357
9374
  - tracks/ocaml/exercises/rna-transcription/README.md
@@ -9454,6 +9471,7 @@ files:
9454
9471
  - tracks/ocaml/tools/test-generator/templates/ocaml/phone-number/test.ml
9455
9472
  - tracks/ocaml/tools/test-generator/templates/ocaml/prime-factors/test.ml
9456
9473
  - tracks/ocaml/tools/test-generator/templates/ocaml/raindrops/test.ml
9474
+ - tracks/ocaml/tools/test-generator/templates/ocaml/rectangles/test.ml
9457
9475
  - tracks/ocaml/tools/test-generator/templates/ocaml/roman-numerals/test.ml
9458
9476
  - tracks/ocaml/tools/test-generator/templates/ocaml/run-length-encoding/test.ml
9459
9477
  - tracks/ocaml/tools/test-generator/templates/ocaml/say/test.ml
@@ -11122,7 +11140,6 @@ files:
11122
11140
  - tracks/racket/img/icon.png
11123
11141
  - tracks/ruby/.git
11124
11142
  - tracks/ruby/.github/ISSUE_TEMPLATE.md
11125
- - tracks/ruby/.github/PULL_REQUEST_TEMPLATE.md
11126
11143
  - tracks/ruby/.github/stale.yml
11127
11144
  - tracks/ruby/.gitignore
11128
11145
  - tracks/ruby/.rubocop.yml
@@ -11813,6 +11830,12 @@ files:
11813
11830
  - tracks/rust/exercises/hexadecimal/example.rs
11814
11831
  - tracks/rust/exercises/hexadecimal/src/lib.rs
11815
11832
  - tracks/rust/exercises/hexadecimal/tests/hexadecimal.rs
11833
+ - tracks/rust/exercises/isbn-verifier/Cargo.lock
11834
+ - tracks/rust/exercises/isbn-verifier/Cargo.toml
11835
+ - tracks/rust/exercises/isbn-verifier/README.md
11836
+ - tracks/rust/exercises/isbn-verifier/example.rs
11837
+ - tracks/rust/exercises/isbn-verifier/src/lib.rs
11838
+ - tracks/rust/exercises/isbn-verifier/tests/isbn-verifier.rs
11816
11839
  - tracks/rust/exercises/isogram/.gitignore
11817
11840
  - tracks/rust/exercises/isogram/Cargo.toml
11818
11841
  - tracks/rust/exercises/isogram/README.md
@@ -12097,6 +12120,12 @@ files:
12097
12120
  - tracks/rust/exercises/triangle/float_example.rs
12098
12121
  - tracks/rust/exercises/triangle/src/lib.rs
12099
12122
  - tracks/rust/exercises/triangle/tests/triangle.rs
12123
+ - tracks/rust/exercises/two-bucket/Cargo.lock
12124
+ - tracks/rust/exercises/two-bucket/Cargo.toml
12125
+ - tracks/rust/exercises/two-bucket/README.md
12126
+ - tracks/rust/exercises/two-bucket/example.rs
12127
+ - tracks/rust/exercises/two-bucket/src/lib.rs
12128
+ - tracks/rust/exercises/two-bucket/tests/two-bucket.rs
12100
12129
  - tracks/rust/exercises/variable-length-quantity/.gitignore
12101
12130
  - tracks/rust/exercises/variable-length-quantity/Cargo.lock
12102
12131
  - tracks/rust/exercises/variable-length-quantity/Cargo.toml