trackler 2.2.1.137 → 2.2.1.138
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/diffie-hellman/canonical-data.json +72 -0
- data/problem-specifications/exercises/yacht/description.md +2 -2
- data/tracks/csharp/exercises/sgf-parsing/Example.cs +1 -1
- data/tracks/csharp/exercises/sgf-parsing/SgfParsingTest.cs +1 -1
- data/tracks/csharp/exercises/sublist/SublistTest.cs +37 -78
- data/tracks/csharp/generators/Exercises/Sublist.cs +32 -0
- data/tracks/elisp/exercises/bob/README.md +2 -0
- data/tracks/elisp/exercises/bob/bob-test.el +60 -15
- data/tracks/elisp/exercises/bob/example.el +15 -5
- data/tracks/elisp/exercises/hamming/hamming-test.el +1 -1
- data/tracks/fsharp/build.ps1 +3 -3
- data/tracks/fsharp/build.sh +3 -3
- data/tracks/fsharp/exercises/bracket-push/BracketPushTest.fs +5 -1
- data/tracks/fsharp/exercises/isbn-verifier/IsbnVerifierTest.fs +5 -1
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGardenTest.fs +1 -1
- data/tracks/fsharp/exercises/pov/PovTest.fs +6 -1
- data/tracks/fsharp/exercises/react/Example.fs +2 -2
- data/tracks/fsharp/exercises/react/React.fsproj +1 -0
- data/tracks/fsharp/exercises/react/ReactTest.fs +55 -33
- data/tracks/fsharp/exercises/series/Example.fs +2 -12
- data/tracks/fsharp/exercises/series/SeriesTest.fs +33 -56
- data/tracks/fsharp/generators/Generators.fs +81 -46
- data/tracks/idris/exercises/rna-transcription/src/{example.idr → Example.idr} +0 -0
- data/tracks/java/config.json +14 -0
- data/tracks/java/exercises/acronym/src/test/java/AcronymTest.java +10 -10
- data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +39 -39
- data/tracks/java/exercises/grep/.meta/hints.md +58 -0
- data/tracks/java/exercises/grep/.meta/src/reference/java/GrepTool.java +65 -0
- data/tracks/java/exercises/grep/.meta/version +1 -0
- data/tracks/java/exercises/grep/README.md +145 -0
- data/tracks/java/exercises/grep/build.gradle +18 -0
- data/tracks/java/exercises/grep/src/main/java/.keep +0 -0
- data/tracks/java/exercises/grep/src/test/java/GrepToolTest.java +395 -0
- data/tracks/java/exercises/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java +36 -36
- data/tracks/java/exercises/minesweeper/src/test/java/MinesweeperBoardTest.java +36 -36
- data/tracks/java/exercises/phone-number/src/test/java/PhoneNumberTest.java +14 -14
- data/tracks/java/exercises/poker/src/test/java/PokerTest.java +40 -40
- data/tracks/java/exercises/pythagorean-triplet/src/test/java/PythagoreanTripletTest.java +10 -10
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/ocaml/exercises/anagram/example.ml +1 -1
- data/tracks/ocaml/exercises/change/example.ml +1 -1
- data/tracks/ocaml/exercises/custom-set/example.ml +4 -3
- data/tracks/ocaml/exercises/custom-set/test.ml +0 -1
- data/tracks/ocaml/exercises/dominoes/test.ml +1 -1
- data/tracks/ocaml/exercises/etl/example.ml +1 -1
- data/tracks/ocaml/exercises/grade-school/example.ml +1 -1
- data/tracks/ocaml/exercises/palindrome-products/example.ml +2 -2
- data/tracks/ocaml/exercises/prime-factors/example.ml +1 -1
- data/tracks/ocaml/exercises/robot-name/test.ml +1 -1
- data/tracks/ocaml/exercises/triangle/example.ml +1 -1
- data/tracks/ocaml/make-exercise.sh +1 -0
- data/tracks/ocaml/tools/test-generator/src/controller.ml +1 -1
- data/tracks/perl5/exercises/raindrops/.meta/solutions/Raindrops.pm +13 -12
- data/tracks/perl5/exercises/raindrops/raindrops.t +166 -111
- data/tracks/perl6/docs/INSTALLATION.md +1 -3
- data/tracks/perl6/exercises/raindrops/.meta/exercise-data.yaml +5 -5
- data/tracks/perl6/exercises/raindrops/.meta/solutions/Raindrops.pm6 +2 -2
- data/tracks/perl6/exercises/raindrops/Raindrops.pm6 +2 -2
- data/tracks/perl6/exercises/raindrops/raindrops.t +3 -3
- data/tracks/python/exercises/food-chain/example.py +11 -2
- data/tracks/python/exercises/food-chain/food_chain_test.py +48 -45
- data/tracks/python/exercises/pov/pov_test.py +12 -1
- data/tracks/python/exercises/series/README.md +6 -6
- data/tracks/python/exercises/series/example.py +2 -3
- data/tracks/python/exercises/series/series_test.py +27 -28
- data/tracks/python/exercises/sgf-parsing/example.py +1 -1
- data/tracks/python/exercises/sgf-parsing/sgf_parsing_test.py +1 -1
- data/tracks/python/exercises/yacht/README.md +2 -2
- data/tracks/ruby/Gemfile +0 -1
- data/tracks/ruby/README.md +23 -0
- data/tracks/ruby/bin/generate +1 -0
- data/tracks/ruby/exercises/complex-numbers/complex_numbers_test.rb +1 -1
- data/tracks/ruby/lib/generator.rb +1 -2
- data/tracks/ruby/lib/generator/command_line.rb +3 -0
- data/tracks/ruby/lib/generator/command_line/generator_optparser.rb +1 -0
- data/tracks/ruby/lib/generator/exercise.rb +2 -0
- data/tracks/ruby/lib/generator/exercise_case.rb +3 -0
- data/tracks/ruby/lib/generator/files.rb +1 -0
- data/tracks/ruby/lib/generator/files/metadata_files.rb +2 -0
- data/tracks/ruby/lib/generator/files/track_files.rb +1 -0
- data/tracks/ruby/lib/generator/implementation.rb +1 -0
- data/tracks/ruby/lib/generator/repository.rb +3 -0
- data/tracks/ruby/lib/generator/template_values.rb +1 -0
- data/tracks/ruby/test/generator/case_values_test.rb +2 -0
- data/tracks/ruby/test/generator/command_line_test.rb +1 -0
- data/tracks/ruby/test/generator/files/metadata_files_test.rb +2 -0
- data/tracks/ruby/test/generator/files/track_files_test.rb +1 -0
- data/tracks/ruby/test/generator/implementation_test.rb +1 -0
- data/tracks/ruby/test/tasks/exercise_test.rb +1 -0
- data/tracks/ruby/test/tasks/exercise_test_tasks_test.rb +2 -0
- data/tracks/ruby/test/test_helper.rb +1 -3
- data/tracks/rust/config.json +12 -0
- data/tracks/rust/exercises/atbash-cipher/src/lib.rs +9 -0
- data/tracks/rust/exercises/hamming/src/lib.rs +6 -0
- data/tracks/rust/exercises/isogram/src/lib.rs +3 -0
- data/tracks/rust/exercises/luhn/src/lib.rs +4 -0
- data/tracks/rust/exercises/palindrome-products/.meta/test-in-release-mode +1 -0
- data/tracks/rust/exercises/palindrome-products/Cargo.toml +6 -0
- data/tracks/rust/exercises/palindrome-products/README.md +72 -0
- data/tracks/rust/exercises/palindrome-products/example.rs +25 -0
- data/tracks/rust/exercises/palindrome-products/src/lib.rs +22 -0
- data/tracks/rust/exercises/palindrome-products/tests/palindrome-products.rs +57 -0
- data/tracks/rust/exercises/pangram/src/lib.rs +4 -0
- data/tracks/rust/exercises/run-length-encoding/src/lib.rs +7 -0
- data/tracks/rust/exercises/say/src/lib.rs +3 -4
- data/tracks/rust/exercises/scrabble-score/src/lib.rs +4 -0
- data/tracks/rust/exercises/word-count/src/lib.rs +6 -0
- data/tracks/scheme/exercises/hello-world/example.scm +1 -4
- data/tracks/scheme/exercises/hello-world/hello-world-test.scm +1 -5
- data/tracks/scheme/exercises/scrabble-score/scrabble-score-test.scm +2 -2
- data/tracks/typescript/config.json +30 -0
- data/tracks/typescript/exercises/queen-attack/README.md +59 -0
- data/tracks/typescript/exercises/queen-attack/package.json +36 -0
- data/tracks/typescript/exercises/queen-attack/queen-attack.example.ts +56 -0
- data/tracks/typescript/exercises/queen-attack/queen-attack.test.ts +71 -0
- data/tracks/typescript/exercises/queen-attack/queen-attack.ts +0 -0
- data/tracks/typescript/exercises/queen-attack/tsconfig.json +22 -0
- data/tracks/typescript/exercises/queen-attack/tslint.json +127 -0
- data/tracks/typescript/exercises/queen-attack/yarn.lock +2624 -0
- data/tracks/typescript/exercises/spiral-matrix/README.md +56 -0
- data/tracks/typescript/exercises/spiral-matrix/package.json +36 -0
- data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.example.ts +33 -0
- data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.test.ts +49 -0
- data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.ts +0 -0
- data/tracks/typescript/exercises/spiral-matrix/tsconfig.json +22 -0
- data/tracks/typescript/exercises/spiral-matrix/tslint.json +127 -0
- data/tracks/typescript/exercises/spiral-matrix/yarn.lock +2624 -0
- metadata +35 -3
|
@@ -2,7 +2,7 @@ require 'minitest/autorun'
|
|
|
2
2
|
require_relative 'complex_numbers'
|
|
3
3
|
|
|
4
4
|
# Common test data version: 1.0.0 '117d062'
|
|
5
|
-
class
|
|
5
|
+
class ComplexNumberTest < Minitest::Test
|
|
6
6
|
def test_imaginary_unit
|
|
7
7
|
# skip
|
|
8
8
|
expected = ComplexNumber.new(-1, 0)
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
|
3
|
-
require 'require_all'
|
|
4
|
-
|
|
5
3
|
unless ENV['CI']
|
|
6
4
|
require 'simplecov'
|
|
7
5
|
|
|
@@ -31,4 +29,4 @@ end
|
|
|
31
29
|
require 'minitest/autorun'
|
|
32
30
|
|
|
33
31
|
# So we can be sure we have coverage on the whole lib directory:
|
|
34
|
-
|
|
32
|
+
Dir.glob('lib/*.rb').each { |file| require file.gsub(%r{(^lib\/|\.rb$)}, '') }
|
data/tracks/rust/config.json
CHANGED
|
@@ -767,6 +767,18 @@
|
|
|
767
767
|
"difficulty": 4,
|
|
768
768
|
"topics": []
|
|
769
769
|
},
|
|
770
|
+
{
|
|
771
|
+
"uuid": "8cdc3424-51da-4cae-a065-9982859d5b55",
|
|
772
|
+
"slug": "palindrome-products",
|
|
773
|
+
"core": false,
|
|
774
|
+
"unlocked_by": null,
|
|
775
|
+
"difficulty": 4,
|
|
776
|
+
"topics": [
|
|
777
|
+
"string comparison",
|
|
778
|
+
"calculation",
|
|
779
|
+
"structs"
|
|
780
|
+
]
|
|
781
|
+
},
|
|
770
782
|
{
|
|
771
783
|
"uuid": "0a33f3ac-cedd-4a40-a132-9d044b0e9977",
|
|
772
784
|
"slug": "poker",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// "Encipher" with the Atbash cipher.
|
|
2
|
+
pub fn encode(plain: &str) -> String {
|
|
3
|
+
unimplemented!("Encoding of {:?} in Atbash cipher.", plain);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/// "Decipher" with the Atbash cipher.
|
|
7
|
+
pub fn decode(cipher: &str) -> String {
|
|
8
|
+
unimplemented!("Decoding of {:?} in Atbash cipher.", cipher);
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Takes very long time in debug mode because of the nested loops which compute the palindrome products.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Palindrome Products
|
|
2
|
+
|
|
3
|
+
Detect palindrome products in a given range.
|
|
4
|
+
|
|
5
|
+
A palindromic number is a number that remains the same when its digits are
|
|
6
|
+
reversed. For example, `121` is a palindromic number but `112` is not.
|
|
7
|
+
|
|
8
|
+
Given a range of numbers, find the largest and smallest palindromes which
|
|
9
|
+
are products of numbers within that range.
|
|
10
|
+
|
|
11
|
+
Your solution should return the largest and smallest palindromes, along with the
|
|
12
|
+
factors of each within the range. If the largest or smallest palindrome has more
|
|
13
|
+
than one pair of factors within the range, then return all the pairs.
|
|
14
|
+
|
|
15
|
+
## Example 1
|
|
16
|
+
|
|
17
|
+
Given the range `[1, 9]` (both inclusive)...
|
|
18
|
+
|
|
19
|
+
And given the list of all possible products within this range:
|
|
20
|
+
`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30, 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81]`
|
|
21
|
+
|
|
22
|
+
The palindrome products are all single digit numbers (in this case):
|
|
23
|
+
`[1, 2, 3, 4, 5, 6, 7, 8, 9]`
|
|
24
|
+
|
|
25
|
+
The smallest palindrome product is `1`. Its factors are `(1, 1)`.
|
|
26
|
+
The largest palindrome product is `9`. Its factors are `(1, 9)` and `(3, 3)`.
|
|
27
|
+
|
|
28
|
+
## Example 2
|
|
29
|
+
|
|
30
|
+
Given the range `[10, 99]` (both inclusive)...
|
|
31
|
+
|
|
32
|
+
The smallest palindrome product is `121`. Its factors are `(11, 11)`.
|
|
33
|
+
The largest palindrome product is `9009`. Its factors are `(91, 99)`.
|
|
34
|
+
|
|
35
|
+
## Rust Installation
|
|
36
|
+
|
|
37
|
+
Refer to the [exercism help page][help-page] for Rust installation and learning
|
|
38
|
+
resources.
|
|
39
|
+
|
|
40
|
+
## Writing the Code
|
|
41
|
+
|
|
42
|
+
Execute the tests with:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
$ cargo test
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
All but the first test have been ignored. After you get the first test to
|
|
49
|
+
pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
|
|
50
|
+
to pass again. The test file is located in the `tests` directory. You can
|
|
51
|
+
also remove the ignore flag from all the tests to get them to run all at once
|
|
52
|
+
if you wish.
|
|
53
|
+
|
|
54
|
+
Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
|
|
55
|
+
haven't already, it will help you with organizing your files.
|
|
56
|
+
|
|
57
|
+
## Feedback, Issues, Pull Requests
|
|
58
|
+
|
|
59
|
+
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 are happy to help!
|
|
60
|
+
|
|
61
|
+
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).
|
|
62
|
+
|
|
63
|
+
[help-page]: http://exercism.io/languages/rust
|
|
64
|
+
[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
|
|
65
|
+
[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
|
|
66
|
+
|
|
67
|
+
## Source
|
|
68
|
+
|
|
69
|
+
Problem 4 at Project Euler [http://projecteuler.net/problem=4](http://projecteuler.net/problem=4)
|
|
70
|
+
|
|
71
|
+
## Submitting Incomplete Solutions
|
|
72
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
pub type Palindrome = u64;
|
|
2
|
+
pub fn get_palindrome_products(min: u64, max: u64) -> Vec<Palindrome> {
|
|
3
|
+
let mut palindromes: Vec<u64> = Vec::new();
|
|
4
|
+
for i in min..max + 1 {
|
|
5
|
+
for j in min..max + 1 {
|
|
6
|
+
if is_palindrome(i * j) {
|
|
7
|
+
palindromes.push(i * j);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
palindromes
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
pub fn min(palindromes: &[Palindrome]) -> Option<Palindrome> {
|
|
15
|
+
palindromes.iter().min().map(|n| n.clone())
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
pub fn max(palindromes: &[Palindrome]) -> Option<Palindrome> {
|
|
19
|
+
palindromes.iter().max().map(|n| n.clone())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fn is_palindrome(n: u64) -> bool {
|
|
23
|
+
let s = n.to_string().into_bytes();
|
|
24
|
+
s.iter().zip(s.iter().rev()).all(|(c1, c2)| c1 == c2)
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
pub type Palindrome = u64;
|
|
2
|
+
pub fn get_palindrome_products(min: u64, max: u64) -> Vec<Palindrome> {
|
|
3
|
+
unimplemented!(
|
|
4
|
+
"Find all palindromic numbers which are products of numbers in the inclusive range ({}..{})",
|
|
5
|
+
min,
|
|
6
|
+
max
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
pub fn min(palindromes: &[Palindrome]) -> Option<Palindrome> {
|
|
11
|
+
unimplemented!(
|
|
12
|
+
"Return the palindrome of minimal value from the supplied list: {:?}",
|
|
13
|
+
palindromes
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
pub fn max(palindromes: &[Palindrome]) -> Option<Palindrome> {
|
|
18
|
+
unimplemented!(
|
|
19
|
+
"Return the palindrome of maximal value from the supplied list: {:?}",
|
|
20
|
+
palindromes
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
extern crate palindrome_products;
|
|
2
|
+
use palindrome_products::*;
|
|
3
|
+
|
|
4
|
+
#[test]
|
|
5
|
+
fn single_digits() {
|
|
6
|
+
let palindromes = get_palindrome_products(1, 9);
|
|
7
|
+
assert_eq!(min(&palindromes), Some(1));
|
|
8
|
+
assert_eq!(max(&palindromes), Some(9));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#[test]
|
|
12
|
+
#[ignore]
|
|
13
|
+
fn double_digits() {
|
|
14
|
+
let palindromes = get_palindrome_products(10, 99);
|
|
15
|
+
assert_eq!(min(&palindromes), Some(121));
|
|
16
|
+
assert_eq!(max(&palindromes), Some(9009));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#[test]
|
|
20
|
+
#[ignore]
|
|
21
|
+
fn triple_digits() {
|
|
22
|
+
let palindromes = get_palindrome_products(100, 999);
|
|
23
|
+
assert_eq!(min(&palindromes), Some(10201));
|
|
24
|
+
assert_eq!(max(&palindromes), Some(906609));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[test]
|
|
28
|
+
#[ignore]
|
|
29
|
+
fn four_digits() {
|
|
30
|
+
let palindromes = get_palindrome_products(1000, 9999);
|
|
31
|
+
assert_eq!(min(&palindromes), Some(1002001));
|
|
32
|
+
assert_eq!(max(&palindromes), Some(99000099));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[test]
|
|
36
|
+
#[ignore]
|
|
37
|
+
fn empty_result_for_smallest_palindrome() {
|
|
38
|
+
assert_eq!(min(&get_palindrome_products(1002, 1003)), None);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[test]
|
|
42
|
+
#[ignore]
|
|
43
|
+
fn empty_result_for_largest_palindrome() {
|
|
44
|
+
assert_eq!(max(&get_palindrome_products(15, 15)), None);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#[test]
|
|
48
|
+
#[ignore]
|
|
49
|
+
fn error_smallest_palindrome_when_min_gt_max() {
|
|
50
|
+
assert_eq!(min(&get_palindrome_products(1000, 1)), None);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#[test]
|
|
54
|
+
#[ignore]
|
|
55
|
+
fn error_largest_palindrome_when_min_st_max() {
|
|
56
|
+
assert_eq!(max(&get_palindrome_products(2, 1)), None);
|
|
57
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//
|
|
1
|
+
pub fn encode(n: u64) -> String {
|
|
2
|
+
unimplemented!("Say {} in English.", n);
|
|
3
|
+
}
|