trackler 2.2.1.71 → 2.2.1.72
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/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
@@ -0,0 +1,19 @@
|
|
1
|
+
exercise: Acronym
|
2
|
+
version: 1
|
3
|
+
plan: 8
|
4
|
+
imports: '&abbreviate'
|
5
|
+
tests: |-
|
6
|
+
|
7
|
+
for $c-data<cases>»<cases>».Array.flat {
|
8
|
+
is abbreviate(.<phrase>), |.<expected description>;
|
9
|
+
}
|
10
|
+
|
11
|
+
unit: module
|
12
|
+
example: |-
|
13
|
+
sub abbreviate ($phrase) is export {
|
14
|
+
[~] $phrase.uc.comb(/\w+/).map: *.substr(0, 1);
|
15
|
+
}
|
16
|
+
|
17
|
+
stub: |-
|
18
|
+
sub abbreviate ($phrase) is export {
|
19
|
+
}
|
@@ -5,9 +5,9 @@ use lib my $dir = $?FILE.IO.dirname;
|
|
5
5
|
use JSON::Fast;
|
6
6
|
|
7
7
|
my Str:D $exercise := 'WordCount';
|
8
|
-
my Version:D $version =
|
8
|
+
my Version:D $version = v2;
|
9
9
|
my Str $module //= $exercise;
|
10
|
-
plan
|
10
|
+
plan 13;
|
11
11
|
|
12
12
|
use-ok $module or bail-out;
|
13
13
|
require ::($module);
|
@@ -140,6 +140,15 @@ is-deeply (% = .<input>.&count-words), |.<expected description> for @($c-data<ca
|
|
140
140
|
"large": 2,
|
141
141
|
"and": 1
|
142
142
|
}
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"description": "multiple spaces not detected as a word",
|
146
|
+
"property": "countwords",
|
147
|
+
"input": " multiple whitespaces",
|
148
|
+
"expected": {
|
149
|
+
"multiple": 1,
|
150
|
+
"whitespaces": 1
|
151
|
+
}
|
143
152
|
}
|
144
153
|
]
|
145
154
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
- [The Pony Tutorial](https://tutorial.ponylang.org/)
|
4
4
|
- [Pony Patterns](https://patterns.ponylang.org/)
|
5
|
-
- [Standard Library Documentation](
|
5
|
+
- [Standard Library Documentation](https://stdlib.ponylang.org/)
|
6
6
|
- [Mailing List](https://pony.groups.io/g/pony)
|
7
7
|
- [IRC Channel](https://webchat.freenode.net/?channels=%23ponylang)
|
@@ -7,6 +7,4 @@ compiler, the Pulp build tool and the Bower package manager.
|
|
7
7
|
|
8
8
|
npm install --global purescript pulp bower
|
9
9
|
|
10
|
-
More information can be found in [the Purescript repository]
|
11
|
-
|
12
|
-
[ps-repo]: (https://github.com/purescript/purescript/blob/master/INSTALL.md).
|
10
|
+
More information can be found in [the Purescript repository](https://github.com/purescript/purescript/blob/master/INSTALL.md).
|
data/tracks/python/config.json
CHANGED
@@ -67,4 +67,9 @@ test_that("normalize case", {
|
|
67
67
|
list("go" = 3, "stop" = 2))
|
68
68
|
})
|
69
69
|
|
70
|
+
test_that("multiple whitespaces", {
|
71
|
+
expect_equal_pairs(word_count(" multiple whitespaces "),
|
72
|
+
list("multiple" = 1, "whitespaces" = 1))
|
73
|
+
})
|
74
|
+
|
70
75
|
message("All tests passed for exercise: word-count")
|
data/tracks/ruby/README.md
CHANGED
@@ -33,9 +33,14 @@ A few exercises use a custom test template:
|
|
33
33
|
|
34
34
|
### BookKeeping::VERSION
|
35
35
|
|
36
|
-
For some, even perhaps many, of the exercises, you will find a
|
37
|
-
|
38
|
-
|
36
|
+
For some, even perhaps many, of the exercises, you will find a reference
|
37
|
+
to the `BookKeeping` module, but this is only included when tests have
|
38
|
+
been generated; see [Generated Test Suites](#generated-test-suites).
|
39
|
+
This `VERSION` number helps make sure exercise solvers and exercise
|
40
|
+
reviewers know which revision of the test suite they are talking
|
41
|
+
about, and it theoretically helps avoid reviewer feedback like
|
42
|
+
*"Your solution doesn't make the tests pass,"* if they are looking
|
43
|
+
at a different version of the tests than the solver used.
|
39
44
|
|
40
45
|
### Canonical Data
|
41
46
|
|
@@ -104,12 +109,67 @@ tree -L 1 ~/code/exercism
|
|
104
109
|
|
105
110
|
#### Regenerating a Test Suite
|
106
111
|
|
107
|
-
From
|
112
|
+
From time to time, the [canonical data](https://github.com/exercism/problem-specifications/tree/master/exercises)
|
113
|
+
for an exercise's tests changes, and we need to keep the Ruby version's
|
114
|
+
tests synced up. Regenerating these tests is a quick and easy way to help
|
115
|
+
maintain the track and get involved!
|
108
116
|
|
109
|
-
|
117
|
+
If it's your first time cloning/contributing to the repository, you'll
|
118
|
+
need to install any dependencies via `bundle`:
|
110
119
|
|
111
|
-
|
112
|
-
|
120
|
+
```bash
|
121
|
+
bundle install
|
122
|
+
```
|
123
|
+
|
124
|
+
Be sure that you're working on the most up-to-date version of the repo.
|
125
|
+
From the root of your copy of the repository:
|
126
|
+
|
127
|
+
```bash
|
128
|
+
# Add the exercism repo as upstream if you haven't yet:
|
129
|
+
git remote add upstream https://github.com/exercism/ruby.git
|
130
|
+
|
131
|
+
# Pull down any changes
|
132
|
+
git fetch upstream
|
133
|
+
|
134
|
+
# Merge any upstream changes with your master branch
|
135
|
+
git checkout master
|
136
|
+
git merge upstream/master
|
137
|
+
```
|
138
|
+
|
139
|
+
Depending on your git workflow preferences and the state of your local
|
140
|
+
repo, you may want to do some rebasing.
|
141
|
+
[See the rebasing documentation for more information.](https://help.github.com/articles/about-git-rebase/)
|
142
|
+
|
143
|
+
The generator also depends on the presence of Exercism's `problem-specifications`
|
144
|
+
repository (see the file tree in the section above). Make sure you've got
|
145
|
+
an *up-to-date* version of the specifications in a `problem-specifications`
|
146
|
+
folder that's in a parallel directory to your local copy of the `ruby` repository.
|
147
|
+
|
148
|
+
To check which problems have possibly been updated, run:
|
149
|
+
|
150
|
+
```bash
|
151
|
+
bin/generate --all
|
152
|
+
```
|
153
|
+
|
154
|
+
This will autogenerate all of the test cases for which generators exist.
|
155
|
+
Use `git diff` (or your preferred method) to find out which test files
|
156
|
+
have changed. Some exercises will update because someone updated the
|
157
|
+
description or other exercise metadata. Others will change because the
|
158
|
+
actual test suite has changed. If you find that an exercise's test suite
|
159
|
+
(i.e. the actual tests, not just the line at the test data version number
|
160
|
+
at the top of the tests) has changed, be sure to use `generate` to update
|
161
|
+
the [BookKeeping::VERSION](#bookkeeping-version) number by running:
|
162
|
+
|
163
|
+
```bash
|
164
|
+
bin/generate --update <exercise-slug>
|
165
|
+
```
|
166
|
+
|
167
|
+
Once everything has been regenerated and updated, you're almost ready to
|
168
|
+
submit your changes via pull request. Please be sure to only update one
|
169
|
+
exercise per pull request. Also, please follow the guidelines in the
|
170
|
+
[Pull Requests](#pull-requests) section, being sure to follow the pattern
|
171
|
+
of `<slug>: Regenerate Tests`, where slug is the slug of the exercise that
|
172
|
+
your pull request is regenerating.
|
113
173
|
|
114
174
|
#### Changing a Generated Exercise
|
115
175
|
|
@@ -260,10 +320,13 @@ are constructed using shared metadata, which lives in the [problem-specification
|
|
260
320
|
|
261
321
|
## Contributing Guide
|
262
322
|
|
263
|
-
For an in-depth discussion of how exercism language tracks and exercises work,
|
264
|
-
|
265
|
-
[contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data)
|
323
|
+
For an in-depth discussion of how exercism language tracks and exercises work, please see the
|
324
|
+
[contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data).
|
266
325
|
|
326
|
+
If you're just getting started and looking for a helpful way to get involved,
|
327
|
+
take a look at [regenerating the test suites](#regenerating-a-test-suite),
|
328
|
+
[porting an exercise from another language](https://github.com/exercism/docs/blob/master/you-can-help/implement-an-exercise-from-specification.md),
|
329
|
+
or [creating an automated test generator](#implementing-a-generator).
|
267
330
|
|
268
331
|
## Ruby icon
|
269
332
|
The Ruby icon is the Vienna.rb logo, and is used with permission. Thanks Floor Dress :)
|
data/tracks/rust/config.json
CHANGED
@@ -164,6 +164,16 @@
|
|
164
164
|
"error handling with Result<T, E>"
|
165
165
|
]
|
166
166
|
},
|
167
|
+
{
|
168
|
+
"uuid": "23d82e48-d074-11e7-8fab-cec278b6b50a",
|
169
|
+
"slug": "diffie-hellman",
|
170
|
+
"core": false,
|
171
|
+
"unlocked_by": null,
|
172
|
+
"difficulty": 1,
|
173
|
+
"topics": [
|
174
|
+
"mathematics"
|
175
|
+
]
|
176
|
+
},
|
167
177
|
{
|
168
178
|
"uuid": "79613fd8-b7da-11e7-abc4-cec278b6b50a",
|
169
179
|
"slug": "isogram",
|
@@ -244,6 +254,18 @@
|
|
244
254
|
"Result"
|
245
255
|
]
|
246
256
|
},
|
257
|
+
{
|
258
|
+
"uuid": "10923b0b-c726-44a7-9e02-b775e7b8b237",
|
259
|
+
"slug": "simple-linked-list",
|
260
|
+
"core": false,
|
261
|
+
"unlocked_by": null,
|
262
|
+
"difficulty": 4,
|
263
|
+
"topics": [
|
264
|
+
"lists",
|
265
|
+
"type_conversion",
|
266
|
+
"struct"
|
267
|
+
]
|
268
|
+
},
|
247
269
|
{
|
248
270
|
"uuid": "ddc0c1da-6b65-4ed1-8bdc-5e71cd05f720",
|
249
271
|
"slug": "pascals-triangle",
|
@@ -589,6 +611,18 @@
|
|
589
611
|
"higher-order functions"
|
590
612
|
]
|
591
613
|
},
|
614
|
+
{
|
615
|
+
"uuid": "29583cc6-d56d-4bee-847d-93d74e5a30e7",
|
616
|
+
"slug": "macros",
|
617
|
+
"core": false,
|
618
|
+
"unlocked_by": null,
|
619
|
+
"difficulty": 4,
|
620
|
+
"topics": [
|
621
|
+
"macros",
|
622
|
+
"macros-by-example",
|
623
|
+
"hashmap"
|
624
|
+
]
|
625
|
+
},
|
592
626
|
{
|
593
627
|
"uuid": "94f040d6-3f41-4950-8fe6-acf0945ac83d",
|
594
628
|
"slug": "allergies",
|
@@ -128,3 +128,10 @@ fn test_three_copies_of_first_book_and_2_each_of_remaining() {
|
|
128
128
|
fn test_three_each_of_first_2_books_and_2_each_of_remaining_books() {
|
129
129
|
process_total_case((vec![1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2], vec![vec![1, 2, 3, 4, 5], vec![1, 2, 3, 4, 5], vec![1, 2]]), 75.2);
|
130
130
|
}
|
131
|
+
|
132
|
+
#[test]
|
133
|
+
#[ignore]
|
134
|
+
/// Four groups of four are cheaper than two groups each of five and three
|
135
|
+
fn test_four_groups_of_four_are_cheaper_than_two_groups_each_of_five_and_three() {
|
136
|
+
process_total_case((vec![1,1,2,2,3,3,4,5,1,1,2,2,3,3,4,5], vec![vec![1,2,3,4],vec![1,2,3,5],vec![1,2,3,4],vec![1,2,3,5]]), 102.4);
|
137
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Generated by Cargo
|
2
|
+
# will have compiled files and executables
|
3
|
+
/target/
|
4
|
+
**/*.rs.bk
|
5
|
+
|
6
|
+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
7
|
+
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
|
8
|
+
Cargo.lock
|
9
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Diffie Hellman
|
2
|
+
|
3
|
+
Diffie-Hellman key exchange.
|
4
|
+
|
5
|
+
Alice and Bob use Diffie-Hellman key exchange to share secrets. They
|
6
|
+
start with prime numbers, pick private keys, generate and share public
|
7
|
+
keys, and then generate a shared secret key.
|
8
|
+
|
9
|
+
## Step 0
|
10
|
+
|
11
|
+
The test program supplies prime numbers p and g.
|
12
|
+
|
13
|
+
## Step 1
|
14
|
+
|
15
|
+
Alice picks a private key, a, greater than 1 and less than p. Bob does
|
16
|
+
the same to pick a private key b.
|
17
|
+
|
18
|
+
## Step 2
|
19
|
+
|
20
|
+
Alice calculates a public key A.
|
21
|
+
|
22
|
+
A = g**a mod p
|
23
|
+
|
24
|
+
Using the same p and g, Bob similarly calculates a public key B from his
|
25
|
+
private key b.
|
26
|
+
|
27
|
+
## Step 3
|
28
|
+
|
29
|
+
Alice and Bob exchange public keys. Alice calculates secret key s.
|
30
|
+
|
31
|
+
s = B**a mod p
|
32
|
+
|
33
|
+
Bob calculates
|
34
|
+
|
35
|
+
s = A**b mod p
|
36
|
+
|
37
|
+
The calculations produce the same result! Alice and Bob now share
|
38
|
+
secret s.
|
39
|
+
|
40
|
+
## Rust Installation
|
41
|
+
|
42
|
+
Refer to the [exercism help page][help-page] for Rust installation and learning
|
43
|
+
resources.
|
44
|
+
|
45
|
+
## Writing the Code
|
46
|
+
|
47
|
+
Execute the tests with:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
$ cargo test
|
51
|
+
```
|
52
|
+
|
53
|
+
All but the first test have been ignored. After you get the first test to
|
54
|
+
pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
|
55
|
+
to pass again. The test file is located in the `tests` directory. You can
|
56
|
+
also remove the ignore flag from all the tests to get them to run all at once
|
57
|
+
if you wish.
|
58
|
+
|
59
|
+
Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
|
60
|
+
haven't already, it will help you with organizing your files.
|
61
|
+
|
62
|
+
## Feedback, Issues, Pull Requests
|
63
|
+
|
64
|
+
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!
|
65
|
+
|
66
|
+
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).
|
67
|
+
|
68
|
+
[help-page]: http://exercism.io/languages/rust
|
69
|
+
[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
|
70
|
+
[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
|
71
|
+
|
72
|
+
## Source
|
73
|
+
|
74
|
+
Wikipedia, 1024 bit key from www.cryptopp.com/wiki. [http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange](http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange)
|
75
|
+
|
76
|
+
## Submitting Incomplete Solutions
|
77
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
extern crate rand;
|
2
|
+
|
3
|
+
use rand::distributions::{IndependentSample, Range};
|
4
|
+
|
5
|
+
pub fn private_key(p: u64) -> u64 {
|
6
|
+
Range::new(2, p).ind_sample(&mut rand::thread_rng())
|
7
|
+
}
|
8
|
+
|
9
|
+
pub fn public_key(p: u64, g: u64, a: u64) -> u64 {
|
10
|
+
g.pow(a as u32) % p
|
11
|
+
}
|
12
|
+
|
13
|
+
pub fn secret(p: u64, b_pub: u64, a: u64) -> u64 {
|
14
|
+
b_pub.pow(a as u32) % p
|
15
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
extern crate diffie_hellman;
|
2
|
+
|
3
|
+
use diffie_hellman::*;
|
4
|
+
|
5
|
+
#[test]
|
6
|
+
fn test_private_key_in_range_key() {
|
7
|
+
let primes: Vec<u64> = vec![5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 773, 967,
|
8
|
+
3461, 6131];
|
9
|
+
let private_keys: Vec<u64> = primes.iter().map(|x| private_key(*x)).collect();
|
10
|
+
|
11
|
+
for i in 0..primes.len() {
|
12
|
+
assert!(1 < private_keys[i] && private_keys[i] < primes[i]);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
#[test]
|
17
|
+
#[ignore]
|
18
|
+
fn test_public_key_correct() {
|
19
|
+
let p: u64 = 23;
|
20
|
+
let g: u64 = 5;
|
21
|
+
|
22
|
+
let private_key: u64 = 6;
|
23
|
+
let expected: u64 = 8;
|
24
|
+
|
25
|
+
assert_eq!(public_key(p, g, private_key), expected);
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
#[test]
|
30
|
+
#[ignore]
|
31
|
+
fn test_secret_key_correct() {
|
32
|
+
let p: u64 = 11;
|
33
|
+
let g: u64 = 7;
|
34
|
+
|
35
|
+
let private_key_a = 7;
|
36
|
+
let public_key_b = 8;
|
37
|
+
let secret = secret(p, public_key_b, private_key_a);
|
38
|
+
let expected = 2;
|
39
|
+
|
40
|
+
assert_eq!(secret, expected);
|
41
|
+
}
|
42
|
+
|
43
|
+
#[test]
|
44
|
+
#[ignore]
|
45
|
+
fn test_changed_secret_key() {
|
46
|
+
let p: u64 = 13;
|
47
|
+
let g: u64 = 11;
|
48
|
+
|
49
|
+
let private_key_a = private_key(p);
|
50
|
+
let private_key_b = private_key(p);
|
51
|
+
|
52
|
+
let public_key_a = public_key(p, g, private_key_a);
|
53
|
+
let public_key_b = public_key(p, g, private_key_b);
|
54
|
+
|
55
|
+
// Key exchange
|
56
|
+
let secret_a = secret(p, public_key_b, private_key_a);
|
57
|
+
let secret_b = secret(p, public_key_a, private_key_b);
|
58
|
+
|
59
|
+
assert_eq!(secret_a, secret_b);
|
60
|
+
}
|