trackler 2.2.1.43 → 2.2.1.44
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/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
|
@@ -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 := 'Grains';
|
|
8
|
+
my Version:D $version = v1;
|
|
9
|
+
my Str $module //= $exercise;
|
|
10
|
+
INIT {
|
|
11
|
+
plan 13;
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
use-ok $module or bail-out;
|
|
13
15
|
require ::($module);
|
|
@@ -31,12 +33,6 @@ for @($c-data<cases>[0]<cases>) {
|
|
|
31
33
|
}
|
|
32
34
|
is total-grains, |$c-data<cases>[1]<expected description>;
|
|
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 {
|
|
@@ -125,4 +121,20 @@ $c-data := from-json q:to/END/;
|
|
|
125
121
|
}
|
|
126
122
|
|
|
127
123
|
END
|
|
124
|
+
|
|
125
|
+
if %*ENV<EXERCISM> {
|
|
126
|
+
$module = 'Example';
|
|
127
|
+
if (my $c-data-file =
|
|
128
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
|
129
|
+
.IO.resolve) ~~ :f
|
|
130
|
+
{
|
|
131
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
flunk 'canonical-data';
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
skip;
|
|
139
|
+
}
|
|
128
140
|
}
|
|
@@ -5,17 +5,17 @@ imports: '&hello'
|
|
|
5
5
|
tests: |
|
|
6
6
|
#`[Go through the cases (hiding at the bottom of this file)
|
|
7
7
|
and check that &hello gives us the correct response.]
|
|
8
|
-
is
|
|
8
|
+
is hello, |.<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
|
imports_comment: Import '&hello' from 'HelloWorld'
|
|
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; #`[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 = v2; #`[The version we will be matching against the exercise.]
|
|
9
|
-
my $module
|
|
10
|
-
|
|
7
|
+
my Str:D $exercise := 'HelloWorld'; #`[The name of this exercise.]
|
|
8
|
+
my Version:D $version = v2; #`[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 3; #`[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;
|
|
@@ -28,14 +30,7 @@ require ::($module) <&hello>;
|
|
|
28
30
|
my $c-data;
|
|
29
31
|
#`[Go through the cases (hiding at the bottom of this file)
|
|
30
32
|
and check that &hello gives us the correct response.]
|
|
31
|
-
is
|
|
32
|
-
|
|
33
|
-
#`[Ignore this for your exercise! Tells Exercism folks when exercise cases become out of date.]
|
|
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 }
|
|
33
|
+
is hello, |.<expected description> for @($c-data<cases>);
|
|
39
34
|
|
|
40
35
|
done-testing; #`[There are no more tests after this :)]
|
|
41
36
|
|
|
@@ -57,4 +52,22 @@ $c-data := from-json q:to/END/;
|
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
END
|
|
55
|
+
|
|
56
|
+
if %*ENV<EXERCISM> {
|
|
57
|
+
#`[Don't worry about the stuff in here for your exercise.
|
|
58
|
+
This is for Exercism folks to check that everything is in order.]
|
|
59
|
+
$module = 'Example';
|
|
60
|
+
if (my $c-data-file =
|
|
61
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
|
62
|
+
.IO.resolve) ~~ :f
|
|
63
|
+
{
|
|
64
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
flunk 'canonical-data';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
skip;
|
|
72
|
+
}
|
|
60
73
|
}
|
|
@@ -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
|
|
@@ -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 := 'Leap';
|
|
8
|
+
my Version:D $version = v1;
|
|
9
|
+
my Str $module //= $exercise;
|
|
10
|
+
INIT {
|
|
11
|
+
plan 6;
|
|
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) <&is-leap-year>;
|
|
23
25
|
|
|
24
26
|
my $c-data;
|
|
25
|
-
is
|
|
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 is-leap-year(.<input>), |.<expected description> for @($c-data<cases>);
|
|
32
28
|
|
|
33
29
|
done-testing;
|
|
34
30
|
|
|
@@ -67,4 +63,20 @@ $c-data := from-json q:to/END/;
|
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
END
|
|
66
|
+
|
|
67
|
+
if %*ENV<EXERCISM> {
|
|
68
|
+
$module = 'Example';
|
|
69
|
+
if (my $c-data-file =
|
|
70
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
|
71
|
+
.IO.resolve) ~~ :f
|
|
72
|
+
{
|
|
73
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
flunk 'canonical-data';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
skip;
|
|
81
|
+
}
|
|
70
82
|
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Implement a doubly linked list.
|
|
4
4
|
|
|
5
|
-
Like an array, a linked list is a simple linear data structure. Several
|
|
6
|
-
common data types can be implemented using linked lists, like queues,
|
|
5
|
+
Like an array, a linked list is a simple linear data structure. Several
|
|
6
|
+
common data types can be implemented using linked lists, like queues,
|
|
7
7
|
stacks, and associative arrays.
|
|
8
8
|
|
|
9
|
-
A linked list is a collection of data elements called *nodes*. In a
|
|
10
|
-
*singly linked list* each node holds a value and a link to the next node.
|
|
11
|
-
In a *doubly linked list* each node also holds a link to the previous
|
|
9
|
+
A linked list is a collection of data elements called *nodes*. In a
|
|
10
|
+
*singly linked list* each node holds a value and a link to the next node.
|
|
11
|
+
In a *doubly linked list* each node also holds a link to the previous
|
|
12
12
|
node.
|
|
13
13
|
|
|
14
|
-
You will write an implementation of a doubly linked list. Implement a
|
|
15
|
-
Node to hold a value and pointers to the next and previous nodes. Then
|
|
16
|
-
implement a List which holds references to the first and last node and
|
|
14
|
+
You will write an implementation of a doubly linked list. Implement a
|
|
15
|
+
Node to hold a value and pointers to the next and previous nodes. Then
|
|
16
|
+
implement a List which holds references to the first and last node and
|
|
17
17
|
offers an array-like interface for adding and removing items:
|
|
18
18
|
|
|
19
19
|
* `push` (*insert value at back*);
|
|
@@ -21,8 +21,8 @@ offers an array-like interface for adding and removing items:
|
|
|
21
21
|
* `shift` (*remove value at front*).
|
|
22
22
|
* `unshift` (*insert value at front*);
|
|
23
23
|
|
|
24
|
-
To keep your implementation simple, the tests will not cover error
|
|
25
|
-
conditions. Specifically: `pop` or `shift` will never be called on an
|
|
24
|
+
To keep your implementation simple, the tests will not cover error
|
|
25
|
+
conditions. Specifically: `pop` or `shift` will never be called on an
|
|
26
26
|
empty list.
|
|
27
27
|
|
|
28
28
|
If you want to know more about linked lists, check [Wikipedia](https://en.wikipedia.org/wiki/Linked_list).
|
|
@@ -4,9 +4,9 @@ use Test;
|
|
|
4
4
|
use lib $?FILE.IO.dirname;
|
|
5
5
|
use JSON::Fast;
|
|
6
6
|
|
|
7
|
-
my $exercise
|
|
8
|
-
my $version = v1;
|
|
9
|
-
my $module
|
|
7
|
+
my Str:D $exercise := 'LinkedList';
|
|
8
|
+
my Version:D $version = v1;
|
|
9
|
+
my Str $module //= $exercise;
|
|
10
10
|
plan 7;
|
|
11
11
|
|
|
12
12
|
use-ok $module or bail-out;
|
|
@@ -99,3 +99,9 @@ INIT {
|
|
|
99
99
|
]
|
|
100
100
|
」
|
|
101
101
|
}
|
|
102
|
+
|
|
103
|
+
INIT {
|
|
104
|
+
if %*ENV<EXERCISM> {
|
|
105
|
+
$module = 'Example';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -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
|
|
|
@@ -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 := 'Luhn';
|
|
8
|
+
my Version:D $version = v1;
|
|
9
|
+
my Str $module //= $exercise;
|
|
10
|
+
INIT {
|
|
11
|
+
plan 15;
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
use-ok $module or bail-out;
|
|
13
15
|
require ::($module);
|
|
@@ -24,12 +26,6 @@ require ::($module) <&is-luhn-valid>;
|
|
|
24
26
|
my $c-data;
|
|
25
27
|
is .<input>.&is-luhn-valid, |.<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 {
|
|
@@ -121,4 +117,20 @@ $c-data := from-json q:to/END/;
|
|
|
121
117
|
}
|
|
122
118
|
|
|
123
119
|
END
|
|
120
|
+
|
|
121
|
+
if %*ENV<EXERCISM> {
|
|
122
|
+
$module = 'Example';
|
|
123
|
+
if (my $c-data-file =
|
|
124
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
|
125
|
+
.IO.resolve) ~~ :f
|
|
126
|
+
{
|
|
127
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
flunk 'canonical-data';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
skip;
|
|
135
|
+
}
|
|
124
136
|
}
|
|
@@ -6,11 +6,12 @@ The **North American Numbering Plan (NANP)** is a telephone numbering system use
|
|
|
6
6
|
|
|
7
7
|
NANP numbers are ten-digit numbers consisting of a three-digit Numbering Plan Area code, commonly known as *area code*, followed by a seven-digit local number. The first three digits of the local number represent the *exchange code*, followed by the unique four-digit number which is the *subscriber number*.
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
The format is usually represented as
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
12
|
(NXX)-NXX-XXXX
|
|
13
13
|
```
|
|
14
|
+
|
|
14
15
|
where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9.
|
|
15
16
|
|
|
16
17
|
Your task is to clean up differently formated telephone numbers by removing punctuation and the country code (1) if present.
|
|
@@ -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 = v3;
|
|
9
|
-
my $module
|
|
10
|
-
|
|
7
|
+
my Str:D $exercise := 'Phone';
|
|
8
|
+
my Version:D $version = v3;
|
|
9
|
+
my Str $module //= $exercise;
|
|
10
|
+
INIT {
|
|
11
|
+
plan 14;
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
use-ok $module or bail-out;
|
|
13
15
|
require ::($module);
|
|
@@ -30,12 +32,6 @@ for @($c-data<cases>[0]<cases>) {
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
if %*ENV<EXERCISM> {
|
|
34
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
|
35
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
|
36
|
-
} else { flunk 'canonical-data' }
|
|
37
|
-
} else { skip }
|
|
38
|
-
|
|
39
35
|
done-testing;
|
|
40
36
|
|
|
41
37
|
INIT {
|
|
@@ -131,4 +127,20 @@ $c-data := from-json q:to/END/;
|
|
|
131
127
|
}
|
|
132
128
|
|
|
133
129
|
END
|
|
130
|
+
|
|
131
|
+
if %*ENV<EXERCISM> {
|
|
132
|
+
$module = 'Example';
|
|
133
|
+
if (my $c-data-file =
|
|
134
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
|
135
|
+
.IO.resolve) ~~ :f
|
|
136
|
+
{
|
|
137
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
flunk 'canonical-data';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
skip;
|
|
145
|
+
}
|
|
134
146
|
}
|
|
@@ -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 := 'Raindrops';
|
|
8
|
+
my Version:D $version = v1;
|
|
9
|
+
my Str $module //= $exercise;
|
|
10
|
+
INIT {
|
|
11
|
+
plan 20;
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
use-ok $module or bail-out;
|
|
13
15
|
require ::($module);
|
|
@@ -30,12 +32,6 @@ for @($c-data<cases>) {
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
if %*ENV<EXERCISM> {
|
|
34
|
-
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
|
|
35
|
-
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
|
|
36
|
-
} else { flunk 'canonical-data' }
|
|
37
|
-
} else { skip }
|
|
38
|
-
|
|
39
35
|
done-testing;
|
|
40
36
|
|
|
41
37
|
INIT {
|
|
@@ -157,4 +153,20 @@ $c-data := from-json q:to/END/;
|
|
|
157
153
|
}
|
|
158
154
|
|
|
159
155
|
END
|
|
156
|
+
|
|
157
|
+
if %*ENV<EXERCISM> {
|
|
158
|
+
$module = 'Example';
|
|
159
|
+
if (my $c-data-file =
|
|
160
|
+
"$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json"
|
|
161
|
+
.IO.resolve) ~~ :f
|
|
162
|
+
{
|
|
163
|
+
is-deeply $c-data, EVAL('from-json $c-data-file.slurp'), 'canonical-data';
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
flunk 'canonical-data';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
skip;
|
|
171
|
+
}
|
|
160
172
|
}
|