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
@@ -31,18 +31,25 @@ 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
+ 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
+
46
53
  ## Rust Installation
47
54
 
48
55
  Refer to the [exercism help page][help-page] for Rust installation and learning
@@ -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
@@ -1,3 +1,3 @@
1
1
  [package]
2
2
  name = "dominoes"
3
- version = "1.0.1"
3
+ version = "2.0.0"
@@ -3,6 +3,7 @@
3
3
  We are going to do the `Transform` step of an Extract-Transform-Load.
4
4
 
5
5
  ### ETL
6
+
6
7
  Extract-Transform-Load (ETL) is a fancy way of saying, "We have some crufty, legacy data over in this system, and now we need it in this shiny new system over here, so
7
8
  we're going to migrate this."
8
9
 
@@ -11,6 +12,7 @@ once." That's then typically followed by much forehead slapping and
11
12
  moaning about how stupid we could possibly be.)
12
13
 
13
14
  ### The goal
15
+
14
16
  We're going to extract some scrabble scores from a legacy system.
15
17
 
16
18
  The old system stored a list of letters per score:
@@ -21,7 +21,6 @@ In the end, you should be able to:
21
21
  Note that all our students only have one name. (It's a small town, what
22
22
  do you want?)
23
23
 
24
-
25
24
  ## For bonus points
26
25
 
27
26
  Did you get the tests passing and the code clean? If you want to, these
@@ -15,7 +15,6 @@ Write code that shows:
15
15
  - how many grains were on each square, and
16
16
  - the total number of grains
17
17
 
18
-
19
18
  ## For bonus points
20
19
 
21
20
  Did you get the tests passing and the code clean? If you want to, these
