trackler 2.2.1.171 → 2.2.1.172

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/go/exercises/dominoes/.meta/gen.go +1 -1
  4. data/tracks/go/exercises/dominoes/cases_test.go +11 -11
  5. data/tracks/ocaml/config.json +1 -1
  6. data/tracks/ocaml/docs/ABOUT.md +6 -4
  7. data/tracks/powershell/config.json +3 -2
  8. data/tracks/rust/bin/format_exercises +31 -0
  9. data/tracks/rust/config.json +10 -2
  10. data/tracks/rust/config/exercise_readme.go.tmpl +26 -5
  11. data/tracks/rust/exercises/accumulate/README.md +26 -5
  12. data/tracks/rust/exercises/accumulate/src/lib.rs +1 -0
  13. data/tracks/rust/exercises/accumulate/tests/accumulate.rs +7 -7
  14. data/tracks/rust/exercises/acronym/README.md +26 -5
  15. data/tracks/rust/exercises/acronym/src/lib.rs +1 -0
  16. data/tracks/rust/exercises/acronym/tests/acronym.rs +10 -5
  17. data/tracks/rust/exercises/all-your-base/README.md +26 -5
  18. data/tracks/rust/exercises/all-your-base/src/lib.rs +6 -1
  19. data/tracks/rust/exercises/all-your-base/tests/all-your-base.rs +68 -34
  20. data/tracks/rust/exercises/allergies/README.md +26 -5
  21. data/tracks/rust/exercises/allergies/src/lib.rs +1 -0
  22. data/tracks/rust/exercises/allergies/tests/allergies.rs +34 -26
  23. data/tracks/rust/exercises/alphametics/README.md +26 -5
  24. data/tracks/rust/exercises/alphametics/tests/alphametics.rs +44 -9
  25. data/tracks/rust/exercises/anagram/README.md +26 -5
  26. data/tracks/rust/exercises/anagram/src/lib.rs +1 -0
  27. data/tracks/rust/exercises/anagram/tests/anagram.rs +15 -4
  28. data/tracks/rust/exercises/armstrong-numbers/README.md +26 -5
  29. data/tracks/rust/exercises/atbash-cipher/README.md +26 -5
  30. data/tracks/rust/exercises/atbash-cipher/src/lib.rs +1 -1
  31. data/tracks/rust/exercises/atbash-cipher/tests/atbash-cipher.rs +16 -8
  32. data/tracks/rust/exercises/beer-song/README.md +26 -5
  33. data/tracks/rust/exercises/binary-search/README.md +26 -5
  34. data/tracks/rust/exercises/binary-search/src/lib.rs +1 -0
  35. data/tracks/rust/exercises/binary-search/tests/binary-search.rs +8 -4
  36. data/tracks/rust/exercises/bob/README.md +26 -5
  37. data/tracks/rust/exercises/bob/tests/bob.rs +32 -15
  38. data/tracks/rust/exercises/book-store/README.md +26 -5
  39. data/tracks/rust/exercises/book-store/src/lib.rs +4 -1
  40. data/tracks/rust/exercises/book-store/tests/book-store.rs +52 -24
  41. data/tracks/rust/exercises/bowling/README.md +26 -5
  42. data/tracks/rust/exercises/bowling/src/lib.rs +1 -2
  43. data/tracks/rust/exercises/bowling/tests/bowling.rs +2 -1
  44. data/tracks/rust/exercises/bracket-push/README.md +29 -7
  45. data/tracks/rust/exercises/bracket-push/src/lib.rs +1 -0
  46. data/tracks/rust/exercises/circular-buffer/README.md +26 -5
  47. data/tracks/rust/exercises/circular-buffer/src/lib.rs +1 -0
  48. data/tracks/rust/exercises/clock/README.md +26 -5
  49. data/tracks/rust/exercises/clock/src/lib.rs +1 -0
  50. data/tracks/rust/exercises/clock/tests/clock.rs +0 -1
  51. data/tracks/rust/exercises/collatz-conjecture/README.md +26 -5
  52. data/tracks/rust/exercises/crypto-square/README.md +53 -29
  53. data/tracks/rust/exercises/custom-set/README.md +26 -5
  54. data/tracks/rust/exercises/custom-set/src/lib.rs +1 -0
  55. data/tracks/rust/exercises/decimal/README.md +26 -5
  56. data/tracks/rust/exercises/decimal/tests/decimal.rs +4 -7
  57. data/tracks/rust/exercises/diamond/README.md +26 -5
  58. data/tracks/rust/exercises/difference-of-squares/README.md +26 -5
  59. data/tracks/rust/exercises/difference-of-squares/src/lib.rs +1 -1
  60. data/tracks/rust/exercises/diffie-hellman/README.md +26 -5
  61. data/tracks/rust/exercises/diffie-hellman/src/lib.rs +12 -2
  62. data/tracks/rust/exercises/diffie-hellman/tests/diffie-hellman.rs +3 -3
  63. data/tracks/rust/exercises/dominoes/README.md +26 -5
  64. data/tracks/rust/exercises/dominoes/src/lib.rs +1 -0
  65. data/tracks/rust/exercises/dominoes/tests/dominoes.rs +29 -13
  66. data/tracks/rust/exercises/etl/README.md +26 -5
  67. data/tracks/rust/exercises/etl/src/lib.rs +1 -0
  68. data/tracks/rust/exercises/etl/tests/etl.rs +39 -34
  69. data/tracks/rust/exercises/forth/README.md +26 -5
  70. data/tracks/rust/exercises/forth/tests/forth.rs +17 -65
  71. data/tracks/rust/exercises/gigasecond/README.md +26 -5
  72. data/tracks/rust/exercises/gigasecond/tests/gigasecond.rs +31 -10
  73. data/tracks/rust/exercises/grade-school/README.md +26 -5
  74. data/tracks/rust/exercises/grade-school/src/lib.rs +1 -2
  75. data/tracks/rust/exercises/grade-school/tests/grade-school.rs +5 -9
  76. data/tracks/rust/exercises/grains/README.md +26 -5
  77. data/tracks/rust/exercises/hamming/README.md +30 -8
  78. data/tracks/rust/exercises/hamming/src/lib.rs +1 -2
  79. data/tracks/rust/exercises/hello-world/README.md +26 -5
  80. data/tracks/rust/exercises/hexadecimal/README.md +26 -5
  81. data/tracks/rust/exercises/hexadecimal/src/lib.rs +1 -0
  82. data/tracks/rust/exercises/isbn-verifier/README.md +26 -5
  83. data/tracks/rust/exercises/isogram/README.md +26 -5
  84. data/tracks/rust/exercises/isogram/src/lib.rs +1 -1
  85. data/tracks/rust/exercises/isogram/tests/isogram.rs +36 -24
  86. data/tracks/rust/exercises/largest-series-product/README.md +26 -5
  87. data/tracks/rust/exercises/largest-series-product/src/lib.rs +5 -1
  88. data/tracks/rust/exercises/largest-series-product/tests/largest-series-product.rs +4 -2
  89. data/tracks/rust/exercises/leap/README.md +26 -5
  90. data/tracks/rust/exercises/luhn-from/README.md +26 -5
  91. data/tracks/rust/exercises/luhn-from/src/lib.rs +1 -0
  92. data/tracks/rust/exercises/luhn-trait/README.md +26 -5
  93. data/tracks/rust/exercises/luhn-trait/src/lib.rs +1 -0
  94. data/tracks/rust/exercises/luhn/README.md +26 -5
  95. data/tracks/rust/exercises/luhn/src/lib.rs +1 -1
  96. data/tracks/rust/exercises/macros/README.md +26 -5
  97. data/tracks/rust/exercises/minesweeper/README.md +26 -5
  98. data/tracks/rust/exercises/minesweeper/src/lib.rs +1 -0
  99. data/tracks/rust/exercises/nth-prime/README.md +26 -5
  100. data/tracks/rust/exercises/nucleotide-codons/README.md +26 -5
  101. data/tracks/rust/exercises/nucleotide-codons/src/lib.rs +1 -0
  102. data/tracks/rust/exercises/nucleotide-codons/tests/codons.rs +6 -5
  103. data/tracks/rust/exercises/nucleotide-count/README.md +26 -5
  104. data/tracks/rust/exercises/nucleotide-count/src/lib.rs +1 -0
  105. data/tracks/rust/exercises/nucleotide-count/tests/nucleotide-count.rs +5 -8
  106. data/tracks/rust/exercises/ocr-numbers/README.md +26 -5
  107. data/tracks/rust/exercises/ocr-numbers/tests/ocr-numbers.rs +0 -1
  108. data/tracks/rust/exercises/palindrome-products/README.md +26 -5
  109. data/tracks/rust/exercises/pangram/README.md +26 -5
  110. data/tracks/rust/exercises/pangram/src/lib.rs +1 -1
  111. data/tracks/rust/exercises/parallel-letter-frequency/README.md +26 -5
  112. data/tracks/rust/exercises/parallel-letter-frequency/benches/benchmark.rs +6 -3
  113. data/tracks/rust/exercises/parallel-letter-frequency/src/lib.rs +1 -0
  114. data/tracks/rust/exercises/parallel-letter-frequency/tests/parallel-letter-frequency.rs +6 -3
  115. data/tracks/rust/exercises/pascals-triangle/README.md +26 -5
  116. data/tracks/rust/exercises/pascals-triangle/tests/pascals-triangle.rs +36 -28
  117. data/tracks/rust/exercises/perfect-numbers/README.md +26 -5
  118. data/tracks/rust/exercises/perfect-numbers/src/lib.rs +1 -1
  119. data/tracks/rust/exercises/perfect-numbers/tests/perfect-numbers.rs +1 -2
  120. data/tracks/rust/exercises/phone-number/README.md +26 -5
  121. data/tracks/rust/exercises/phone-number/src/lib.rs +1 -0
  122. data/tracks/rust/exercises/pig-latin/README.md +26 -5
  123. data/tracks/rust/exercises/pig-latin/src/lib.rs +1 -0
  124. data/tracks/rust/exercises/poker/README.md +26 -5
  125. data/tracks/rust/exercises/poker/tests/poker.rs +27 -104
  126. data/tracks/rust/exercises/prime-factors/README.md +26 -5
  127. data/tracks/rust/exercises/protein-translation/README.md +26 -5
  128. data/tracks/rust/exercises/protein-translation/src/lib.rs +1 -0
  129. data/tracks/rust/exercises/protein-translation/tests/proteins.rs +16 -9
  130. data/tracks/rust/exercises/proverb/README.md +26 -5
  131. data/tracks/rust/exercises/proverb/tests/proverb.rs +1 -7
  132. data/tracks/rust/exercises/pythagorean-triplet/README.md +26 -5
  133. data/tracks/rust/exercises/queen-attack/README.md +26 -5
  134. data/tracks/rust/exercises/queen-attack/src/lib.rs +1 -0
  135. data/tracks/rust/exercises/raindrops/README.md +26 -5
  136. data/tracks/rust/exercises/raindrops/tests/raindrops.rs +57 -19
  137. data/tracks/rust/exercises/react/README.md +26 -5
  138. data/tracks/rust/exercises/react/src/lib.rs +16 -4
  139. data/tracks/rust/exercises/react/tests/react.rs +174 -43
  140. data/tracks/rust/exercises/rectangles/README.md +26 -5
  141. data/tracks/rust/exercises/rectangles/src/lib.rs +1 -0
  142. data/tracks/rust/exercises/reverse-string/README.md +26 -5
  143. data/tracks/rust/exercises/reverse-string/tests/reverse-string.rs +2 -11
  144. data/tracks/rust/exercises/rna-transcription/README.md +26 -5
  145. data/tracks/rust/exercises/rna-transcription/src/lib.rs +1 -0
  146. data/tracks/rust/exercises/robot-name/README.md +26 -5
  147. data/tracks/rust/exercises/robot-name/src/lib.rs +1 -0
  148. data/tracks/rust/exercises/robot-name/tests/robot-name.rs +8 -2
  149. data/tracks/rust/exercises/robot-simulator/README.md +26 -5
  150. data/tracks/rust/exercises/robot-simulator/src/lib.rs +5 -6
  151. data/tracks/rust/exercises/roman-numerals/README.md +26 -5
  152. data/tracks/rust/exercises/roman-numerals/src/lib.rs +1 -0
  153. data/tracks/rust/exercises/rotational-cipher/README.md +26 -5
  154. data/tracks/rust/exercises/rotational-cipher/src/lib.rs +1 -0
  155. data/tracks/rust/exercises/rotational-cipher/tests/rotational-cipher.rs +12 -4
  156. data/tracks/rust/exercises/run-length-encoding/README.md +26 -5
  157. data/tracks/rust/exercises/run-length-encoding/src/lib.rs +1 -1
  158. data/tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs +12 -5
  159. data/tracks/rust/exercises/saddle-points/README.md +26 -5
  160. data/tracks/rust/exercises/saddle-points/src/lib.rs +4 -1
  161. data/tracks/rust/exercises/say/README.md +27 -6
  162. data/tracks/rust/exercises/say/src/lib.rs +1 -1
  163. data/tracks/rust/exercises/say/tests/say.rs +30 -14
  164. data/tracks/rust/exercises/scrabble-score/README.md +26 -5
  165. data/tracks/rust/exercises/scrabble-score/src/lib.rs +1 -1
  166. data/tracks/rust/exercises/series/README.md +32 -11
  167. data/tracks/rust/exercises/series/src/lib.rs +5 -1
  168. data/tracks/rust/exercises/sieve/README.md +31 -8
  169. data/tracks/rust/exercises/sieve/src/lib.rs +1 -0
  170. data/tracks/rust/exercises/sieve/tests/sieve.rs +11 -12
  171. data/tracks/rust/exercises/simple-cipher/README.md +26 -5
  172. data/tracks/rust/exercises/simple-cipher/src/lib.rs +6 -3
  173. data/tracks/rust/exercises/simple-cipher/tests/simple-cipher.rs +0 -1
  174. data/tracks/rust/exercises/simple-linked-list/README.md +26 -5
  175. data/tracks/rust/exercises/simple-linked-list/src/lib.rs +0 -1
  176. data/tracks/rust/exercises/simple-linked-list/tests/simple-linked-list.rs +0 -1
  177. data/tracks/rust/exercises/space-age/README.md +26 -5
  178. data/tracks/rust/exercises/space-age/tests/space-age.rs +4 -4
  179. data/tracks/rust/exercises/spiral-matrix/README.md +26 -5
  180. data/tracks/rust/exercises/sublist/README.md +26 -5
  181. data/tracks/rust/exercises/sublist/src/lib.rs +1 -0
  182. data/tracks/rust/exercises/sublist/tests/sublist.rs +17 -68
  183. data/tracks/rust/exercises/sum-of-multiples/README.md +26 -5
  184. data/tracks/rust/exercises/sum-of-multiples/src/lib.rs +5 -1
  185. data/tracks/rust/exercises/tournament/README.md +26 -5
  186. data/tracks/rust/exercises/tournament/src/lib.rs +1 -0
  187. data/tracks/rust/exercises/tournament/tests/tournament.rs +60 -60
  188. data/tracks/rust/exercises/triangle/README.md +26 -5
  189. data/tracks/rust/exercises/triangle/src/lib.rs +1 -0
  190. data/tracks/rust/exercises/two-bucket/README.md +26 -5
  191. data/tracks/rust/exercises/two-bucket/src/lib.rs +2 -6
  192. data/tracks/rust/exercises/two-bucket/tests/two-bucket.rs +49 -37
  193. data/tracks/rust/exercises/twofer/README.md +33 -7
  194. data/tracks/rust/exercises/twofer/src/lib.rs +2 -2
  195. data/tracks/rust/exercises/twofer/tests/two-fer.rs +2 -2
  196. data/tracks/rust/exercises/variable-length-quantity/README.md +26 -5
  197. data/tracks/rust/exercises/variable-length-quantity/tests/variable-length-quantity.rs +60 -32
  198. data/tracks/rust/exercises/word-count/README.md +26 -5
  199. data/tracks/rust/exercises/word-count/src/lib.rs +1 -1
  200. data/tracks/rust/exercises/word-count/tests/word-count.rs +15 -23
  201. data/tracks/rust/exercises/wordy/README.md +26 -5
  202. data/tracks/rust/exercises/wordy/src/lib.rs +1 -0
  203. metadata +3 -2
