trackler 2.2.1.71 → 2.2.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/book-store/canonical-data.json +9 -2
- data/problem-specifications/exercises/word-count/canonical-data.json +9 -0
- data/tracks/bash/CONTRIBUTING.md +199 -0
- data/tracks/bash/config.json +24 -11
- data/tracks/bash/exercises/triangle/README.md +38 -0
- data/tracks/bash/exercises/triangle/example.sh +56 -0
- data/tracks/bash/exercises/triangle/triangle_test.sh +126 -0
- data/tracks/bash/img/canonical-data-example.png +0 -0
- data/tracks/bash/img/create-pr.png +0 -0
- data/tracks/bash/img/fork-repository.png +0 -0
- data/tracks/c/exercises/acronym/makefile +1 -1
- data/tracks/c/exercises/all-your-base/makefile +1 -1
- data/tracks/c/exercises/allergies/makefile +1 -1
- data/tracks/c/exercises/anagram/makefile +1 -1
- data/tracks/c/exercises/atbash-cipher/makefile +1 -1
- data/tracks/c/exercises/beer-song/makefile +1 -1
- data/tracks/c/exercises/binary-search/makefile +1 -1
- data/tracks/c/exercises/binary/makefile +1 -1
- data/tracks/c/exercises/bob/makefile +1 -1
- data/tracks/c/exercises/clock/makefile +1 -1
- data/tracks/c/exercises/collatz-conjecture/makefile +1 -1
- data/tracks/c/exercises/difference-of-squares/makefile +1 -1
- data/tracks/c/exercises/gigasecond/makefile +1 -1
- data/tracks/c/exercises/grains/makefile +1 -1
- data/tracks/c/exercises/hamming/makefile +1 -1
- data/tracks/c/exercises/hamming/test/test_hamming.c +2 -2
- data/tracks/c/exercises/hello-world/makefile +1 -1
- data/tracks/c/exercises/isogram/makefile +1 -1
- data/tracks/c/exercises/largest-series-product/makefile +1 -1
- data/tracks/c/exercises/leap/makefile +1 -1
- data/tracks/c/exercises/meetup/makefile +1 -1
- data/tracks/c/exercises/nth-prime/makefile +1 -1
- data/tracks/c/exercises/nucleotide-count/makefile +1 -1
- data/tracks/c/exercises/palindrome-products/makefile +1 -1
- data/tracks/c/exercises/pangram/makefile +1 -1
- data/tracks/c/exercises/pascals-triangle/makefile +1 -1
- data/tracks/c/exercises/perfect-numbers/makefile +1 -1
- data/tracks/c/exercises/phone-number/makefile +1 -1
- data/tracks/c/exercises/queen-attack/makefile +1 -1
- data/tracks/c/exercises/raindrops/makefile +1 -1
- data/tracks/c/exercises/react/makefile +1 -1
- data/tracks/c/exercises/rna-transcription/makefile +1 -1
- data/tracks/c/exercises/robot-simulator/makefile +1 -1
- data/tracks/c/exercises/roman-numerals/makefile +1 -1
- data/tracks/c/exercises/scrabble-score/makefile +1 -1
- data/tracks/c/exercises/series/makefile +1 -1
- data/tracks/c/exercises/sieve/makefile +1 -1
- data/tracks/c/exercises/space-age/makefile +1 -1
- data/tracks/c/exercises/sublist/makefile +1 -1
- data/tracks/c/exercises/sum-of-multiples/makefile +1 -1
- data/tracks/c/exercises/triangle/makefile +1 -1
- data/tracks/c/exercises/word-count/makefile +1 -1
- data/tracks/delphi/exercises/allergies/README.md +1 -1
- data/tracks/delphi/exercises/bank-account/README.md +1 -1
- data/tracks/delphi/exercises/beer-song/README.md +1 -1
- data/tracks/delphi/exercises/binary-search/README.md +1 -1
- data/tracks/delphi/exercises/bob/README.md +1 -1
- data/tracks/delphi/exercises/book-store/README.md +1 -1
- data/tracks/delphi/exercises/book-store/uBookStoreExample.pas +34 -14
- data/tracks/delphi/exercises/book-store/uBookStoreTests.pas +36 -1
- data/tracks/delphi/exercises/bowling/README.md +1 -1
- data/tracks/delphi/exercises/circular-buffer/README.md +1 -1
- data/tracks/delphi/exercises/clock/README.md +1 -1
- data/tracks/delphi/exercises/collatz-conjecture/README.md +1 -1
- data/tracks/delphi/exercises/etl/README.md +1 -1
- data/tracks/delphi/exercises/grains/README.md +1 -1
- data/tracks/delphi/exercises/hamming/README.md +1 -1
- data/tracks/delphi/exercises/hello-world/README.md +1 -1
- data/tracks/delphi/exercises/leap/README.md +1 -1
- data/tracks/delphi/exercises/minesweeper/README.md +1 -1
- data/tracks/delphi/exercises/nucleotide-count/README.md +1 -1
- data/tracks/delphi/exercises/perfect-numbers/README.md +1 -1
- data/tracks/delphi/exercises/phone-number/README.md +1 -1
- data/tracks/delphi/exercises/pig-latin/README.md +1 -1
- data/tracks/delphi/exercises/poker/README.md +1 -1
- data/tracks/delphi/exercises/raindrops/README.md +1 -1
- data/tracks/delphi/exercises/reverse-string/README.md +1 -1
- data/tracks/delphi/exercises/rna-transcription/README.md +1 -1
- data/tracks/delphi/exercises/roman-numerals/README.md +1 -1
- data/tracks/delphi/exercises/saddle-points/README.md +1 -1
- data/tracks/delphi/exercises/triangle/README.md +1 -1
- data/tracks/delphi/exercises/two-fer/README.md +1 -1
- data/tracks/delphi/exercises/wordy/README.md +1 -1
- data/tracks/ecmascript/.travis.yml +1 -1
- data/tracks/ecmascript/Makefile +4 -5
- data/tracks/ecmascript/README.md +2 -1
- data/tracks/ecmascript/config.json +12 -0
- data/tracks/ecmascript/exercises/change/package.json +5 -3
- data/tracks/ecmascript/exercises/protein-translation/package.json +2 -2
- data/tracks/ecmascript/exercises/react/README.md +41 -0
- data/tracks/ecmascript/exercises/react/example.js +101 -0
- data/tracks/ecmascript/exercises/react/package.json +71 -0
- data/tracks/ecmascript/exercises/react/react.spec.js +211 -0
- data/tracks/ecmascript/exercises/rectangles/package.json +1 -2
- data/tracks/ecmascript/exercises/rotational-cipher/package.json +1 -2
- data/tracks/ecmascript/exercises/spiral-matrix/package.json +1 -2
- data/tracks/ecmascript/exercises/transpose/package.json +2 -2
- data/tracks/erlang/docs/ABOUT.md +1 -1
- data/tracks/go/exercises/binary-search/.meta/gen.go +55 -0
- data/tracks/go/exercises/binary-search/binary_search_test.go +26 -167
- data/tracks/go/exercises/binary-search/cases_test.go +73 -0
- data/tracks/go/exercises/binary-search/example.go +8 -30
- data/tracks/go/exercises/nth-prime/.meta/gen.go +76 -0
- data/tracks/go/exercises/nth-prime/cases_test.go +43 -0
- data/tracks/go/exercises/nth-prime/nth_prime_test.go +4 -18
- data/tracks/go/exercises/prime-factors/.meta/gen.go +54 -0
- data/tracks/go/exercises/prime-factors/cases_test.go +48 -0
- data/tracks/go/exercises/prime-factors/prime_factors_test.go +4 -19
- data/tracks/groovy/config.json +13 -1
- data/tracks/groovy/exercises/linked-list/DoubleLinkedList.groovy +19 -0
- data/tracks/groovy/exercises/linked-list/DoubleLinkedListSpec.groovy +79 -0
- data/tracks/groovy/exercises/linked-list/Example.groovy +57 -0
- data/tracks/groovy/exercises/linked-list/README.md +49 -0
- data/tracks/java/bin/run-journey-test-from-ci.sh +1 -1
- data/tracks/java/config.json +10 -0
- data/tracks/java/config/maintainers.json +8 -1
- data/tracks/java/docs/MAINTAINING.md +3 -3
- data/tracks/java/exercises/accumulate/.meta/src/reference/java/Accumulate.java +2 -2
- data/tracks/java/exercises/binary/.meta/src/reference/java/Binary.java +3 -3
- data/tracks/java/exercises/circular-buffer/.meta/src/reference/java/BufferIOException.java +1 -1
- data/tracks/java/exercises/circular-buffer/.meta/src/reference/java/CircularBuffer.java +6 -6
- data/tracks/java/exercises/circular-buffer/src/main/java/BufferIOException.java +1 -1
- data/tracks/java/exercises/clock/.meta/src/reference/java/Clock.java +3 -3
- data/tracks/java/exercises/crypto-square/.meta/src/reference/java/Crypto.java +7 -7
- data/tracks/java/exercises/etl/.meta/src/reference/java/Etl.java +2 -2
- data/tracks/java/exercises/etl/src/main/java/Etl.java +2 -2
- data/tracks/java/exercises/kindergarten-garden/.meta/src/reference/java/KindergartenGarden.java +4 -4
- data/tracks/java/exercises/kindergarten-garden/.meta/src/reference/java/Plant.java +2 -2
- data/tracks/java/exercises/kindergarten-garden/src/main/java/Plant.java +2 -2
- data/tracks/java/exercises/nth-prime/.meta/src/reference/java/PrimeCalculator.java +2 -2
- data/tracks/java/exercises/reverse-string/.meta/src/reference/java/ReverseString.java +7 -0
- data/tracks/java/exercises/reverse-string/.meta/version +1 -0
- data/tracks/java/exercises/reverse-string/README.md +25 -0
- data/tracks/java/exercises/reverse-string/build.gradle +17 -0
- data/tracks/java/exercises/reverse-string/src/main/java/ReverseString.java +7 -0
- data/tracks/java/exercises/reverse-string/src/test/java/ReverseStringTest.java +37 -0
- data/tracks/java/exercises/run-length-encoding/.meta/src/reference/java/RunLengthEncoding.java +4 -4
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/kotlin/docs/RESOURCES.md +1 -1
- data/tracks/kotlin/exercises/accumulate/build.gradle +1 -1
- data/tracks/kotlin/exercises/acronym/build.gradle +1 -1
- data/tracks/kotlin/exercises/all-your-base/build.gradle +1 -1
- data/tracks/kotlin/exercises/allergies/build.gradle +1 -1
- data/tracks/kotlin/exercises/anagram/build.gradle +1 -1
- data/tracks/kotlin/exercises/atbash-cipher/build.gradle +1 -1
- data/tracks/kotlin/exercises/bank-account/build.gradle +1 -1
- data/tracks/kotlin/exercises/beer-song/build.gradle +1 -1
- data/tracks/kotlin/exercises/binary-search/build.gradle +1 -1
- data/tracks/kotlin/exercises/binary/build.gradle +1 -1
- data/tracks/kotlin/exercises/bob/build.gradle +1 -1
- data/tracks/kotlin/exercises/bracket-push/build.gradle +1 -1
- data/tracks/kotlin/exercises/change/build.gradle +1 -1
- data/tracks/kotlin/exercises/clock/build.gradle +1 -1
- data/tracks/kotlin/exercises/collatz-conjecture/build.gradle +1 -1
- data/tracks/kotlin/exercises/complex-numbers/build.gradle +1 -1
- data/tracks/kotlin/exercises/diamond/build.gradle +1 -1
- data/tracks/kotlin/exercises/difference-of-squares/build.gradle +1 -1
- data/tracks/kotlin/exercises/etl/build.gradle +1 -1
- data/tracks/kotlin/exercises/flatten-array/build.gradle +1 -1
- data/tracks/kotlin/exercises/forth/build.gradle +1 -1
- data/tracks/kotlin/exercises/gigasecond/build.gradle +1 -1
- data/tracks/kotlin/exercises/grade-school/build.gradle +1 -1
- data/tracks/kotlin/exercises/grains/build.gradle +1 -1
- data/tracks/kotlin/exercises/hamming/build.gradle +1 -1
- data/tracks/kotlin/exercises/hello-world/build.gradle +1 -1
- data/tracks/kotlin/exercises/hexadecimal/build.gradle +1 -1
- data/tracks/kotlin/exercises/isogram/build.gradle +1 -1
- data/tracks/kotlin/exercises/largest-series-product/build.gradle +1 -1
- data/tracks/kotlin/exercises/leap/build.gradle +1 -1
- data/tracks/kotlin/exercises/linked-list/build.gradle +1 -1
- data/tracks/kotlin/exercises/list-ops/build.gradle +1 -1
- data/tracks/kotlin/exercises/luhn/build.gradle +1 -1
- data/tracks/kotlin/exercises/meetup/build.gradle +1 -1
- data/tracks/kotlin/exercises/minesweeper/build.gradle +1 -1
- data/tracks/kotlin/exercises/nth-prime/build.gradle +1 -1
- data/tracks/kotlin/exercises/nucleotide-count/build.gradle +1 -1
- data/tracks/kotlin/exercises/pangram/build.gradle +1 -1
- data/tracks/kotlin/exercises/pascals-triangle/build.gradle +1 -1
- data/tracks/kotlin/exercises/perfect-numbers/build.gradle +1 -1
- data/tracks/kotlin/exercises/phone-number/build.gradle +1 -1
- data/tracks/kotlin/exercises/pig-latin/build.gradle +1 -1
- data/tracks/kotlin/exercises/prime-factors/build.gradle +1 -1
- data/tracks/kotlin/exercises/raindrops/build.gradle +1 -1
- data/tracks/kotlin/exercises/react/build.gradle +1 -1
- data/tracks/kotlin/exercises/rna-transcription/build.gradle +1 -1
- data/tracks/kotlin/exercises/robot-name/build.gradle +1 -1
- data/tracks/kotlin/exercises/robot-simulator/build.gradle +1 -1
- data/tracks/kotlin/exercises/roman-numerals/build.gradle +1 -1
- data/tracks/kotlin/exercises/rotational-cipher/build.gradle +1 -1
- data/tracks/kotlin/exercises/saddle-points/build.gradle +1 -1
- data/tracks/kotlin/exercises/say/build.gradle +1 -1
- data/tracks/kotlin/exercises/scrabble-score/build.gradle +1 -1
- data/tracks/kotlin/exercises/secret-handshake/build.gradle +1 -1
- data/tracks/kotlin/exercises/series/build.gradle +1 -1
- data/tracks/kotlin/exercises/sieve/build.gradle +1 -1
- data/tracks/kotlin/exercises/simple-cipher/README.md +4 -6
- data/tracks/kotlin/exercises/simple-cipher/build.gradle +1 -1
- data/tracks/kotlin/exercises/space-age/build.gradle +1 -1
- data/tracks/kotlin/exercises/spiral-matrix/build.gradle +1 -1
- data/tracks/kotlin/exercises/strain/build.gradle +1 -1
- data/tracks/kotlin/exercises/sublist/build.gradle +1 -1
- data/tracks/kotlin/exercises/sum-of-multiples/build.gradle +1 -1
- data/tracks/kotlin/exercises/triangle/build.gradle +1 -1
- data/tracks/kotlin/exercises/two-fer/build.gradle +1 -1
- data/tracks/kotlin/exercises/word-count/build.gradle +1 -1
- data/tracks/lua/.gitignore +1 -0
- data/tracks/lua/config.json +12 -0
- data/tracks/lua/exercises/isbn-verifier/README.md +52 -0
- data/tracks/lua/exercises/isbn-verifier/example.lua +16 -0
- data/tracks/lua/exercises/isbn-verifier/isbn-verifier_spec.lua +55 -0
- data/tracks/ocaml/.travis-ci.sh +1 -1
- data/tracks/ocaml/.travis.yml +1 -1
- data/tracks/ocaml/README.md +1 -1
- data/tracks/perl6/config.json +10 -0
- data/tracks/perl6/exercises/acronym/Acronym.pm6 +4 -0
- data/tracks/perl6/exercises/acronym/Example.pm6 +5 -0
- data/tracks/perl6/exercises/acronym/README.md +33 -0
- data/tracks/perl6/exercises/acronym/acronym.t +96 -0
- data/tracks/perl6/exercises/acronym/example.yaml +19 -0
- data/tracks/perl6/exercises/word-count/Example.pm6 +1 -1
- data/tracks/perl6/exercises/word-count/WordCount.pm6 +1 -1
- data/tracks/perl6/exercises/word-count/example.yaml +2 -2
- data/tracks/perl6/exercises/word-count/word-count.t +11 -2
- data/tracks/pony/docs/RESOURCES.md +1 -1
- data/tracks/purescript/docs/INSTALLATION.md +1 -3
- data/tracks/python/config.json +1 -1
- data/tracks/r/exercises/word-count/test_word-count.R +5 -0
- data/tracks/ruby/README.md +73 -10
- data/tracks/rust/config.json +34 -0
- data/tracks/rust/exercises/book-store/Cargo.toml +1 -1
- data/tracks/rust/exercises/book-store/tests/book-store.rs +7 -0
- data/tracks/rust/exercises/diffie-hellman/.gitignore +9 -0
- data/tracks/rust/exercises/diffie-hellman/Cargo-example.toml +6 -0
- data/tracks/rust/exercises/diffie-hellman/Cargo.toml +5 -0
- data/tracks/rust/exercises/diffie-hellman/README.md +77 -0
- data/tracks/rust/exercises/diffie-hellman/example.rs +15 -0
- data/tracks/rust/exercises/diffie-hellman/src/lib.rs +11 -0
- data/tracks/rust/exercises/diffie-hellman/tests/diffie-hellman.rs +60 -0
- data/tracks/rust/exercises/macros/.gitignore +3 -0
- data/tracks/rust/exercises/macros/.meta/description.md +29 -0
- data/tracks/rust/exercises/macros/.meta/metadata.yml +3 -0
- data/tracks/rust/exercises/macros/Cargo.toml +6 -0
- data/tracks/rust/exercises/macros/README.md +70 -0
- data/tracks/rust/exercises/macros/example.rs +16 -0
- data/tracks/rust/exercises/macros/src/lib.rs +6 -0
- data/tracks/rust/exercises/macros/tests/macros.rs +62 -0
- data/tracks/rust/exercises/simple-linked-list/.gitignore +7 -0
- data/tracks/rust/exercises/simple-linked-list/.meta/hints.md +34 -0
- data/tracks/rust/exercises/simple-linked-list/Cargo.toml +5 -0
- data/tracks/rust/exercises/simple-linked-list/README.md +96 -0
- data/tracks/rust/exercises/simple-linked-list/example.rs +87 -0
- data/tracks/rust/exercises/simple-linked-list/src/lib.rs +46 -0
- data/tracks/rust/exercises/simple-linked-list/tests/simple-linked-list.rs +91 -0
- data/tracks/swift/.travis.yml +1 -1
- data/tracks/swift/config.json +24 -0
- data/tracks/swift/exercises/isbn-verifier/Package.swift +5 -0
- data/tracks/swift/exercises/isbn-verifier/README.md +39 -0
- data/tracks/swift/exercises/isbn-verifier/Sources/IsbnVerifier.swift +1 -0
- data/tracks/swift/exercises/isbn-verifier/Sources/IsbnVerifierExample.swift +35 -0
- data/tracks/swift/exercises/isbn-verifier/Tests/IsbnVerifierTests/IsbnVerifierTests.swift +75 -0
- data/tracks/swift/exercises/isbn-verifier/Tests/LinuxMain.swift +6 -0
- data/tracks/swift/exercises/two-fer/Package.swift +5 -0
- data/tracks/swift/exercises/two-fer/README.md +54 -0
- data/tracks/swift/exercises/two-fer/Sources/TwoFer.swift +1 -0
- data/tracks/swift/exercises/two-fer/Sources/TwoFerExample.swift +6 -0
- data/tracks/swift/exercises/two-fer/Tests/LinuxMain.swift +6 -0
- data/tracks/swift/exercises/two-fer/Tests/TwoFerTests/TwoFerTests.swift +25 -0
- metadata +71 -2
|
@@ -58,15 +58,13 @@ would get the same thing as the Caesar Cipher.
|
|
|
58
58
|
|
|
59
59
|
The weakest link in any cipher is the human being. Let's make your
|
|
60
60
|
substitution cipher a little more fault tolerant by providing a source
|
|
61
|
-
of randomness and ensuring that the key
|
|
62
|
-
capital letters.
|
|
61
|
+
of randomness and ensuring that the key contains only lowercase letters.
|
|
63
62
|
|
|
64
63
|
If someone doesn't submit a key at all, generate a truly random key of
|
|
65
|
-
at least 100 characters in length
|
|
66
|
-
syntax means instance variable)
|
|
64
|
+
at least 100 characters in length.
|
|
67
65
|
|
|
68
|
-
If the key submitted
|
|
69
|
-
|
|
66
|
+
If the key submitted is not composed only of lowercase letters, your
|
|
67
|
+
solution should handle the error in a language-appropriate way.
|
|
70
68
|
|
|
71
69
|
## Extensions
|
|
72
70
|
|
data/tracks/lua/.gitignore
CHANGED
data/tracks/lua/config.json
CHANGED
|
@@ -942,6 +942,18 @@
|
|
|
942
942
|
],
|
|
943
943
|
"unlocked_by": "list-ops",
|
|
944
944
|
"uuid": "09df8b87-c2cf-44a7-879c-96c9030cf27b"
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
"core": false,
|
|
948
|
+
"difficulty": 3,
|
|
949
|
+
"slug": "isbn-verifier",
|
|
950
|
+
"topics": [
|
|
951
|
+
"mathematics",
|
|
952
|
+
"control_flow_loops",
|
|
953
|
+
"strings"
|
|
954
|
+
],
|
|
955
|
+
"unlocked_by": "run-length-encoding",
|
|
956
|
+
"uuid": "a9a6a2c7-2a58-4090-b538-5a275c521fe0"
|
|
945
957
|
}
|
|
946
958
|
],
|
|
947
959
|
"foregone": [],
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Isbn Verifier
|
|
2
|
+
|
|
3
|
+
Check if a given ISBN-10 is valid.
|
|
4
|
+
|
|
5
|
+
## Functionality
|
|
6
|
+
|
|
7
|
+
Given an unkown 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
|
+
## Running the tests
|
|
39
|
+
|
|
40
|
+
To run the tests, run the command `busted .` from within the exercise directory.
|
|
41
|
+
|
|
42
|
+
## Further information
|
|
43
|
+
|
|
44
|
+
For more detailed information about the Lua track, including how to get help if
|
|
45
|
+
you're having trouble, please visit the exercism.io [Lua language page](http://exercism.io/languages/lua/about).
|
|
46
|
+
|
|
47
|
+
## Source
|
|
48
|
+
|
|
49
|
+
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)
|
|
50
|
+
|
|
51
|
+
## Submitting Incomplete Solutions
|
|
52
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
return {
|
|
2
|
+
valid = function(isbn)
|
|
3
|
+
isbn = isbn:gsub('-', '')
|
|
4
|
+
|
|
5
|
+
if not isbn:match('^%d%d%d%d%d%d%d%d%d[%dX]$') then
|
|
6
|
+
return false
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
local sum = 0
|
|
10
|
+
for i = 1, 10 do
|
|
11
|
+
sum = sum + (11 - i) * (tonumber(isbn:sub(i, i)) or 10)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
return sum % 11 == 0
|
|
15
|
+
end
|
|
16
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
local valid = require('isbn-verifier').valid
|
|
2
|
+
|
|
3
|
+
describe('isbn-verifier', function()
|
|
4
|
+
it('valid isbn number', function()
|
|
5
|
+
assert.is_true(valid('3-598-21508-8'))
|
|
6
|
+
end)
|
|
7
|
+
|
|
8
|
+
it('invalid isbn check digit', function()
|
|
9
|
+
assert.is_false(valid('3-598-21508-9'))
|
|
10
|
+
end)
|
|
11
|
+
|
|
12
|
+
it('valid isbn number with a check digit of 10', function()
|
|
13
|
+
assert.is_true(valid('3-598-21507-X'))
|
|
14
|
+
end)
|
|
15
|
+
|
|
16
|
+
it('check digit is a character other than X', function()
|
|
17
|
+
assert.is_false(valid('3-598-21507-A'))
|
|
18
|
+
end)
|
|
19
|
+
|
|
20
|
+
it('invalid character in isbn', function()
|
|
21
|
+
assert.is_false(valid('3-598-2K507-0'))
|
|
22
|
+
end)
|
|
23
|
+
|
|
24
|
+
it('X is only valid as a check digit', function()
|
|
25
|
+
assert.is_false(valid('3-598-2X507-9'))
|
|
26
|
+
end)
|
|
27
|
+
|
|
28
|
+
it('valid isbn without separating dashes', function()
|
|
29
|
+
assert.is_true(valid('3598215088'))
|
|
30
|
+
end)
|
|
31
|
+
|
|
32
|
+
it('isbn without separating dashes and X as check digit', function()
|
|
33
|
+
assert.is_true(valid('359821507X'))
|
|
34
|
+
end)
|
|
35
|
+
|
|
36
|
+
it('isbn without check digit and dashes', function()
|
|
37
|
+
assert.is_false(valid('359821507'))
|
|
38
|
+
end)
|
|
39
|
+
|
|
40
|
+
it('too long isbn and no dashes', function()
|
|
41
|
+
assert.is_false(valid('3598215078X'))
|
|
42
|
+
end)
|
|
43
|
+
|
|
44
|
+
it('isbn without check digit', function()
|
|
45
|
+
assert.is_false(valid('3-598-21507'))
|
|
46
|
+
end)
|
|
47
|
+
|
|
48
|
+
it('too long isbn', function()
|
|
49
|
+
assert.is_false(valid('3-598-21507-XX'))
|
|
50
|
+
end)
|
|
51
|
+
|
|
52
|
+
it('check digit of X should not be used for 0', function()
|
|
53
|
+
assert.is_false(valid('3-598-21515-X'))
|
|
54
|
+
end)
|
|
55
|
+
end)
|
data/tracks/ocaml/.travis-ci.sh
CHANGED
data/tracks/ocaml/.travis.yml
CHANGED
data/tracks/ocaml/README.md
CHANGED
|
@@ -11,7 +11,7 @@ notes contain a few details specific to Ocaml.
|
|
|
11
11
|
|
|
12
12
|
## Prerequisites
|
|
13
13
|
|
|
14
|
-
The OCaml track assumes installation of OCaml version 4.
|
|
14
|
+
The OCaml track assumes installation of OCaml version 4.06.0, and installation of Core, OUnit, and React (for the Hangman exercise).
|
|
15
15
|
Assuming you have opam, these can be installed with
|
|
16
16
|
```bash
|
|
17
17
|
opam install core ounit react
|
data/tracks/perl6/config.json
CHANGED
|
@@ -288,6 +288,16 @@
|
|
|
288
288
|
|
|
289
289
|
]
|
|
290
290
|
},
|
|
291
|
+
{
|
|
292
|
+
"uuid": "a5d0488e-1a95-4896-8196-541d59dbcea1",
|
|
293
|
+
"slug": "acronym",
|
|
294
|
+
"core": false,
|
|
295
|
+
"unlocked_by": null,
|
|
296
|
+
"difficulty": 3,
|
|
297
|
+
"topics": [
|
|
298
|
+
|
|
299
|
+
]
|
|
300
|
+
},
|
|
291
301
|
{
|
|
292
302
|
"uuid": "1d36c4df-a1c8-454c-b4ec-7bec3c1cbca3",
|
|
293
303
|
"slug": "binary",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Acronym
|
|
2
|
+
|
|
3
|
+
Convert a phrase to its acronym.
|
|
4
|
+
|
|
5
|
+
Techies love their TLA (Three Letter Acronyms)!
|
|
6
|
+
|
|
7
|
+
Help generate some jargon by writing a program that converts a long name
|
|
8
|
+
like Portable Network Graphics to its acronym (PNG).
|
|
9
|
+
|
|
10
|
+
## Resources
|
|
11
|
+
|
|
12
|
+
Remember to check out the Perl 6 [documentation](https://docs.perl6.org/) and
|
|
13
|
+
[resources](https://perl6.org/resources/) pages for information, tips, and
|
|
14
|
+
examples if you get stuck.
|
|
15
|
+
|
|
16
|
+
## Running the tests
|
|
17
|
+
|
|
18
|
+
There is a test suite and module included with the exercise.
|
|
19
|
+
The test suite (a file with the extension `.t`) will attempt to run routines
|
|
20
|
+
from the module (a file with the extension `.pm6`).
|
|
21
|
+
Add/modify routines in the module so that the tests will pass! You can view the
|
|
22
|
+
test data by executing the command `perl6 --doc *.t` (\* being the name of the
|
|
23
|
+
test suite), and run the test suite for the exercise by executing the command
|
|
24
|
+
`prove . --exec=perl6` in the exercise directory.
|
|
25
|
+
You can also add the `-v` flag e.g. `prove . --exec=perl6 -v` to display all
|
|
26
|
+
tests, including any optional tests marked as 'TODO'.
|
|
27
|
+
|
|
28
|
+
## Source
|
|
29
|
+
|
|
30
|
+
Julien Vanier [https://github.com/monkbroc](https://github.com/monkbroc)
|
|
31
|
+
|
|
32
|
+
## Submitting Incomplete Solutions
|
|
33
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env perl6
|
|
2
|
+
use v6;
|
|
3
|
+
use Test;
|
|
4
|
+
use lib my $dir = $?FILE.IO.dirname;
|
|
5
|
+
use JSON::Fast;
|
|
6
|
+
|
|
7
|
+
my Str:D $exercise := 'Acronym';
|
|
8
|
+
my Version:D $version = v1;
|
|
9
|
+
my Str $module //= $exercise;
|
|
10
|
+
plan 8;
|
|
11
|
+
|
|
12
|
+
use-ok $module or bail-out;
|
|
13
|
+
require ::($module);
|
|
14
|
+
|
|
15
|
+
if ::($exercise).^ver !~~ $version {
|
|
16
|
+
warn "\nExercise version mismatch. Further tests may fail!"
|
|
17
|
+
~ "\n$exercise is $(::($exercise).^ver.gist). "
|
|
18
|
+
~ "Test is $($version.gist).\n";
|
|
19
|
+
bail-out 'Example version must match test version.' if %*ENV<EXERCISM>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
require ::($module) <&abbreviate>;
|
|
23
|
+
|
|
24
|
+
my $c-data = from-json $=pod.pop.contents;
|
|
25
|
+
|
|
26
|
+
for $c-data<cases>»<cases>».Array.flat {
|
|
27
|
+
is abbreviate(.<phrase>), |.<expected description>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
=head2 Canonical Data
|
|
31
|
+
=begin code
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
"exercise": "acronym",
|
|
35
|
+
"version": "1.1.0",
|
|
36
|
+
"cases": [
|
|
37
|
+
{
|
|
38
|
+
"description": "Abbreviate a phrase",
|
|
39
|
+
"cases": [
|
|
40
|
+
{
|
|
41
|
+
"description": "basic",
|
|
42
|
+
"property": "abbreviate",
|
|
43
|
+
"phrase": "Portable Network Graphics",
|
|
44
|
+
"expected": "PNG"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"description": "lowercase words",
|
|
48
|
+
"property": "abbreviate",
|
|
49
|
+
"phrase": "Ruby on Rails",
|
|
50
|
+
"expected": "ROR"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"description": "punctuation",
|
|
54
|
+
"property": "abbreviate",
|
|
55
|
+
"phrase": "First In, First Out",
|
|
56
|
+
"expected": "FIFO"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"description": "all caps words",
|
|
60
|
+
"property": "abbreviate",
|
|
61
|
+
"phrase": "PHP: Hypertext Preprocessor",
|
|
62
|
+
"expected": "PHP"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"description": "non-acronym all caps word",
|
|
66
|
+
"property": "abbreviate",
|
|
67
|
+
"phrase": "GNU Image Manipulation Program",
|
|
68
|
+
"expected": "GIMP"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"description": "hyphenated",
|
|
72
|
+
"property": "abbreviate",
|
|
73
|
+
"phrase": "Complementary metal-oxide semiconductor",
|
|
74
|
+
"expected": "CMOS"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
=end code
|
|
82
|
+
|
|
83
|
+
unless %*ENV<EXERCISM> {
|
|
84
|
+
skip-rest 'exercism tests';
|
|
85
|
+
exit;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
subtest 'canonical-data' => {
|
|
89
|
+
(my $c-data-file = "$dir/../../problem-specifications/exercises/{
|
|
90
|
+
$dir.IO.resolve.basename
|
|
91
|
+
}/canonical-data.json".IO.resolve) ~~ :f ??
|
|
92
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'match problem-specifications' !!
|
|
93
|
+
flunk 'problem-specifications file not found';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
INIT { $module = 'Example' if %*ENV<EXERCISM> }
|