@@ -0,0 +1,4 @@
1
+ [root]
2
+ name = "isbn-verifier"
3
+ version = "1.1.0"
4
+
@@ -0,0 +1,3 @@
1
+ [package]
2
+ name = "isbn-verifier"
3
+ version = "1.1.0"
@@ -0,0 +1,74 @@
1
+ # Isbn Verifier
2
+
3
+ Check if a given ISBN-10 is valid.
4
+
5
+ ## Functionality
6
+
7
+ Given an unknown string the program should check if the provided string is a valid ISBN-10.
8
+ Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN.
9
+
10
+ The program should allow for ISBN-10 without the separating dashes to be verified as well.
11
+
12
+ ## ISBN
13
+
14
+ Let's take a random ISBN-10 number, say `3-598-21508-8` for this.
15
+ The first digit block indicates the group where the ISBN belongs. Groups can consist of shared languages, geographic regions or countries. The leading '3' signals this ISBN is from a german speaking country.
16
+ The following number block is to identify the publisher. Since this is a three digit publisher number there is a 5 digit title number for this book.
17
+ The last digit in the ISBN is the check digit which is used to detect read errors.
18
+
19
+ The first 9 digits in the ISBN have to be between 0 and 9.
20
+ The check digit can additionally be an 'X' to allow 10 to be a valid check digit as well.
21
+
22
+ A valid ISBN-10 is calculated with this formula `(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0`
23
+ So for our example ISBN this means:
24
+ (3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 = 0
25
+
26
+ Which proves that the ISBN is valid.
27
+
28
+ ## Caveats
29
+
30
+ Converting from string to number can be tricky in certain languages.
31
+ It's getting even trickier since the check-digit of an ISBN-10 can be 'X'.
32
+
33
+ ## Bonus tasks
34
+
35
+ * Generate a valid ISBN-13 from the input ISBN-10 (and maybe verify it again with a derived verifier)
36
+
37
+ * Generate valid ISBN, maybe even from a given starting ISBN
38
+ ## Rust Installation
39
+
40
+ Refer to the [exercism help page][help-page] for Rust installation and learning
41
+ resources.
42
+
43
+ ## Writing the Code
44
+
45
+ Execute the tests with:
46
+
47
+ ```bash
48
+ $ cargo test
49
+ ```
50
+
51
+ All but the first test have been ignored. After you get the first test to
52
+ pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
53
+ to pass again. The test file is located in the `tests` directory. You can
54
+ also remove the ignore flag from all the tests to get them to run all at once
55
+ if you wish.
56
+
57
+ Make sure to read the [Crates and Modules](https://doc.rust-lang.org/stable/book/crates-and-modules.html) chapter if you
58
+ haven't already, it will help you with organizing your files.
59
+
60
+ ## Feedback, Issues, Pull Requests
61
+
62
+ 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!
63
+
64
+ 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).
65
+
66
+ [help-page]: http://exercism.io/languages/rust
67
+ [crates-and-modules]: http://doc.rust-lang.org/stable/book/crates-and-modules.html
68
+
69
+ ## Source
70
+
71
+ Converting a string into a number and some basic processing utilizing a relatable real world example. [https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation](https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation)
72
+
73
+ ## Submitting Incomplete Solutions
74
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,44 @@
1
+ /// An ISBN type
2
+ #[derive(PartialEq, Eq)]
3
+ enum IsbnType {
4
+ Isbn10,
5
+ Isbn13,
6
+ }
7
+
8
+ /// Checks if an 'X' is valid at the given position for the given ISBN type
9
+ #[allow(non_snake_case)]
10
+ fn is_X_valid(position: &usize, isbn_type: &IsbnType) -> bool {
11
+ (isbn_type == &IsbnType::Isbn10 && position == &9 ) ||
12
+ (isbn_type == &IsbnType::Isbn13 && position == &12)
13
+ }
14
+
15
+ /// Checks if a '-' is valid at the given position for the given ISBN type
16
+ fn is_dash_valid(position: &usize, isbn_type: &IsbnType) -> bool {
17
+ isbn_type == &IsbnType::Isbn13 &&
18
+ (position == &1 || position == &5 || position == &11)
19
+ }
20
+
21
+ /// Determines whether the supplied string is a valid ISBN number
22
+ pub fn is_valid_isbn(isbn: &str) -> bool {
23
+ let isbn_type = match isbn.len() {
24
+ 10 => IsbnType::Isbn10,
25
+ 13 => IsbnType::Isbn13,
26
+ _ => return false,
27
+ };
28
+
29
+ let mut checksum = 0;
30
+ let mut coefficient = 10;
31
+ for (position, c) in isbn.char_indices() {
32
+ let digit_value = match c {
33
+ '0' ... '9' => c.to_digit(10).unwrap(),
34
+ 'X' if is_X_valid(&position, &isbn_type) => 10,
35
+ '-' if is_dash_valid(&position, &isbn_type) => continue,
36
+ _ => return false,
37
+ };
38
+
39
+ checksum += coefficient * digit_value;
40
+ coefficient -= 1;
41
+ }
42
+
43
+ checksum % 11 == 0
44
+ }
@@ -0,0 +1,4 @@
1
+ /// Determines whether the supplied string is a valid ISBN number
2
+ pub fn is_valid_isbn(_isbn: &str) -> bool {
3
+ unimplemented!();
4
+ }
@@ -0,0 +1,83 @@
1
+ extern crate isbn_verifier;
2
+
3
+ use isbn_verifier::is_valid_isbn;
4
+
5
+ #[test]
6
+ fn test_valid() {
7
+ assert!(is_valid_isbn("3-598-21508-8"));
8
+ }
9
+
10
+ #[test]
11
+ #[ignore]
12
+ fn test_invalid_check_digit() {
13
+ assert!(!is_valid_isbn("3-598-21508-9"));
14
+ }
15
+
16
+ #[test]
17
+ #[ignore]
18
+ fn test_valid_check_digit_of_10() {
19
+ assert!(is_valid_isbn("3-598-21507-X"));
20
+ }
21
+
22
+ #[test]
23
+ #[ignore]
24
+ fn test_invalid_character_as_check_digit() {
25
+ assert!(!is_valid_isbn("3-598-21507-A"));
26
+ }
27
+
28
+ #[test]
29
+ #[ignore]
30
+ fn test_invalid_character_in_isbn() {
31
+ assert!(!is_valid_isbn("3-598-2K507-0"));
32
+ }
33
+
34
+ #[test]
35
+ #[ignore]
36
+ #[allow(non_snake_case)]
37
+ fn test_invalid_isbn_with_invalid_X() {
38
+ assert!(!is_valid_isbn("3-598-2X507-9"));
39
+ }
40
+
41
+ #[test]
42
+ #[ignore]
43
+ fn test_valid_isbn_without_dashes() {
44
+ assert!(is_valid_isbn("3598215088"));
45
+ }
46
+
47
+ #[test]
48
+ #[ignore]
49
+ #[allow(non_snake_case)]
50
+ fn test_valid_isbn_without_dashes_and_X_as_check() {
51
+ assert!(is_valid_isbn("359821507X"));
52
+ }
53
+
54
+ #[test]
55
+ #[ignore]
56
+ fn test_invalid_isbn_without_dashes_and_no_check_digit() {
57
+ assert!(!is_valid_isbn("359821507"));
58
+ }
59
+
60
+ #[test]
61
+ #[ignore]
62
+ fn test_invalid_isbn_without_dashes_and_too_long() {
63
+ assert!(!is_valid_isbn("3598215078X"));
64
+ }
65
+
66
+ #[test]
67
+ #[ignore]
68
+ fn test_invalid_isbn_without_check_digit() {
69
+ assert!(!is_valid_isbn("3-598-21507"));
70
+ }
71
+
72
+ #[test]
73
+ #[ignore]
74
+ fn test_invalid_isbn_too_long() {
75
+ assert!(!is_valid_isbn("3-598-21507-XX"));
76
+ }
77
+
78
+ #[test]
79
+ #[ignore]
80
+ #[allow(non_snake_case)]
81
+ fn test_invalid_isbn_with_check_digit_X_instead_of_0() {
82
+ assert!(!is_valid_isbn("3-598-21515-X"));
83
+ }
@@ -32,7 +32,7 @@ to pass again. The test file is located in the `tests` directory. You can
32
32
  also remove the ignore flag from all the tests to get them to run all at once
33
33
  if you wish.
34
34
 
35
- Make sure to read the [Crates and Modules](https://doc.rust-lang.org/stable/book/crates-and-modules.html) chapter if you
35
+ Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
36
36
  haven't already, it will help you with organizing your files.
37
37
 
38
38
  ## Feedback, Issues, Pull Requests
@@ -42,7 +42,8 @@ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is th
42
42
  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).
43
43
 
44
44
  [help-page]: http://exercism.io/languages/rust
45
- [crates-and-modules]: http://doc.rust-lang.org/stable/book/crates-and-modules.html
45
+ [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
46
+ [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
46
47
 
47
48
  ## Source
48
49
 
@@ -4,7 +4,7 @@ Given a year, report if it is a leap year.
4
4
 
5
5
  The tricky thing here is that a leap year in the Gregorian calendar occurs:
6
6
 
7
- ```plain
7
+ ```text
8
8
  on every year that is evenly divisible by 4
9
9
  except every year that is evenly divisible by 100
10
10
  unless the year is also evenly divisible by 400
@@ -18,27 +18,27 @@ are disallowed.
18
18
 
19
19
  ## Example 1: valid credit card number
20
20
 
21
- ```
21
+ ```text
22
22
  4539 1488 0343 6467
23
23
  ```
24
24
 
25
25
  The first step of the Luhn algorithm is to double every second digit,
26
26
  starting from the right. We will be doubling
27
27
 
28
- ```
28
+ ```text
29
29
  4_3_ 1_8_ 0_4_ 6_6_
30
30
  ```
31
31
 
32
32
  If doubling the number results in a number greater than 9 then subtract 9
33
33
  from the product. The results of our doubling:
34
34
 
35
- ```
35
+ ```text
36
36
  8569 2478 0383 3437
37
37
  ```
38
38
 
39
39
  Then sum all of the digits:
40
40
 
41
- ```
41
+ ```text
42
42
  8+5+6+9+2+4+7+8+0+3+8+3+3+4+3+7 = 80
43
43
  ```
44
44
 
@@ -46,19 +46,19 @@ If the sum is evenly divisible by 10, then the number is valid. This number is v
46
46
 
47
47
  ## Example 2: invalid credit card number
48
48
 
49
- ```
49
+ ```text
50
50
  8273 1232 7352 0569
51
51
  ```
52
52
 
53
53
  Double the second digits, starting from the right
54
54
 
55
- ```
55
+ ```text
56
56
  7253 2262 5312 0539
57
57
  ```
58
58
 
59
59
  Sum the digits
60
60
 
61
- ```
61
+ ```text
62
62
  7+2+5+3+2+2+6+2+5+3+1+2+0+5+3+9 = 57
63
63
  ```
64
64
 
@@ -1,30 +1,16 @@
1
1
  # Nucleotide Count
2
2
 
3
- Given a DNA string, compute how many times each nucleotide occurs in the string.
3
+ Given a single stranded DNA string, compute how many times each nucleotide occurs in the string.
4
4
 
5
- DNA is represented by an alphabet of the following symbols: 'A', 'C',
6
- 'G', and 'T'.
7
-
8
- Each symbol represents a nucleotide, which is a fancy name for the
9
- particular molecules that happen to make up a large part of DNA.
10
-
11
- Shortest intro to biochemistry EVAR:
5
+ The genetic language of every living thing on the planet is DNA.
6
+ DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides.
7
+ 4 types exist in DNA and these differ only slightly and can be represented as the following symbols: 'A' for adenine, 'C' for cytosine, 'G' for guanine, and 'T' thymine.
12
8
 
9
+ Here is an analogy:
13
10
  - twigs are to birds nests as
14
- - nucleotides are to DNA and RNA as
15
- - amino acids are to proteins as
16
- - sugar is to starch as
17
- - oh crap lipids
18
-
19
- I'm not going to talk about lipids because they're crazy complex.
20
-
21
- So back to nucleotides.
22
-
23
- DNA contains four types of them: adenine (`A`), cytosine (`C`), guanine
24
- (`G`), and thymine (`T`).
25
-
26
- RNA contains a slightly different set of nucleotides, but we don't care
27
- about that for now.
11
+ - nucleotides are to DNA as
12
+ - legos are to lego houses as
13
+ - words are to sentences as...
28
14
 
29
15
  ## Rust Installation
30
16