@@ -74,7 +74,8 @@ pub const ODE_AN_DIE_FREUDE: [&'static str; 8] = [
74
74
  "Deine Zauber binden wieder",
75
75
  "Was die Mode streng geteilt;",
76
76
  "Alle Menschen werden Brüder,",
77
- "Wo dein sanfter Flügel weilt."];
77
+ "Wo dein sanfter Flügel weilt.",
78
+ ];
78
79
 
79
80
  // Dutch national anthem
80
81
  pub const WILHELMUS: [&'static str; 8] = [
@@ -85,7 +86,8 @@ pub const WILHELMUS: [&'static str; 8] = [
85
86
  "Een Prinse van Oranje",
86
87
  "ben ik, vrij, onverveerd,",
87
88
  "den Koning van Hispanje",
88
- "heb ik altijd geëerd."];
89
+ "heb ik altijd geëerd.",
90
+ ];
89
91
 
90
92
  // American national anthem
91
93
  pub const STAR_SPANGLED_BANNER: [&'static str; 8] = [
@@ -96,4 +98,5 @@ pub const STAR_SPANGLED_BANNER: [&'static str; 8] = [
96
98
  "And the rockets' red glare, the bombs bursting in air,",
97
99
  "Gave proof through the night that our flag was still there;",
98
100
  "O say does that star-spangled banner yet wave,",
99
- "O'er the land of the free and the home of the brave?"];
101
+ "O'er the land of the free and the home of the brave?",
102
+ ];
@@ -11,7 +11,8 @@ const ODE_AN_DIE_FREUDE: [&'static str; 8] = [
11
11
  "Deine Zauber binden wieder",
12
12
  "Was die Mode streng geteilt;",
13
13
  "Alle Menschen werden Brüder,",
14
- "Wo dein sanfter Flügel weilt."];
14
+ "Wo dein sanfter Flügel weilt.",
15
+ ];
15
16
 
