trackler 2.2.1.43 → 2.2.1.44
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/lens-person/description.md +1 -1
- data/problem-specifications/exercises/palindrome-products/description.md +5 -12
- data/problem-specifications/exercises/pascals-triangle/canonical-data.json +1 -7
- data/tracks/c/exercises/meetup/src/example.c +64 -60
- data/tracks/c/exercises/meetup/src/example.h +2 -2
- data/tracks/c/exercises/meetup/test/test_meetup.c +4 -4
- data/tracks/cfml/config.json +179 -169
- data/tracks/cfml/exercises/markdown/.meta/HINTS.md +0 -0
- data/tracks/cfml/exercises/markdown/Markdown.cfc +121 -0
- data/tracks/cfml/exercises/markdown/MarkdownTest.cfc +51 -0
- data/tracks/cfml/exercises/markdown/Solution.cfc +204 -0
- data/tracks/cfml/exercises/markdown/SolutionTest.cfc +7 -0
- data/tracks/cfml/exercises/markdown/TestRunner.cfc +103 -0
- data/tracks/cfml/exercises/markdown/box.json +8 -0
- data/tracks/cfml/exercises/markdown/index.cfm +37 -0
- data/tracks/csharp/exercises/dominoes/DominoesTest.cs +40 -45
- data/tracks/csharp/exercises/meetup/MeetupTest.cs +761 -83
- data/tracks/csharp/generators/Exercises/Dominoes.cs +33 -0
- data/tracks/csharp/generators/Exercises/Meetup.cs +46 -0
- data/tracks/csharp/generators/Output/FormattingExtensions.cs +11 -1
- data/tracks/csharp/generators/Output/TypesExtensions.cs +23 -0
- data/tracks/csharp/generators/Output/ValueFormatter.cs +70 -69
- data/tracks/dart/config.json +15 -3
- data/tracks/dart/exercises/word-count/README.md +18 -0
- data/tracks/dart/exercises/word-count/lib/example.dart +26 -0
- data/tracks/dart/exercises/word-count/lib/word_count.dart +3 -0
- data/tracks/dart/exercises/word-count/pubspec.lock +293 -0
- data/tracks/dart/exercises/word-count/pubspec.yaml +3 -0
- data/tracks/dart/exercises/word-count/test/word_count_test.dart +64 -0
- data/tracks/ecmascript/docs/INSTALLATION.md +4 -7
- data/tracks/elixir/exercises/hello-world/README.md +1 -26
- data/tracks/elixir/exercises/hello-world/example.exs +3 -7
- data/tracks/elixir/exercises/hello-world/hello_world.exs +3 -25
- data/tracks/elixir/exercises/hello-world/hello_world_test.exs +2 -13
- data/tracks/elixir/mix.lock +1 -1
- data/tracks/elm/config.json +11 -0
- data/tracks/elm/exercises/pascals-triangle/README.md +51 -0
- data/tracks/elm/exercises/pascals-triangle/Triangle.elm +1 -0
- data/tracks/elm/exercises/pascals-triangle/Triangle.example.elm +23 -0
- data/tracks/elm/exercises/pascals-triangle/elm-package.json +14 -0
- data/tracks/elm/exercises/pascals-triangle/package.json +14 -0
- data/tracks/elm/exercises/pascals-triangle/tests/Tests.elm +34 -0
- data/tracks/elm/exercises/pascals-triangle/tests/elm-package.json +16 -0
- data/tracks/fsharp/exercises/grade-school/GradeSchool.fs +2 -2
- data/tracks/fsharp/exercises/grade-school/GradeSchoolTest.fs +3 -2
- data/tracks/java/CONTRIBUTING.md +34 -0
- data/tracks/java/config.json +42 -6
- data/tracks/java/exercises/largest-series-product/src/main/java/LargestSeriesProductCalculator.java +7 -3
- data/tracks/java/exercises/matrix/src/main/java/Matrix.java +23 -0
- data/tracks/julia/config.json +11 -2
- data/tracks/julia/exercises/grains/README.md +33 -0
- data/tracks/julia/exercises/grains/example.jl +23 -0
- data/tracks/julia/exercises/grains/grains.jl +9 -0
- data/tracks/julia/exercises/grains/runtests.jl +27 -0
- data/tracks/lua/README.md +1 -1
- data/tracks/mips/exercises/octal/README.md +3 -8
- data/tracks/ocaml/exercises/palindrome-products/README.md +8 -14
- data/tracks/perl6/.travis.yml +7 -3
- data/tracks/perl6/bin/exercise-gen.pl6 +5 -1
- data/tracks/perl6/exercises/accumulate/README.md +0 -3
- data/tracks/perl6/exercises/accumulate/accumulate.t +9 -3
- data/tracks/perl6/exercises/all-your-base/README.md +1 -1
- data/tracks/perl6/exercises/all-your-base/all-your-base.t +23 -11
- data/tracks/perl6/exercises/all-your-base/example.yaml +1 -1
- data/tracks/perl6/exercises/allergies/README.md +0 -1
- data/tracks/perl6/exercises/allergies/allergies.t +22 -10
- data/tracks/perl6/exercises/anagram/anagram.t +22 -10
- data/tracks/perl6/exercises/atbash-cipher/README.md +2 -1
- data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +22 -10
- data/tracks/perl6/exercises/binary/README.md +2 -0
- data/tracks/perl6/exercises/bob/bob.t +24 -11
- data/tracks/perl6/exercises/bob/example.yaml +2 -2
- data/tracks/perl6/exercises/clock/clock.t +22 -10
- data/tracks/perl6/exercises/flatten-array/README.md +1 -2
- data/tracks/perl6/exercises/flatten-array/example.yaml +1 -1
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +23 -11
- data/tracks/perl6/exercises/grade-school/README.md +0 -1
- data/tracks/perl6/exercises/grade-school/grade-school.t +9 -3
- data/tracks/perl6/exercises/grains/README.md +0 -1
- data/tracks/perl6/exercises/grains/grains.t +22 -10
- data/tracks/perl6/exercises/hello-world/example.yaml +3 -3
- data/tracks/perl6/exercises/hello-world/hello-world.t +25 -12
- data/tracks/perl6/exercises/leap/README.md +1 -1
- data/tracks/perl6/exercises/leap/example.yaml +1 -1
- data/tracks/perl6/exercises/leap/leap.t +23 -11
- data/tracks/perl6/exercises/linked-list/README.md +10 -10
- data/tracks/perl6/exercises/linked-list/linked-list.t +9 -3
- data/tracks/perl6/exercises/luhn/README.md +7 -7
- data/tracks/perl6/exercises/luhn/luhn.t +22 -10
- data/tracks/perl6/exercises/phone-number/README.md +3 -2
- data/tracks/perl6/exercises/phone-number/phone-number.t +22 -10
- data/tracks/perl6/exercises/raindrops/raindrops.t +22 -10
- data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +22 -10
- data/tracks/perl6/exercises/robot-name/robot-name.t +9 -3
- data/tracks/perl6/exercises/scrabble-score/README.md +3 -1
- data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +22 -10
- data/tracks/perl6/exercises/space-age/README.md +2 -1
- data/tracks/perl6/exercises/space-age/space-age.t +22 -10
- data/tracks/perl6/exercises/trinary/README.md +1 -1
- data/tracks/perl6/exercises/word-count/README.md +1 -2
- data/tracks/perl6/exercises/word-count/word-count.t +22 -10
- data/tracks/perl6/exercises/wordy/README.md +0 -5
- data/tracks/perl6/exercises/wordy/wordy.t +22 -10
- data/tracks/perl6/templates/test.mustache +26 -15
- data/tracks/python/config.json +10 -0
- data/tracks/python/exercises/book-store/book_store.py +1 -1
- data/tracks/python/exercises/flatten-array/flatten_array.py +1 -1
- data/tracks/python/exercises/matrix/matrix.py +1 -1
- data/tracks/python/exercises/palindrome-products/palindrome_products.py +2 -2
- data/tracks/python/exercises/perfect-numbers/perfect_numbers.py +2 -2
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet.py +3 -3
- data/tracks/python/exercises/raindrops/raindrops.py +1 -1
- data/tracks/python/exercises/scale-generator/scale_generator.py +1 -1
- data/tracks/python/exercises/sieve/sieve.py +1 -1
- data/tracks/python/exercises/sublist/sublist.py +1 -1
- data/tracks/python/exercises/transpose/transpose.py +1 -1
- data/tracks/python/exercises/triangle/triangle.py +4 -1
- data/tracks/python/exercises/two-bucket/example.py +59 -0
- data/tracks/python/exercises/two-bucket/two_bucket.py +2 -0
- data/tracks/python/exercises/two-bucket/two_bucket_test.py +32 -0
- data/tracks/scheme/config.json +59 -89
- data/tracks/scheme/config/maintainers.json +11 -11
- data/tracks/sml/exercises/allergies/README.md +20 -5
- data/tracks/sml/exercises/allergies/allergies.sml +11 -14
- data/tracks/sml/exercises/allergies/example.sml +9 -9
- data/tracks/sml/exercises/allergies/test.sml +65 -129
- data/tracks/sml/exercises/allergies/testlib.sml +159 -0
- data/tracks/sml/exercises/hamming/README.md +21 -5
- data/tracks/sml/exercises/hamming/example.sml +14 -10
- data/tracks/sml/exercises/hamming/hamming.sml +4 -3
- data/tracks/sml/exercises/hamming/test.sml +55 -64
- data/tracks/sml/exercises/hamming/testlib.sml +159 -0
- data/tracks/typescript/config.json +15 -0
- data/tracks/typescript/exercises/linked-list/linked-list.test.ts +11 -11
- data/tracks/typescript/exercises/nth-prime/README.md +36 -0
- data/tracks/typescript/exercises/nth-prime/nth-prime.example.ts +28 -0
- data/tracks/typescript/exercises/nth-prime/nth-prime.test.ts +25 -0
- data/tracks/typescript/exercises/nth-prime/nth-prime.ts +0 -0
- data/tracks/typescript/exercises/nth-prime/package.json +36 -0
- data/tracks/typescript/exercises/nth-prime/tsconfig.json +22 -0
- data/tracks/typescript/exercises/nth-prime/tslint.json +127 -0
- data/tracks/typescript/exercises/nth-prime/yarn.lock +2305 -0
- data/tracks/typescript/exercises/prime-factors/README.md +1 -1
- data/tracks/typescript/exercises/prime-factors/prime-factors.test.ts +11 -11
- data/tracks/typescript/exercises/series/README.md +1 -1
- data/tracks/typescript/exercises/series/series.test.ts +11 -11
- data/tracks/typescript/img/icon.png +0 -0
- data/tracks/typescript/img/icon.svg +3 -8
- metadata +44 -2
@@ -22,7 +22,7 @@ tests: |
|
|
22
22
|
is-deeply call-convert-base, $expected, $case<description>
|
23
23
|
}
|
24
24
|
|
25
|
-
sub call-convert-base {
|
25
|
+
sub call-convert-base { convert-base(|$case<input_base input_digits output_base>) }
|
26
26
|
}
|
27
27
|
|
28
28
|
unit: module
|
@@ -29,7 +29,6 @@ allergens that score 256, 512, 1024, etc.). Your program should
|
|
29
29
|
ignore those components of the score. For example, if the allergy
|
30
30
|
score is 257, your program should only report the eggs (1) allergy.
|
31
31
|
|
32
|
-
|
33
32
|
## Resources
|
34
33
|
|
35
34
|
Remember to check out the Perl 6 [documentation](https://docs.perl6.org/) and
|
@@ -4,10 +4,12 @@ use Test;
|
|
4
4
|
use lib my $dir = $?FILE.IO.dirname;
|
5
5
|
use JSON::Fast;
|
6
6
|
|
7
|
-
my $exercise
|
8
|
-
my $version = v1;
|
9
|
-
my $module
|
10
|
-
|
7
|
+
my Str:D $exercise := 'Allergies';
|
8
|
+
my Version:D $version = v1;
|
9
|
+
my Str $module //= $exercise;
|
10
|
+
INIT {
|
11
|
+
plan 4;
|
12
|
+
}
|
11
13
|
|
12
14
|
use-ok $module or bail-out;
|
13
15
|
require ::($module);
|
@@ -39,12 +41,6 @@ for @($c-data<cases>) -> %cases {
|
|
39
41
|
} if %cases<description> ~~ 'list';
|
40
42
|
}
|
41
43
|
|
42
|
-
if %*ENV<EXERCISM> {
|
43
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
44
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
45
|
-
} else { flunk 'canonical-data' }
|
46
|
-
} else { skip }
|
47
|
-
|
48
44
|
done-testing;
|
49
45
|
|
50
46
|
INIT {
|
@@ -201,4 +197,20 @@ $c-data := from-json q:to/END/;
|
|
201
197
|
}
|
202
198
|
|
203
199
|
END
|
200
|
+
|
201
|
+
if %*ENV<EXERCISM> {
|
202
|
+
$module = 'Example';
|
203
|
+
if (my $c-data-file =
|
204
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
205
|
+
.IO.resolve) ~~ :f
|
206
|
+
{
|
207
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
208
|
+
}
|
209
|
+
else {
|
210
|
+
flunk 'canonical-data';
|
211
|
+
}
|
212
|
+
}
|
213
|
+
else {
|
214
|
+
skip;
|
215
|
+
}
|
204
216
|
}
|
@@ -4,10 +4,12 @@ use Test;
|
|
4
4
|
use lib my $dir = $?FILE.IO.dirname;
|
5
5
|
use JSON::Fast;
|
6
6
|
|
7
|
-
my $exercise
|
8
|
-
my $version = v1;
|
9
|
-
my $module
|
10
|
-
|
7
|
+
my Str:D $exercise := 'Anagram';
|
8
|
+
my Version:D $version = v1;
|
9
|
+
my Str $module //= $exercise;
|
10
|
+
INIT {
|
11
|
+
plan 18;
|
12
|
+
}
|
11
13
|
|
12
14
|
use-ok $module or bail-out;
|
13
15
|
require ::($module);
|
@@ -24,12 +26,6 @@ require ::($module) <&match-anagrams>;
|
|
24
26
|
my $c-data;
|
25
27
|
is match-anagrams(|.<subject candidates>), |.<expected description> for @($c-data<cases>);
|
26
28
|
|
27
|
-
if %*ENV<EXERCISM> {
|
28
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
29
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
30
|
-
} else { flunk 'canonical-data' }
|
31
|
-
} else { skip }
|
32
|
-
|
33
29
|
done-testing;
|
34
30
|
|
35
31
|
INIT {
|
@@ -167,4 +163,20 @@ $c-data := from-json q:to/END/;
|
|
167
163
|
}
|
168
164
|
|
169
165
|
END
|
166
|
+
|
167
|
+
if %*ENV<EXERCISM> {
|
168
|
+
$module = 'Example';
|
169
|
+
if (my $c-data-file =
|
170
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
171
|
+
.IO.resolve) ~~ :f
|
172
|
+
{
|
173
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
174
|
+
}
|
175
|
+
else {
|
176
|
+
flunk 'canonical-data';
|
177
|
+
}
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
skip;
|
181
|
+
}
|
170
182
|
}
|
@@ -9,7 +9,7 @@ letter, the second with the second-last, and so on.
|
|
9
9
|
|
10
10
|
An Atbash cipher for the Latin alphabet would be as follows:
|
11
11
|
|
12
|
-
```
|
12
|
+
```text
|
13
13
|
Plain: abcdefghijklmnopqrstuvwxyz
|
14
14
|
Cipher: zyxwvutsrqponmlkjihgfedcba
|
15
15
|
```
|
@@ -23,6 +23,7 @@ being 5 letters, and punctuation is excluded. This is to make it harder to guess
|
|
23
23
|
things based on word boundaries.
|
24
24
|
|
25
25
|
## Examples
|
26
|
+
|
26
27
|
- Encoding `test` gives `gvhg`
|
27
28
|
- Decoding `gvhg` gives `test`
|
28
29
|
- Decoding `gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt` gives `thequickbrownfoxjumpsoverthelazydog`
|
@@ -4,10 +4,12 @@ use Test;
|
|
4
4
|
use lib my $dir = $?FILE.IO.dirname;
|
5
5
|
use JSON::Fast;
|
6
6
|
|
7
|
-
my $exercise
|
8
|
-
my $version = v1;
|
9
|
-
my $module
|
10
|
-
|
7
|
+
my Str:D $exercise := 'AtbashCipher';
|
8
|
+
my Version:D $version = v1;
|
9
|
+
my Str $module //= $exercise;
|
10
|
+
INIT {
|
11
|
+
plan 4;
|
12
|
+
}
|
11
13
|
|
12
14
|
use-ok $module or bail-out;
|
13
15
|
require ::($module);
|
@@ -31,12 +33,6 @@ for @($c-data<cases>) {
|
|
31
33
|
}
|
32
34
|
}
|
33
35
|
|
34
|
-
if %*ENV<EXERCISM> {
|
35
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
36
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
37
|
-
} else { flunk 'canonical-data' }
|
38
|
-
} else { skip }
|
39
|
-
|
40
36
|
done-testing;
|
41
37
|
|
42
38
|
INIT {
|
@@ -139,4 +135,20 @@ $c-data := from-json q:to/END/;
|
|
139
135
|
}
|
140
136
|
|
141
137
|
END
|
138
|
+
|
139
|
+
if %*ENV<EXERCISM> {
|
140
|
+
$module = 'Example';
|
141
|
+
if (my $c-data-file =
|
142
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
143
|
+
.IO.resolve) ~~ :f
|
144
|
+
{
|
145
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
flunk 'canonical-data';
|
149
|
+
}
|
150
|
+
}
|
151
|
+
else {
|
152
|
+
skip;
|
153
|
+
}
|
142
154
|
}
|
@@ -7,10 +7,12 @@ string, your program should produce a decimal output. The
|
|
7
7
|
program should handle invalid inputs.
|
8
8
|
|
9
9
|
## Note
|
10
|
+
|
10
11
|
- Implement the conversion yourself.
|
11
12
|
Do not use something else to perform the conversion for you.
|
12
13
|
|
13
14
|
## About Binary (Base-2)
|
15
|
+
|
14
16
|
Decimal is a base-10 system.
|
15
17
|
|
16
18
|
A number 23 in base 10 notation can be understood
|
@@ -4,10 +4,12 @@ use Test;
|
|
4
4
|
use lib my $dir = $?FILE.IO.dirname; #`[Look for the module inside the same directory as this test file.]
|
5
5
|
use JSON::Fast;
|
6
6
|
|
7
|
-
my $exercise
|
8
|
-
my $version = v1; #`[The version we will be matching against the exercise.]
|
9
|
-
my $module
|
10
|
-
|
7
|
+
my Str:D $exercise := 'Bob'; #`[The name of this exercise.]
|
8
|
+
my Version:D $version = v1; #`[The version we will be matching against the exercise.]
|
9
|
+
my Str $module //= $exercise; #`[The name of the module file to be loaded.]
|
10
|
+
INIT {
|
11
|
+
plan 28; #`[This is how many tests we expect to run.]
|
12
|
+
}
|
11
13
|
|
12
14
|
#`[Check that the module can be use-d.]
|
13
15
|
use-ok $module or bail-out;
|
@@ -33,13 +35,6 @@ my $c-data;
|
|
33
35
|
and check that Bob gives us the correct response for each one.]
|
34
36
|
is ::($exercise).?hey(.<input>), |.<expected description> for @($c-data<cases>);
|
35
37
|
|
36
|
-
#`[Ignore this for your exercise! Tells Exercism folks when exercise cases become out of date.]
|
37
|
-
if %*ENV<EXERCISM> {
|
38
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
39
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
40
|
-
} else { flunk 'canonical-data' }
|
41
|
-
} else { skip }
|
42
|
-
|
43
38
|
done-testing; #`[There are no more tests after this :)]
|
44
39
|
|
45
40
|
#`['INIT' is a phaser, it makes sure that the test data is available before everything else
|
@@ -205,4 +200,22 @@ $c-data := from-json q:to/END/;
|
|
205
200
|
}
|
206
201
|
|
207
202
|
END
|
203
|
+
|
204
|
+
if %*ENV<EXERCISM> {
|
205
|
+
#`[Don't worry about the stuff in here for your exercise.
|
206
|
+
This is for Exercism folks to check that everything is in order.]
|
207
|
+
$module = 'Example';
|
208
|
+
if (my $c-data-file =
|
209
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
210
|
+
.IO.resolve) ~~ :f
|
211
|
+
{
|
212
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
213
|
+
}
|
214
|
+
else {
|
215
|
+
flunk 'canonical-data';
|
216
|
+
}
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
skip;
|
220
|
+
}
|
208
221
|
}
|
@@ -8,14 +8,14 @@ tests: |
|
|
8
8
|
is ::($exercise).?hey(.<input>), |.<expected description> for @($c-data<cases>);
|
9
9
|
|
10
10
|
exercise_comment: The name of this exercise.
|
11
|
-
module_comment:
|
11
|
+
module_comment: The name of the module file to be loaded.
|
12
12
|
version_comment: The version we will be matching against the exercise.
|
13
13
|
lib_comment: Look for the module inside the same directory as this test file.
|
14
14
|
plan_comment: This is how many tests we expect to run.
|
15
15
|
use_test_comment: Check that the module can be use-d.
|
16
16
|
version_test_comment: "If the exercise is updated, we want to make sure other people testing\nyour code don't think you've made a mistake if things have changed!"
|
17
17
|
methods_comment: "Check that the class 'Bob' can use all of the methods\nneeded in the tests (only 'hey' for this one)."
|
18
|
-
|
18
|
+
exercism_comment: "Don't worry about the stuff in here for your exercise.\nThis is for Exercism folks to check that everything is in order."
|
19
19
|
done_testing_comment: There are no more tests after this :)
|
20
20
|
INIT_comment: "'INIT' is a phaser, it makes sure that the test data is available before everything else\nstarts running (otherwise we'd have to shove the test data into the middle of the file!)"
|
21
21
|
|
@@ -4,10 +4,12 @@ use Test;
|
|
4
4
|
use lib my $dir = $?FILE.IO.dirname;
|
5
5
|
use JSON::Fast;
|
6
6
|
|
7
|
-
my $exercise
|
8
|
-
my $version = v1;
|
9
|
-
my $module
|
10
|
-
|
7
|
+
my Str:D $exercise := 'Clock';
|
8
|
+
my Version:D $version = v1;
|
9
|
+
my Str $module //= $exercise;
|
10
|
+
INIT {
|
11
|
+
plan 54;
|
12
|
+
}
|
11
13
|
|
12
14
|
use-ok $module or bail-out;
|
13
15
|
require ::($module);
|
@@ -48,12 +50,6 @@ for @($c-data<cases>) {
|
|
48
50
|
todo 'optional test' unless %*ENV<EXERCISM>;
|
49
51
|
is ::($exercise).new(:0hour,:0minute).?add-minutes(65).?time, '01:05', 'add-minutes method can be chained';
|
50
52
|
|
51
|
-
if %*ENV<EXERCISM> {
|
52
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
53
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
54
|
-
} else { flunk 'canonical-data' }
|
55
|
-
} else { skip }
|
56
|
-
|
57
53
|
done-testing;
|
58
54
|
|
59
55
|
INIT {
|
@@ -550,4 +546,20 @@ $c-data := from-json q:to/END/;
|
|
550
546
|
}
|
551
547
|
|
552
548
|
END
|
549
|
+
|
550
|
+
if %*ENV<EXERCISM> {
|
551
|
+
$module = 'Example';
|
552
|
+
if (my $c-data-file =
|
553
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
554
|
+
.IO.resolve) ~~ :f
|
555
|
+
{
|
556
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
557
|
+
}
|
558
|
+
else {
|
559
|
+
flunk 'canonical-data';
|
560
|
+
}
|
561
|
+
}
|
562
|
+
else {
|
563
|
+
skip;
|
564
|
+
}
|
553
565
|
}
|
@@ -3,14 +3,13 @@
|
|
3
3
|
Take a nested list and return a single flattened list with all values except nil/null.
|
4
4
|
|
5
5
|
The challenge is to write a function that accepts an arbitrarily-deep nested list-like structure and returns a flattened structure without any nil/null values.
|
6
|
-
|
6
|
+
|
7
7
|
For Example
|
8
8
|
|
9
9
|
input: [1,[2,3,null,4],[null],5]
|
10
10
|
|
11
11
|
output: [1,2,3,4,5]
|
12
12
|
|
13
|
-
|
14
13
|
## Resources
|
15
14
|
|
16
15
|
Remember to check out the Perl 6 [documentation](https://docs.perl6.org/) and
|
@@ -4,10 +4,12 @@ use Test;
|
|
4
4
|
use lib my $dir = $?FILE.IO.dirname;
|
5
5
|
use JSON::Fast;
|
6
6
|
|
7
|
-
my $exercise
|
8
|
-
my $version = v1;
|
9
|
-
my $module
|
10
|
-
|
7
|
+
my Str:D $exercise := 'FlattenArray';
|
8
|
+
my Version:D $version = v1;
|
9
|
+
my Str $module //= $exercise;
|
10
|
+
INIT {
|
11
|
+
plan 8;
|
12
|
+
}
|
11
13
|
|
12
14
|
use-ok $module or bail-out;
|
13
15
|
require ::($module);
|
@@ -22,13 +24,7 @@ if ::($exercise).^ver !~~ $version {
|
|
22
24
|
require ::($module) <&flatten-array>;
|
23
25
|
|
24
26
|
my $c-data;
|
25
|
-
is-deeply
|
26
|
-
|
27
|
-
if %*ENV<EXERCISM> {
|
28
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
29
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
30
|
-
} else { flunk 'canonical-data' }
|
31
|
-
} else { skip }
|
27
|
+
is-deeply flatten-array(.<input>), |.<expected description> for @($c-data<cases>);
|
32
28
|
|
33
29
|
done-testing;
|
34
30
|
|
@@ -79,4 +75,20 @@ $c-data := from-json q:to/END/;
|
|
79
75
|
}
|
80
76
|
|
81
77
|
END
|
78
|
+
|
79
|
+
if %*ENV<EXERCISM> {
|
80
|
+
$module = 'Example';
|
81
|
+
if (my $c-data-file =
|
82
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
83
|
+
.IO.resolve) ~~ :f
|
84
|
+
{
|
85
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
flunk 'canonical-data';
|
89
|
+
}
|
90
|
+
}
|
91
|
+
else {
|
92
|
+
skip;
|
93
|
+
}
|
82
94
|
}
|
@@ -3,9 +3,9 @@ use v6;
|
|
3
3
|
use Test;
|
4
4
|
use lib $?FILE.IO.dirname;
|
5
5
|
|
6
|
-
my $exercise
|
7
|
-
my $version = v1;
|
8
|
-
my $module
|
6
|
+
my Str:D $exercise := 'GradeSchool';
|
7
|
+
my Version:D $version = v1;
|
8
|
+
my Str $module //= $exercise;
|
9
9
|
plan 10;
|
10
10
|
|
11
11
|
use-ok $module or bail-out;
|
@@ -40,3 +40,9 @@ subtest 'Additional students', {
|
|
40
40
|
is $roster.?list-all, ('Grade 1', <Anna Barb Charlie>, 'Grade 2', <Alex Jim Zoe>, 'Grade 3', <Dick Harry Tom>), 'List all';
|
41
41
|
|
42
42
|
done-testing;
|
43
|
+
|
44
|
+
INIT {
|
45
|
+
if %*ENV<EXERCISM> {
|
46
|
+
$module = 'Example';
|
47
|
+
}
|
48
|
+
}
|