trackler 2.2.1.91 → 2.2.1.92
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/diamond/metadata.yml +1 -1
- data/problem-specifications/exercises/food-chain/canonical-data.json +42 -22
- data/problem-specifications/exercises/hello-world/canonical-data.json +2 -1
- data/problem-specifications/exercises/isbn-verifier/metadata.yml +2 -1
- data/problem-specifications/exercises/largest-series-product/canonical-data.json +62 -33
- data/problem-specifications/exercises/leap/canonical-data.json +14 -6
- data/problem-specifications/exercises/list-ops/canonical-data.json +6 -6
- data/problem-specifications/exercises/markdown/canonical-data.json +29 -11
- data/problem-specifications/exercises/minesweeper/canonical-data.json +80 -56
- data/problem-specifications/exercises/minesweeper/metadata.yml +1 -1
- data/problem-specifications/exercises/nth-prime/canonical-data.json +20 -8
- data/problem-specifications/exercises/nucleotide-count/canonical-data.json +17 -7
- data/problem-specifications/exercises/pascals-triangle/canonical-data.json +28 -10
- data/problem-specifications/exercises/perfect-numbers/canonical-data.json +41 -15
- data/problem-specifications/exercises/phone-number/canonical-data.json +44 -16
- data/problem-specifications/exercises/pig-latin/canonical-data.json +68 -24
- data/problem-specifications/exercises/reverse-string/metadata.yml +1 -1
- data/problem-specifications/exercises/rna-transcription/canonical-data.json +17 -7
- data/problem-specifications/exercises/roman-numerals/canonical-data.json +56 -20
- data/problem-specifications/exercises/rotational-cipher/canonical-data.json +42 -22
- data/problem-specifications/exercises/saddle-points/canonical-data.json +34 -24
- data/problem-specifications/exercises/scrabble-score/canonical-data.json +35 -13
- data/problem-specifications/exercises/secret-handshake/canonical-data.json +34 -12
- data/problem-specifications/exercises/sieve/canonical-data.json +16 -6
- data/problem-specifications/exercises/space-age/canonical-data.json +34 -18
- data/problem-specifications/exercises/spiral-matrix/canonical-data.json +19 -7
- data/problem-specifications/exercises/sublist/canonical-data.json +69 -35
- data/problem-specifications/exercises/twelve-days/canonical-data.json +61 -31
- data/problem-specifications/exercises/variable-length-quantity/canonical-data.json +79 -27
- data/problem-specifications/exercises/zebra-puzzle/canonical-data.json +3 -1
- data/tracks/csharp/exercises/accumulate/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/allergies/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/alphametics/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/bank-account/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/beer-song/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/clock/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/custom-set/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/diamond/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/difference-of-squares/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/diffie-hellman/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/dot-dsl/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/food-chain/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/forth/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/hangman/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/house/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/list-ops/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/markdown/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/nth-prime/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/nucleotide-count/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/palindrome-products/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/proverb/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/react/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/roman-numerals/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/saddle-points/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/sgf-parsing/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/simple-linked-list/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/sublist/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/sum-of-multiples/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/twelve-days/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/variable-length-quantity/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/word-search/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/wordy/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/zebra-puzzle/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/csharp/exercises/zipper/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/delphi/exercises/secret-handshake/uTestSecretHandshake.pas +1 -1
- data/tracks/elixir/config/exercise_readme.go.tmpl +34 -4
- data/tracks/elixir/exercises/accumulate/README.md +1 -6
- data/tracks/elixir/exercises/acronym/README.md +1 -4
- data/tracks/elixir/exercises/all-your-base/README.md +2 -5
- data/tracks/elixir/exercises/allergies/README.md +1 -4
- data/tracks/elixir/exercises/anagram/README.md +1 -3
- data/tracks/elixir/exercises/atbash-cipher/README.md +3 -4
- data/tracks/elixir/exercises/bank-account/README.md +1 -4
- data/tracks/elixir/exercises/beer-song/README.md +3 -5
- data/tracks/elixir/exercises/binary-search-tree/README.md +43 -0
- data/tracks/elixir/exercises/binary-search/README.md +1 -3
- data/tracks/elixir/exercises/binary/README.md +3 -3
- data/tracks/elixir/exercises/bob/README.md +2 -2
- data/tracks/elixir/exercises/bowling/README.md +21 -9
- data/tracks/elixir/exercises/bracket-push/README.md +1 -3
- data/tracks/elixir/exercises/change/README.md +2 -4
- data/tracks/elixir/exercises/clock/README.md +1 -3
- data/tracks/elixir/exercises/collatz-conjecture/README.md +2 -4
- data/tracks/elixir/exercises/connect/README.md +2 -5
- data/tracks/elixir/exercises/crypto-square/README.md +11 -11
- data/tracks/elixir/exercises/custom-set/README.md +1 -4
- data/tracks/elixir/exercises/diamond/README.md +7 -9
- data/tracks/elixir/exercises/difference-of-squares/README.md +1 -3
- data/tracks/elixir/exercises/diffie-hellman/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/elixir/exercises/diffie-hellman/README.md +1 -3
- data/tracks/elixir/exercises/dominoes/README.md +4 -7
- data/tracks/elixir/exercises/dot-dsl/README.md +2 -5
- data/tracks/elixir/exercises/etl/README.md +4 -4
- data/tracks/elixir/exercises/flatten-array/README.md +2 -5
- data/tracks/elixir/exercises/forth/README.md +1 -4
- data/tracks/elixir/exercises/gigasecond/README.md +1 -3
- data/tracks/elixir/exercises/grade-school/README.md +1 -4
- data/tracks/elixir/exercises/grains/README.md +1 -4
- data/tracks/elixir/exercises/grep/README.md +13 -15
- data/tracks/elixir/exercises/hamming/README.md +1 -3
- data/tracks/elixir/exercises/hello-world/README.md +23 -0
- data/tracks/elixir/exercises/hexadecimal/README.md +1 -3
- data/tracks/elixir/exercises/isbn-verifier/README.md +26 -24
- data/tracks/elixir/exercises/isogram/README.md +3 -4
- data/tracks/elixir/exercises/kindergarten-garden/README.md +14 -16
- data/tracks/elixir/exercises/largest-series-product/README.md +1 -3
- data/tracks/elixir/exercises/leap/README.md +2 -4
- data/tracks/elixir/exercises/list-ops/README.md +1 -4
- data/tracks/elixir/exercises/luhn/README.md +8 -10
- data/tracks/elixir/exercises/markdown/README.md +1 -4
- data/tracks/elixir/exercises/matrix/README.md +7 -7
- data/tracks/elixir/exercises/meetup/README.md +17 -16
- data/tracks/elixir/exercises/minesweeper/README.md +1 -4
- data/tracks/elixir/exercises/nth-prime/README.md +1 -3
- data/tracks/elixir/exercises/nucleotide-count/README.md +9 -25
- data/tracks/elixir/exercises/ocr-numbers/README.md +7 -9
- data/tracks/elixir/exercises/palindrome-products/README.md +16 -19
- data/tracks/elixir/exercises/pangram/README.md +2 -4
- data/tracks/elixir/exercises/parallel-letter-frequency/README.md +1 -4
- data/tracks/elixir/exercises/pascals-triangle/README.md +3 -5
- data/tracks/elixir/exercises/perfect-numbers/README.md +3 -5
- data/tracks/elixir/exercises/phone-number/README.md +5 -6
- data/tracks/elixir/exercises/pig-latin/README.md +1 -3
- data/tracks/elixir/exercises/poker/README.md +1 -3
- data/tracks/elixir/exercises/prime-factors/README.md +1 -3
- data/tracks/elixir/exercises/protein-translation/README.md +3 -6
- data/tracks/elixir/exercises/pythagorean-triplet/README.md +4 -6
- data/tracks/elixir/exercises/queen-attack/README.md +2 -4
- data/tracks/elixir/exercises/rail-fence-cipher/README.md +13 -10
- data/tracks/elixir/exercises/raindrops/README.md +1 -3
- data/tracks/elixir/exercises/rna-transcription/README.md +2 -4
- data/tracks/elixir/exercises/robot-simulator/README.md +1 -3
- data/tracks/elixir/exercises/roman-numerals/README.md +2 -4
- data/tracks/elixir/exercises/rotational-cipher/README.md +3 -4
- data/tracks/elixir/exercises/run-length-encoding/README.md +5 -7
- data/tracks/elixir/exercises/saddle-points/README.md +3 -5
- data/tracks/elixir/exercises/say/README.md +1 -3
- data/tracks/elixir/exercises/scale-generator/README.md +1 -5
- data/tracks/elixir/exercises/scrabble-score/README.md +4 -4
- data/tracks/elixir/exercises/secret-handshake/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/elixir/exercises/secret-handshake/README.md +4 -4
- data/tracks/elixir/exercises/series/README.md +1 -3
- data/tracks/elixir/exercises/sieve/README.md +1 -3
- data/tracks/elixir/exercises/simple-cipher/README.md +6 -10
- data/tracks/elixir/exercises/simple-linked-list/README.md +1 -3
- data/tracks/elixir/exercises/space-age/README.md +2 -4
- data/tracks/elixir/exercises/spiral-matrix/README.md +5 -5
- data/tracks/elixir/exercises/strain/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/elixir/exercises/strain/README.md +1 -3
- data/tracks/elixir/exercises/sublist/README.md +1 -4
- data/tracks/elixir/exercises/sum-of-multiples/README.md +4 -9
- data/tracks/elixir/exercises/tournament/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/elixir/exercises/tournament/README.md +6 -9
- data/tracks/elixir/exercises/transpose/README.md +6 -7
- data/tracks/elixir/exercises/triangle/README.md +10 -9
- data/tracks/elixir/exercises/twelve-days/README.md +2 -4
- data/tracks/elixir/exercises/word-count/README.md +2 -5
- data/tracks/elixir/exercises/wordy/README.md +1 -8
- data/tracks/elixir/exercises/zipper/README.md +2 -5
- data/tracks/fortran/README.md +1 -1
- data/tracks/fsharp/config/exercise_readme.go.tmpl +0 -3
- data/tracks/fsharp/exercises/accumulate/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/alphametics/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/beer-song/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/diamond/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/difference-of-squares/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/diffie-hellman/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/food-chain/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/gigasecond/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/grade-school/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/grains/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/house/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/lens-person/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/linked-list/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/nth-prime/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/palindrome-products/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/parallel-letter-frequency/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/poker/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/proverb/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/raindrops/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/rna-transcription/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/space-age/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/twelve-days/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fsharp/exercises/wordy/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/java/exercises/acronym/.meta/version +1 -1
- data/tracks/java/exercises/acronym/src/test/java/AcronymTest.java +6 -6
- data/tracks/java/exercises/raindrops/.meta/version +1 -0
- data/tracks/java/exercises/raindrops/src/test/java/RaindropConverterTest.java +3 -1
- data/tracks/java/exercises/transpose/src/test/java/TransposeTest.java +5 -5
- data/tracks/java/exercises/word-count/.meta/src/reference/java/WordCount.java +1 -1
- data/tracks/java/exercises/word-count/.meta/version +1 -0
- data/tracks/java/exercises/word-count/src/test/java/WordCountTest.java +73 -3
- data/tracks/mips/config/exercise_readme.go.tmpl +0 -3
- data/tracks/perl5/config/exercise_readme.go.tmpl +0 -3
- data/tracks/php/exercises/bob/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/php/exercises/roman-numerals/roman-numerals_test.php +1 -1
- data/tracks/pony/config/exercise_readme.go.tmpl +0 -3
- data/tracks/python/config.json +14 -0
- data/tracks/python/exercises/isbn-verifier/README.md +43 -0
- data/tracks/python/exercises/isbn-verifier/example.py +8 -0
- data/tracks/python/exercises/isbn-verifier/isbn_verifier.py +2 -0
- data/tracks/python/exercises/isbn-verifier/isbn_verifier_test.py +54 -0
- data/tracks/rust/exercises/atbash-cipher/example.rs +0 -2
- data/tracks/rust/exercises/bracket-push/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/rust/exercises/crypto-square/example.rs +0 -2
- data/tracks/rust/exercises/etl/example.rs +0 -1
- data/tracks/rust/exercises/forth/example.rs +0 -1
- data/tracks/rust/exercises/largest-series-product/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/rust/exercises/pangram/example.rs +0 -1
- data/tracks/rust/exercises/parallel-letter-frequency/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/rust/exercises/scrabble-score/tests/scrabble-score.rs +9 -2
- data/tracks/rust/exercises/space-age/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/rust/exercises/triangle/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/bank-account/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/connect/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/gigasecond/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/hamming/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/hello-world/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/leap/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/nucleotide-count/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/parallel-letter-frequency/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/phone-number/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/robot-name/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/roman-numerals/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/scala/exercises/variable-length-quantity/{HINTS.md → .meta/hints.md} +0 -0
- metadata +87 -86
- data/tracks/elixir/docs/EXERCISE_README_INSERT.md +0 -35
- data/tracks/fsharp/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/mips/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/perl5/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/pony/docs/EXERCISE_README_INSERT.md +0 -0
@@ -3,14 +3,14 @@
|
|
3
3
|
Search a file for lines matching a regular expression pattern. Return the line
|
4
4
|
number and contents of each matching line.
|
5
5
|
|
6
|
-
The Unix [`grep`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html) command can be used to search for lines in one or more files
|
6
|
+
The Unix [`grep`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html) command can be used to search for lines in one or more files
|
7
7
|
that match a user-provided search query (known as the *pattern*).
|
8
8
|
|
9
9
|
The `grep` command takes three arguments:
|
10
10
|
|
11
|
-
1. The pattern used to match lines in a file.
|
11
|
+
1. The pattern used to match lines in a file.
|
12
12
|
2. Zero or more flags to customize the matching behavior.
|
13
|
-
3. One or more files in which to search for matching lines.
|
13
|
+
3. One or more files in which to search for matching lines.
|
14
14
|
|
15
15
|
Your task is to implement the `grep` function, which should read the contents
|
16
16
|
of the specified files, find the lines that match the specified pattern
|
@@ -20,18 +20,18 @@ in the first file being output first.
|
|
20
20
|
|
21
21
|
As an example, suppose there is a file named "input.txt" with the following contents:
|
22
22
|
|
23
|
-
|
23
|
+
```text
|
24
24
|
hello
|
25
25
|
world
|
26
26
|
hello again
|
27
|
-
|
27
|
+
```
|
28
28
|
|
29
29
|
If we were to call `grep "hello" input.txt`, the returned string should be:
|
30
30
|
|
31
|
-
|
31
|
+
```text
|
32
32
|
hello
|
33
33
|
hello again
|
34
|
-
|
34
|
+
```
|
35
35
|
|
36
36
|
### Flags
|
37
37
|
|
@@ -46,18 +46,18 @@ As said earlier, the `grep` command should also support the following flags:
|
|
46
46
|
If we run `grep -n "hello" input.txt`, the `-n` flag will require the matching
|
47
47
|
lines to be prefixed with its line number:
|
48
48
|
|
49
|
-
|
49
|
+
```text
|
50
50
|
1:hello
|
51
51
|
3:hello again
|
52
|
-
|
52
|
+
```
|
53
53
|
|
54
|
-
And if we run `grep -i "HELLO" input.txt`, we'll do a case-insensitive match,
|
54
|
+
And if we run `grep -i "HELLO" input.txt`, we'll do a case-insensitive match,
|
55
55
|
and the output will be:
|
56
56
|
|
57
|
-
|
57
|
+
```text
|
58
58
|
hello
|
59
59
|
hello again
|
60
|
-
|
60
|
+
```
|
61
61
|
|
62
62
|
The `grep` command should support multiple flags at once.
|
63
63
|
|
@@ -69,11 +69,9 @@ print the names of files that do not contain the string "hello".
|
|
69
69
|
Execute the tests with:
|
70
70
|
|
71
71
|
```bash
|
72
|
-
$ elixir
|
72
|
+
$ elixir grep_test.exs
|
73
73
|
```
|
74
74
|
|
75
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
76
|
-
|
77
75
|
### Pending tests
|
78
76
|
|
79
77
|
In the test suites, all but the first test have been skipped.
|
@@ -40,11 +40,9 @@ of equal length differently.
|
|
40
40
|
Execute the tests with:
|
41
41
|
|
42
42
|
```bash
|
43
|
-
$ elixir
|
43
|
+
$ elixir hamming_test.exs
|
44
44
|
```
|
45
45
|
|
46
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
47
|
-
|
48
46
|
### Pending tests
|
49
47
|
|
50
48
|
In the test suites, all but the first test have been skipped.
|
@@ -22,6 +22,29 @@ Execute the tests with:
|
|
22
22
|
$ elixir hello_world_test.exs
|
23
23
|
```
|
24
24
|
|
25
|
+
### Pending tests
|
26
|
+
|
27
|
+
In the test suites, all but the first test have been skipped.
|
28
|
+
|
29
|
+
Once you get a test passing, you can unskip the next one by
|
30
|
+
commenting out the relevant `@tag :pending` with a `#` symbol.
|
31
|
+
|
32
|
+
For example:
|
33
|
+
|
34
|
+
```elixir
|
35
|
+
# @tag :pending
|
36
|
+
test "shouting" do
|
37
|
+
assert Bob.hey("WATCH OUT!") == "Whoa, chill out!"
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
Or, you can enable all the tests by commenting out the
|
42
|
+
`ExUnit.configure` line in the test suite.
|
43
|
+
|
44
|
+
```elixir
|
45
|
+
# ExUnit.configure exclude: :pending, trace: true
|
46
|
+
```
|
47
|
+
|
25
48
|
For more detailed information about the Elixir track, please
|
26
49
|
see the [help page](http://exercism.io/languages/elixir).
|
27
50
|
|
@@ -12,11 +12,9 @@ The program should handle invalid hexadecimal strings.
|
|
12
12
|
Execute the tests with:
|
13
13
|
|
14
14
|
```bash
|
15
|
-
$ elixir
|
15
|
+
$ elixir hexadecimal_test.exs
|
16
16
|
```
|
17
17
|
|
18
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
19
|
-
|
20
18
|
### Pending tests
|
21
19
|
|
22
20
|
In the test suites, all but the first test have been skipped.
|
@@ -1,42 +1,45 @@
|
|
1
|
-
# ISBN
|
1
|
+
# ISBN Verifier
|
2
2
|
|
3
|
-
|
3
|
+
The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is used to validate book identification
|
4
|
+
numbers. These normally contain dashes and look like: `3-598-21508-8`
|
4
5
|
|
5
|
-
##
|
6
|
+
## ISBN
|
6
7
|
|
7
|
-
|
8
|
-
Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN.
|
8
|
+
The ISBN-10 format is 9 digits (0 to 9) plus one check character (either a digit or an X only). In the case the check character is an X, this represents the value '10'. These may be communicated with or without hyphens, and can be checked for their validity by the following formula:
|
9
9
|
|
10
|
-
|
10
|
+
```
|
11
|
+
(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0
|
12
|
+
```
|
11
13
|
|
12
|
-
|
14
|
+
If the result is 0, then it is a valid ISBN-10, otherwise it is invalid.
|
15
|
+
|
16
|
+
## Example
|
17
|
+
|
18
|
+
Let's take the ISBN-10 `3-598-21508-8`. We plug it in to the formula, and get:
|
19
|
+
```
|
20
|
+
(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 == 0
|
21
|
+
```
|
13
22
|
|
14
|
-
|
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.
|
23
|
+
Since the result is 0, this proves that our ISBN is valid.
|
18
24
|
|
19
|
-
|
20
|
-
|
25
|
+
## Task
|
26
|
+
|
27
|
+
Given a string the program should check if the provided string is a valid ISBN-10.
|
28
|
+
Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN.
|
21
29
|
|
22
|
-
|
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
|
30
|
+
The program should be able to verify ISBN-10 both with and without separating dashes.
|
25
31
|
|
26
|
-
Which proves that the ISBN is valid.
|
27
32
|
|
28
33
|
## Caveats
|
29
34
|
|
30
|
-
Converting from
|
31
|
-
|
35
|
+
Converting from strings to numbers can be tricky in certain languages.
|
36
|
+
Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representing '10'). For instance `3-598-21507-X` is a valid ISBN-10.
|
32
37
|
|
33
38
|
## Bonus tasks
|
34
39
|
|
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
|
-
|
40
|
+
* Generate a valid ISBN-13 from the input ISBN-10 (and maybe verify it again with a derived verifier).
|
39
41
|
|
42
|
+
* Generate valid ISBN, maybe even from a given starting ISBN.
|
40
43
|
## Running tests
|
41
44
|
|
42
45
|
Execute the tests with:
|
@@ -45,7 +48,6 @@ Execute the tests with:
|
|
45
48
|
$ elixir isbn_verifier_test.exs
|
46
49
|
```
|
47
50
|
|
48
|
-
|
49
51
|
### Pending tests
|
50
52
|
|
51
53
|
In the test suites, all but the first test have been skipped.
|
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
Determine if a word or phrase is an isogram.
|
4
4
|
|
5
|
-
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter.
|
5
|
+
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.
|
6
6
|
|
7
7
|
Examples of isograms:
|
8
8
|
|
9
9
|
- lumberjacks
|
10
10
|
- background
|
11
11
|
- downstream
|
12
|
+
- six-year-old
|
12
13
|
|
13
14
|
The word *isograms*, however, is not an isogram, because the s repeats.
|
14
15
|
|
@@ -17,11 +18,9 @@ The word *isograms*, however, is not an isogram, because the s repeats.
|
|
17
18
|
Execute the tests with:
|
18
19
|
|
19
20
|
```bash
|
20
|
-
$ elixir
|
21
|
+
$ elixir isogram_test.exs
|
21
22
|
```
|
22
23
|
|
23
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
24
|
-
|
25
24
|
### Pending tests
|
26
25
|
|
27
26
|
In the test suites, all but the first test have been skipped.
|
@@ -3,19 +3,19 @@
|
|
3
3
|
Given a diagram, determine which plants each child in the kindergarten class is
|
4
4
|
responsible for.
|
5
5
|
|
6
|
-
The kindergarten class is learning about growing plants. The
|
6
|
+
The kindergarten class is learning about growing plants. The teacher
|
7
7
|
thought it would be a good idea to give them actual seeds, plant them in
|
8
8
|
actual dirt, and grow actual plants.
|
9
9
|
|
10
10
|
They've chosen to grow grass, clover, radishes, and violets.
|
11
11
|
|
12
|
-
To this end,
|
13
|
-
|
14
|
-
|
12
|
+
To this end, the children have put little cups along the window sills, and
|
13
|
+
planted one type of plant in each cup, choosing randomly from the available
|
14
|
+
types of seeds.
|
15
15
|
|
16
|
-
```
|
16
|
+
```text
|
17
17
|
[window][window][window]
|
18
|
-
........................ # each dot represents a
|
18
|
+
........................ # each dot represents a cup
|
19
19
|
........................
|
20
20
|
```
|
21
21
|
|
@@ -25,27 +25,27 @@ There are 12 children in the class:
|
|
25
25
|
- Eve, Fred, Ginny, Harriet,
|
26
26
|
- Ileana, Joseph, Kincaid, and Larry.
|
27
27
|
|
28
|
-
Each child gets 4 cups, two on each row.
|
29
|
-
|
28
|
+
Each child gets 4 cups, two on each row. Their teacher assigns cups to
|
29
|
+
the children alphabetically by their names.
|
30
30
|
|
31
31
|
The following diagram represents Alice's plants:
|
32
32
|
|
33
|
-
```
|
33
|
+
```text
|
34
34
|
[window][window][window]
|
35
35
|
VR......................
|
36
36
|
RG......................
|
37
37
|
```
|
38
38
|
|
39
|
-
|
40
|
-
row
|
39
|
+
In the first row, nearest the windows, she has a violet and a radish. In the
|
40
|
+
second row she has a radish and some grass.
|
41
41
|
|
42
42
|
Your program will be given the plants from left-to-right starting with
|
43
43
|
the row nearest the windows. From this, it should be able to determine
|
44
|
-
which plants belong to
|
44
|
+
which plants belong to each student.
|
45
45
|
|
46
46
|
For example, if it's told that the garden looks like so:
|
47
47
|
|
48
|
-
```
|
48
|
+
```text
|
49
49
|
[window][window][window]
|
50
50
|
VRCGVVRVCGGCCGVRGCVCGCGV
|
51
51
|
VRCCCGCRRGVCGCRVVCVGCGCV
|
@@ -64,11 +64,9 @@ While asking for Bob's plants would yield:
|
|
64
64
|
Execute the tests with:
|
65
65
|
|
66
66
|
```bash
|
67
|
-
$ elixir
|
67
|
+
$ elixir kindergarten_garden_test.exs
|
68
68
|
```
|
69
69
|
|
70
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
71
|
-
|
72
70
|
### Pending tests
|
73
71
|
|
74
72
|
In the test suites, all but the first test have been skipped.
|
@@ -18,11 +18,9 @@ the largest product for a series of 6 digits is 23520.
|
|
18
18
|
Execute the tests with:
|
19
19
|
|
20
20
|
```bash
|
21
|
-
$ elixir
|
21
|
+
$ elixir largest_series_product_test.exs
|
22
22
|
```
|
23
23
|
|
24
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
25
|
-
|
26
24
|
### Pending tests
|
27
25
|
|
28
26
|
In the test suites, all but the first test have been skipped.
|
@@ -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
|
-
```
|
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
|
@@ -31,11 +31,9 @@ phenomenon, go watch [this youtube video][video].
|
|
31
31
|
Execute the tests with:
|
32
32
|
|
33
33
|
```bash
|
34
|
-
$ elixir
|
34
|
+
$ elixir leap_test.exs
|
35
35
|
```
|
36
36
|
|
37
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
38
|
-
|
39
37
|
### Pending tests
|
40
38
|
|
41
39
|
In the test suites, all but the first test have been skipped.
|
@@ -11,11 +11,9 @@ without using existing functions.
|
|
11
11
|
Execute the tests with:
|
12
12
|
|
13
13
|
```bash
|
14
|
-
$ elixir
|
14
|
+
$ elixir list_ops_test.exs
|
15
15
|
```
|
16
16
|
|
17
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
18
|
-
|
19
17
|
### Pending tests
|
20
18
|
|
21
19
|
In the test suites, all but the first test have been skipped.
|
@@ -42,6 +40,5 @@ Or, you can enable all the tests by commenting out the
|
|
42
40
|
For more detailed information about the Elixir track, please
|
43
41
|
see the [help page](http://exercism.io/languages/elixir).
|
44
42
|
|
45
|
-
|
46
43
|
## Submitting Incomplete Solutions
|
47
44
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -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
|
|
@@ -69,11 +69,9 @@ Sum the digits
|
|
69
69
|
Execute the tests with:
|
70
70
|
|
71
71
|
```bash
|
72
|
-
$ elixir
|
72
|
+
$ elixir luhn_test.exs
|
73
73
|
```
|
74
74
|
|
75
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
76
|
-
|
77
75
|
### Pending tests
|
78
76
|
|
79
77
|
In the test suites, all but the first test have been skipped.
|
@@ -19,11 +19,9 @@ important thing is to make the code better!
|
|
19
19
|
Execute the tests with:
|
20
20
|
|
21
21
|
```bash
|
22
|
-
$ elixir
|
22
|
+
$ elixir markdown_test.exs
|
23
23
|
```
|
24
24
|
|
25
|
-
(Replace `bob_test.exs` with the name of the test file.)
|
26
|
-
|
27
25
|
### Pending tests
|
28
26
|
|
29
27
|
In the test suites, all but the first test have been skipped.
|
@@ -50,6 +48,5 @@ Or, you can enable all the tests by commenting out the
|
|
50
48
|
For more detailed information about the Elixir track, please
|
51
49
|
see the [help page](http://exercism.io/languages/elixir).
|
52
50
|
|
53
|
-
|
54
51
|
## Submitting Incomplete Solutions
|
55
52
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|