16
17
  // Dutch national anthem
17
18
  const WILHELMUS: [&'static str; 8] = [
@@ -22,7 +23,8 @@ const WILHELMUS: [&'static str; 8] = [
22
23
  "Een Prinse van Oranje",
23
24
  "ben ik, vrij, onverveerd,",
24
25
  "den Koning van Hispanje",
25
- "heb ik altijd geëerd."];
26
+ "heb ik altijd geëerd.",
27
+ ];
26
28
 
27
29
  // American national anthem
28
30
  const STAR_SPANGLED_BANNER: [&'static str; 8] = [
@@ -33,7 +35,8 @@ const STAR_SPANGLED_BANNER: [&'static str; 8] = [
33
35
  "And the rockets' red glare, the bombs bursting in air,",
34
36
  "Gave proof through the night that our flag was still there;",
35
37
  "O say does that star-spangled banner yet wave,",
36
- "O'er the land of the free and the home of the brave?"];
38
+ "O'er the land of the free and the home of the brave?",
39
+ ];
37
40
 
38
41
  #[test]
39
42
  fn test_no_texts() {
@@ -27,11 +27,31 @@ Execute the tests with:
27
27
  $ cargo test
28
28
  ```
29
29
 
30
- All but the first test have been ignored. After you get the first test to
31
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
32
- to pass again. The test file is located in the `tests` directory. You can
33
- also remove the ignore flag from all the tests to get them to run all at once
34
- if you wish.
30
+ All but the first test have been ignored. After you get the first test to
31
+ pass, open the tests source file wich is located in the `tests` directory
32
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
33
+ again. Each separate test is a function with `#[test]` flag above it.
34
+ Continue, until you pass every test.
35
+
36
+ If you wish to run all tests without editing the tests source file, use:
37
+
38
+ ```bash
39
+ $ cargo test -- --ignored
40
+ ```
41
+
42
+ To run a specific test, for example `some_test`, you can use:
43
+
44
+ ```bash
45
+ $ cargo test some_test
46
+ ```
47
+
48
+ If the specfic test is ignored use:
49
+
50
+ ```bash
51
+ $ cargo test some_test -- --ignored
52
+ ```
53
+
54
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
35
55
 
36
56
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
37
57
  haven't already, it will help you with organizing your files.
@@ -45,6 +65,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
45
65
  [help-page]: http://exercism.io/languages/rust
46
66
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
47
67
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
68
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
48
69
 
49
70
  ## Source
50
71
 
@@ -45,11 +45,13 @@ fn last_of_four_rows() {
45
45
  #[ignore]
46
46
  fn five_rows() {
47
47
  let pt = PascalsTriangle::new(5);
48
- let expected: Vec<Vec<u32>> = vec![vec![1],
49
- vec![1, 1],
50
- vec![1, 2, 1],
51
- vec![1, 3, 3, 1],
52
- vec![1, 4, 6, 4, 1]];
48
+ let expected: Vec<Vec<u32>> = vec![
49
+ vec![1],
50
+ vec![1, 1],
51
+ vec![1, 2, 1],
52
+ vec![1, 3, 3, 1],
53
+ vec![1, 4, 6, 4, 1],
54
+ ];
53
55
  assert_eq!(expected, pt.rows());
54
56
  }
55
57
 
@@ -57,12 +59,14 @@ fn five_rows() {
57
59
  #[ignore]
58
60
  fn six_rows() {
59
61
  let pt = PascalsTriangle::new(6);
60
- let expected: Vec<Vec<u32>> = vec![vec![1],
61
- vec![1, 1],
62
- vec![1, 2, 1],
63
- vec![1, 3, 3, 1],
64
- vec![1, 4, 6, 4, 1],
65
- vec![1, 5, 10, 10, 5, 1]];
62
+ let expected: Vec<Vec<u32>> = vec![
63
+ vec![1],
64
+ vec![1, 1],
65
+ vec![1, 2, 1],
66
+ vec![1, 3, 3, 1],
67
+ vec![1, 4, 6, 4, 1],
68
+ vec![1, 5, 10, 10, 5, 1],
69
+ ];
66
70
  assert_eq!(expected, pt.rows());
67
71
  }
68
72
 
@@ -70,13 +74,15 @@ fn six_rows() {
70
74
  #[ignore]
71
75
  fn seven_rows() {
72
76
  let pt = PascalsTriangle::new(7);
73
- let expected: Vec<Vec<u32>> = vec![vec![1],
74
- vec![1, 1],
75
- vec![1, 2, 1],
76
- vec![1, 3, 3, 1],
77
- vec![1, 4, 6, 4, 1],
78
- vec![1, 5, 10, 10, 5, 1],
79
- vec![1, 6, 15, 20, 15, 6, 1]];
77
+ let expected: Vec<Vec<u32>> = vec![
78
+ vec![1],
79
+ vec![1, 1],
80
+ vec![1, 2, 1],
81
+ vec![1, 3, 3, 1],
82
+ vec![1, 4, 6, 4, 1],
83
+ vec![1, 5, 10, 10, 5, 1],
84
+ vec![1, 6, 15, 20, 15, 6, 1],
85
+ ];
80
86
  assert_eq!(expected, pt.rows());
81
87
  }
82
88
 
@@ -84,15 +90,17 @@ fn seven_rows() {
84
90
  #[ignore]
85
91
  fn ten_rows() {
86
92
  let pt = PascalsTriangle::new(10);
87
- let expected: Vec<Vec<u32>> = vec![vec![1],
88
- vec![1, 1],
89
- vec![1, 2, 1],
90
- vec![1, 3, 3, 1],
91
- vec![1, 4, 6, 4, 1],
92
- vec![1, 5, 10, 10, 5, 1],
93
- vec![1, 6, 15, 20, 15, 6, 1],
94
- vec![1, 7, 21, 35, 35, 21, 7, 1],
95
- vec![1, 8, 28, 56, 70, 56, 28, 8, 1],
96
- vec![1, 9, 36, 84, 126, 126, 84, 36, 9, 1]];
93
+ let expected: Vec<Vec<u32>> = vec![
94
+ vec![1],
95
+ vec![1, 1],
96
+ vec![1, 2, 1],
97
+ vec![1, 3, 3, 1],
98
+ vec![1, 4, 6, 4, 1],
99
+ vec![1, 5, 10, 10, 5, 1],
100
+ vec![1, 6, 15, 20, 15, 6, 1],
101
+ vec![1, 7, 21, 35, 35, 21, 7, 1],
102
+ vec![1, 8, 28, 56, 70, 56, 28, 8, 1],
103
+ vec![1, 9, 36, 84, 126, 126, 84, 36, 9, 1],
104
+ ];
97
105
  assert_eq!(expected, pt.rows());
98
106
  }
@@ -30,11 +30,31 @@ Execute the tests with:
30
30
  $ cargo test
31
31
  ```
32
32
 
33
- All but the first test have been ignored. After you get the first test to
34
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
35
- to pass again. The test file is located in the `tests` directory. You can
36
- also remove the ignore flag from all the tests to get them to run all at once
37
- if you wish.
33
+ All but the first test have been ignored. After you get the first test to
34
+ pass, open the tests source file wich is located in the `tests` directory
35
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
36
+ again. Each separate test is a function with `#[test]` flag above it.
37
+ Continue, until you pass every test.
38
+
39
+ If you wish to run all tests without editing the tests source file, use:
40
+
41
+ ```bash
42
+ $ cargo test -- --ignored
43
+ ```
44
+
45
+ To run a specific test, for example `some_test`, you can use:
46
+
47
+ ```bash
48
+ $ cargo test some_test
49
+ ```
50
+
51
+ If the specfic test is ignored use:
52
+
53
+ ```bash
54
+ $ cargo test some_test -- --ignored
55
+ ```
56
+
57
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
38
58
 
39
59
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
40
60
  haven't already, it will help you with organizing your files.
@@ -48,6 +68,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
48
68
  [help-page]: http://exercism.io/languages/rust
49
69
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
50
70
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
71
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
51
72
 
52
73
  ## Source
53
74
 
@@ -2,7 +2,7 @@
2
2
  pub enum Classification {
3
3
  Abundant,
4
4
  Perfect,
5
- Deficient
5
+ Deficient,
6
6
  }
7
7
 
8
8
  pub fn classify(num: u64) -> Option<Classification> {
@@ -1,6 +1,6 @@
1
1
  extern crate perfect_numbers;
2
2
 
3
- use perfect_numbers::{Classification, classify};
3
+ use perfect_numbers::{classify, Classification};
4
4
 
5
5
  macro_rules! tests {
6
6
  ($property_test_func:ident {
@@ -25,7 +25,6 @@ fn basic() {
25
25
  assert_eq!(classify(0), None);
26
26
  }
27
27
 
28
-
29
28
  tests! {
30
29
  test_classification {
31
30
  #[ignore] test_1(1, Classification::Deficient);
@@ -41,11 +41,31 @@ Execute the tests with:
41
41
  $ cargo test
42
42
  ```
43
43
 
44
- All but the first test have been ignored. After you get the first test to
45
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
46
- to pass again. The test file is located in the `tests` directory. You can
47
- also remove the ignore flag from all the tests to get them to run all at once
48
- if you wish.
44
+ All but the first test have been ignored. After you get the first test to
45
+ pass, open the tests source file wich is located in the `tests` directory
46
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
47
+ again. Each separate test is a function with `#[test]` flag above it.
48
+ Continue, until you pass every test.
49
+
50
+ If you wish to run all tests without editing the tests source file, use:
51
+
52
+ ```bash
53
+ $ cargo test -- --ignored
54
+ ```
55
+
56
+ To run a specific test, for example `some_test`, you can use:
57
+
58
+ ```bash
59
+ $ cargo test some_test
60
+ ```
61
+
62
+ If the specfic test is ignored use:
63
+
64
+ ```bash
65
+ $ cargo test some_test -- --ignored
66
+ ```
67
+
68
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
49
69
 
50
70
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
51
71
  haven't already, it will help you with organizing your files.
@@ -59,6 +79,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
59
79
  [help-page]: http://exercism.io/languages/rust
60
80
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
61
81
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
82
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
62
83
 
63
84
  ## Source
64
85
 
@@ -30,11 +30,31 @@ Execute the tests with:
30
30
  $ cargo test
31
31
  ```
32
32
 
33
- All but the first test have been ignored. After you get the first test to
34
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
35
- to pass again. The test file is located in the `tests` directory. You can
36
- also remove the ignore flag from all the tests to get them to run all at once
37
- if you wish.
33
+ All but the first test have been ignored. After you get the first test to
34
+ pass, open the tests source file wich is located in the `tests` directory
35
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
36
+ again. Each separate test is a function with `#[test]` flag above it.
37
+ Continue, until you pass every test.
38
+
39
+ If you wish to run all tests without editing the tests source file, use:
40
+
41
+ ```bash
42
+ $ cargo test -- --ignored
43
+ ```
44
+
45
+ To run a specific test, for example `some_test`, you can use:
46
+
47
+ ```bash
48
+ $ cargo test some_test
49
+ ```
50
+
51
+ If the specfic test is ignored use:
52
+
53
+ ```bash
54
+ $ cargo test some_test -- --ignored
55
+ ```
56
+
57
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
38
58
 
39
59
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
40
60
  haven't already, it will help you with organizing your files.
@@ -48,6 +68,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
48
68
  [help-page]: http://exercism.io/languages/rust
49
69
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
50
70
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
71
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
51
72
 
52
73
  ## Source
53
74
 
@@ -28,11 +28,31 @@ Execute the tests with:
28
28
  $ cargo test
29
29
  ```
30
30
 
31
- All but the first test have been ignored. After you get the first test to
32
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
33
- to pass again. The test file is located in the `tests` directory. You can
34
- also remove the ignore flag from all the tests to get them to run all at once
35
- if you wish.
31
+ All but the first test have been ignored. After you get the first test to
32
+ pass, open the tests source file wich is located in the `tests` directory
33
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
34
+ again. Each separate test is a function with `#[test]` flag above it.
35
+ Continue, until you pass every test.
36
+
37
+ If you wish to run all tests without editing the tests source file, use:
38
+
39
+ ```bash
40
+ $ cargo test -- --ignored
41
+ ```
42
+
43
+ To run a specific test, for example `some_test`, you can use:
44
+
45
+ ```bash
46
+ $ cargo test some_test
47
+ ```
48
+
49
+ If the specfic test is ignored use:
50
+
51
+ ```bash
52
+ $ cargo test some_test -- --ignored
53
+ ```
54
+
55
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
36
56
 
37
57
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
38
58
  haven't already, it will help you with organizing your files.
@@ -46,6 +66,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
46
66
  [help-page]: http://exercism.io/languages/rust
47
67
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
48
68
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
69
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
49
70
 
50
71
  ## Source
51
72
 
@@ -1,6 +1,6 @@
1
1
  extern crate poker;
2
- use std::collections::HashSet;
3
2
  use poker::winning_hands;
3
+ use std::collections::HashSet;
4
4
 
5
5
  fn hs_from<'a>(input: &[&'a str]) -> HashSet<&'a str> {
6
6
  let mut hs = HashSet::new();
@@ -17,9 +17,7 @@ fn hs_from<'a>(input: &[&'a str]) -> HashSet<&'a str> {
17
17
  /// abstract away the order of outputs.
18
18
  fn test<'a, 'b>(input: &[&'a str], expected: &[&'b str]) {
19
19
  assert_eq!(
20
- hs_from(&winning_hands(input).expect(
21
- "This test should produce Some value",
22
- )),
20
+ hs_from(&winning_hands(input).expect("This test should produce Some value",)),
23
21
  hs_from(expected)
24
22
  )
25
23
  }
@@ -57,47 +55,32 @@ fn test_a_tie_has_multiple_winners() {
57
55
  fn test_high_card_can_be_low_card_in_an_otherwise_tie() {
58
56
  // multiple hands with the same high cards, tie compares next highest ranked,
59
57
  // down to last card
60
- test(
61
- &["3S 5H 6S 8D 7H", "2S 5D 6D 8C 7S"],
62
- &["3S 5H 6S 8D 7H"],
63
- )
58
+ test(&["3S 5H 6S 8D 7H", "2S 5D 6D 8C 7S"], &["3S 5H 6S 8D 7H"])
64
59
  }
65
60
 
66
61
  #[test]
67
62
  #[ignore]
68
63
  fn test_one_pair_beats_high_card() {
69
- test(
70
- &["4S 5H 6C 8D KH", "2S 4H 6S 4D JH"],
71
- &["2S 4H 6S 4D JH"],
72
- )
64
+ test(&["4S 5H 6C 8D KH", "2S 4H 6S 4D JH"], &["2S 4H 6S 4D JH"])
73
65
  }
74
66
 
75
67
  #[test]
76
68
  #[ignore]
77
69
  fn test_highest_pair_wins() {
78
- test(
79
- &["4S 2H 6S 2D JH", "2S 4H 6C 4D JD"],
80
- &["2S 4H 6C 4D JD"],
81
- )
70
+ test(&["4S 2H 6S 2D JH", "2S 4H 6C 4D JD"], &["2S 4H 6C 4D JD"])
82
71
  }
83
72
 
84
73
  #[test]
85
74
  #[ignore]
86
75
  fn test_two_pairs_beats_one_pair() {
87
- test(
88
- &["2S 8H 6S 8D JH", "4S 5H 4C 8C 5C"],
89
- &["4S 5H 4C 8C 5C"],
90
- )
76
+ test(&["2S 8H 6S 8D JH", "4S 5H 4C 8C 5C"], &["4S 5H 4C 8C 5C"])
91
77
  }
92
78
 
93
79
  #[test]
94
80
  #[ignore]
95
81
  fn test_two_pair_ranks() {
96
82
  // both hands have two pairs, highest ranked pair wins
97
- test(
98
- &["2S 8H 2D 8D 3H", "4S 5H 4C 8S 5D"],
99
- &["2S 8H 2D 8D 3H"],
100
- )
83
+ test(&["2S 8H 2D 8D 3H", "4S 5H 4C 8S 5D"], &["2S 8H 2D 8D 3H"])
101
84
  }
102
85
 
103
86
  #[test]
@@ -105,10 +88,7 @@ fn test_two_pair_ranks() {
105
88
  fn test_two_pairs_second_pair_cascade() {
106
89
  // both hands have two pairs, with the same highest ranked pair,
107
90
  // tie goes to low pair
108
- test(
109
- &["2S QS 2C QD JH", "JD QH JS 8D QC"],
110
- &["JD QH JS 8D QC"],
111
- )
91
+ test(&["2S QS 2C QD JH", "JD QH JS 8D QC"], &["JD QH JS 8D QC"])
112
92
  }
113
93
 
114
94
  #[test]
@@ -116,29 +96,20 @@ fn test_two_pairs_second_pair_cascade() {
116
96
  fn test_two_pairs_last_card_cascade() {
117
97
  // both hands have two identically ranked pairs,
118
98
  // tie goes to remaining card (kicker)
119
- test(
120
- &["JD QH JS 8D QC", "JS QS JC 2D QD"],
121
- &["JD QH JS 8D QC"],
122
- )
99
+ test(&["JD QH JS 8D QC", "JS QS JC 2D QD"], &["JD QH JS 8D QC"])
123
100
  }
124
101
 
125
102
  #[test]
126
103
  #[ignore]
127
104
  fn test_three_of_a_kind_beats_two_pair() {
128
- test(
129
- &["2S 8H 2H 8D JH", "4S 5H 4C 8S 4H"],
130
- &["4S 5H 4C 8S 4H"],
131
- )
105
+ test(&["2S 8H 2H 8D JH", "4S 5H 4C 8S 4H"], &["4S 5H 4C 8S 4H"])
132
106
  }
133
107
 
134
108
  #[test]
135
109
  #[ignore]
136
110
  fn test_three_of_a_kind_ranks() {
137
111
  //both hands have three of a kind, tie goes to highest ranked triplet
138
- test(
139
- &["2S 2H 2C 8D JH", "4S AH AS 8C AD"],
140
- &["4S AH AS 8C AD"],
141
- )
112
+ test(&["2S 2H 2C 8D JH", "4S AH AS 8C AD"], &["4S AH AS 8C AD"])
142
113
  }
143
114
 
144
115
  #[test]
@@ -146,153 +117,105 @@ fn test_three_of_a_kind_ranks() {
146
117
  fn test_three_of_a_kind_cascade_ranks() {
147
118
  // with multiple decks, two players can have same three of a kind,
148
119
  // ties go to highest remaining cards
149
- test(
150
- &["4S AH AS 7C AD", "4S AH AS 8C AD"],
151
- &["4S AH AS 8C AD"],
152
- )
120
+ test(&["4S AH AS 7C AD", "4S AH AS 8C AD"], &["4S AH AS 8C AD"])
153
121
  }
154
122
 
155
123
  #[test]
156
124
  #[ignore]
157
125
  fn test_straight_beats_three_of_a_kind() {
158
- test(
159
- &["4S 5H 4C 8D 4H", "3S 4D 2S 6D 5C"],
160
- &["3S 4D 2S 6D 5C"],
161
- )
126
+ test(&["4S 5H 4C 8D 4H", "3S 4D 2S 6D 5C"], &["3S 4D 2S 6D 5C"])
162
127
  }
163
128
 
164
129
  #[test]
165
130
  #[ignore]
166
131
  fn test_aces_can_end_a_straight_high() {
167
132
  // aces can end a straight (10 J Q K A)
168
- test(
169
- &["4S 5H 4C 8D 4H", "10D JH QS KD AC"],
170
- &["10D JH QS KD AC"],
171
- )
133
+ test(&["4S 5H 4C 8D 4H", "10D JH QS KD AC"], &["10D JH QS KD AC"])
172
134
  }
173
135
 
174
136
  #[test]
175
137
  #[ignore]
176
138
  fn test_aces_can_end_a_straight_low() {
177
139
  // aces can start a straight (A 2 3 4 5)
178
- test(
179
- &["4S 5H 4C 8D 4H", "4D AH 3S 2D 5C"],
180
- &["4D AH 3S 2D 5C"],
181
- )
140
+ test(&["4S 5H 4C 8D 4H", "4D AH 3S 2D 5C"], &["4D AH 3S 2D 5C"])
182
141
  }
183
142
 
184
143
  #[test]
185
144
  #[ignore]
186
145
  fn test_straight_cascade() {
187
146
  // both hands with a straight, tie goes to highest ranked card
188
- test(
189
- &["4S 6C 7S 8D 5H", "5S 7H 8S 9D 6H"],
190
- &["5S 7H 8S 9D 6H"],
191
- )
147
+ test(&["4S 6C 7S 8D 5H", "5S 7H 8S 9D 6H"], &["5S 7H 8S 9D 6H"])
192
148
  }
193
149
 
194
150
  #[test]
195
151
  #[ignore]
196
152
  fn test_straight_scoring() {
197
153
  // even though an ace is usually high, a 5-high straight is the lowest-scoring straight
198
- test(
199
- &["2H 3C 4D 5D 6H", "4S AH 3S 2D 5H"],
200
- &["2H 3C 4D 5D 6H"],
201
- )
154
+ test(&["2H 3C 4D 5D 6H", "4S AH 3S 2D 5H"], &["2H 3C 4D 5D 6H"])
202
155
  }
203
156
 
204
157
  #[test]
205
158
  #[ignore]
206
159
  fn test_flush_beats_a_straight() {
207
- test(
208
- &["4C 6H 7D 8D 5H", "2S 4S 5S 6S 7S"],
209
- &["2S 4S 5S 6S 7S"],
210
- )
160
+ test(&["4C 6H 7D 8D 5H", "2S 4S 5S 6S 7S"], &["2S 4S 5S 6S 7S"])
211
161
  }
212
162
 
213
163
  #[test]
214
164
  #[ignore]
215
165
  fn test_flush_cascade() {
216
166
  // both hands have a flush, tie goes to high card, down to the last one if necessary
217
- test(
218
- &["4H 7H 8H 9H 6H", "2S 4S 5S 6S 7S"],
219
- &["4H 7H 8H 9H 6H"],
220
- )
167
+ test(&["4H 7H 8H 9H 6H", "2S 4S 5S 6S 7S"], &["4H 7H 8H 9H 6H"])
221
168
  }
222
169
 
223
170
  #[test]
224
171
  #[ignore]
225
172
  fn test_full_house_beats_a_flush() {
226
- test(
227
- &["3H 6H 7H 8H 5H", "4S 5C 4C 5D 4H"],
228
- &["4S 5C 4C 5D 4H"],
229
- )
173
+ test(&["3H 6H 7H 8H 5H", "4S 5C 4C 5D 4H"], &["4S 5C 4C 5D 4H"])
230
174
  }
231
175
 
232
176
  #[test]
233
177
  #[ignore]
234
178
  fn test_full_house_ranks() {
235
179
  // both hands have a full house, tie goes to highest-ranked triplet
236
- test(
237
- &["4H 4S 4D 9S 9D", "5H 5S 5D 8S 8D"],
238
- &["5H 5S 5D 8S 8D"],
239
- )
180
+ test(&["4H 4S 4D 9S 9D", "5H 5S 5D 8S 8D"], &["5H 5S 5D 8S 8D"])
240
181
  }
241
182
 
242
183
  #[test]
243
184
  #[ignore]
244
185
  fn test_full_house_cascade() {
245
186
  // with multiple decks, both hands have a full house with the same triplet, tie goes to the pair
246
- test(
247
- &["5H 5S 5D 9S 9D", "5H 5S 5D 8S 8D"],
248
- &["5H 5S 5D 9S 9D"],
249
- )
187
+ test(&["5H 5S 5D 9S 9D", "5H 5S 5D 8S 8D"], &["5H 5S 5D 9S 9D"])
250
188
  }
251
189
 
252
190
  #[test]
253
191
  #[ignore]
254
192
  fn test_four_of_a_kind_beats_full_house() {
255
- test(
256
- &["4S 5H 4D 5D 4H", "3S 3H 2S 3D 3C"],
257
- &["3S 3H 2S 3D 3C"],
258
- )
193
+ test(&["4S 5H 4D 5D 4H", "3S 3H 2S 3D 3C"], &["3S 3H 2S 3D 3C"])
259
194
  }
260
195
 
261
196
  #[test]
262
197
  #[ignore]
263
198
  fn test_four_of_a_kind_ranks() {
264
199
  // both hands have four of a kind, tie goes to high quad
265
- test(
266
- &["2S 2H 2C 8D 2D", "4S 5H 5S 5D 5C"],
267
- &["4S 5H 5S 5D 5C"],
268
- )
200
+ test(&["2S 2H 2C 8D 2D", "4S 5H 5S 5D 5C"], &["4S 5H 5S 5D 5C"])
269
201
  }
270
202
 
271
203
  #[test]
272
204
  #[ignore]
273
205
  fn test_four_of_a_kind_cascade() {
274
206
  // with multiple decks, both hands with identical four of a kind, tie determined by kicker
275
- test(
276
- &["3S 3H 2S 3D 3C", "3S 3H 4S 3D 3C"],
277
- &["3S 3H 4S 3D 3C"],
278
- )
207
+ test(&["3S 3H 2S 3D 3C", "3S 3H 4S 3D 3C"], &["3S 3H 4S 3D 3C"])
279
208
  }
280
209
 
281
210
  #[test]
282
211
  #[ignore]
283
212
  fn test_straight_flush_beats_four_of_a_kind() {
284
- test(
285
- &["4S 5H 5S 5D 5C", "7S 8S 9S 6S 10S"],
286
- &["7S 8S 9S 6S 10S"],
287
- )
213
+ test(&["4S 5H 5S 5D 5C", "7S 8S 9S 6S 10S"], &["7S 8S 9S 6S 10S"])
288
214
  }
289
215
 
290
216
  #[test]
291
217
  #[ignore]
292
218
  fn test_straight_flush_ranks() {
293
219
  // both hands have straight flush, tie goes to highest-ranked card
294
- test(
295
- &["4H 6H 7H 8H 5H", "5S 7S 8S 9S 6S"],
296
- &["5S 7S 8S 9S 6S"],
297
- )
220
+ test(&["4H 6H 7H 8H 5H", "5S 7S 8S 9S 6S"], &["5S 7S 8S 9S 6S"])
298
221
  }