trackler 2.2.1.53 → 2.2.1.54
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/nth-prime/canonical-data.json +2 -7
- data/problem-specifications/exercises/zebra-puzzle/canonical-data.json +16 -0
- data/tracks/c/config.json +11 -1
- data/tracks/c/docs/C_STYLE_GUIDE.md +142 -0
- data/tracks/c/exercises/collatz-conjecture/README.md +65 -0
- data/tracks/c/exercises/collatz-conjecture/makefile +15 -0
- data/tracks/c/exercises/collatz-conjecture/src/collatz_conjecture.h +8 -0
- data/tracks/c/exercises/collatz-conjecture/src/example.c +23 -0
- data/tracks/c/exercises/collatz-conjecture/test/test_collatz_conjecture.c +48 -0
- data/tracks/c/exercises/collatz-conjecture/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/collatz-conjecture/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/collatz-conjecture/test/vendor/unity_internals.h +701 -0
- data/tracks/cfml/tasks/GenerateReadme.cfc +5 -5
- data/tracks/erlang/testgen/src/testgen.erl +99 -17
- data/tracks/erlang/testgen/src/tg_file_tools.erl +3 -3
- data/tracks/erlang/testgen/src/tgen.erl +15 -7
- data/tracks/haskell/config.json +15 -3
- data/tracks/java/scripts/canonical_data_check.sh +1 -1
- data/tracks/javascript/config.json +12 -0
- data/tracks/javascript/exercises/difference-of-squares/README.md +1 -1
- data/tracks/javascript/exercises/sum-of-multiples/README.md +1 -1
- data/tracks/javascript/exercises/zipper/README.md +55 -0
- data/tracks/javascript/exercises/zipper/example.js +100 -0
- data/tracks/javascript/exercises/zipper/zipper.spec.js +77 -0
- data/tracks/julia/config.json +12 -0
- data/tracks/julia/exercises/triangle/README.md +30 -0
- data/tracks/julia/exercises/triangle/example.jl +25 -0
- data/tracks/julia/exercises/triangle/runtests.jl +64 -0
- data/tracks/julia/exercises/triangle/triangle.jl +8 -0
- data/tracks/kotlin/exercises/leap/.meta/version +1 -1
- data/tracks/kotlin/exercises/leap/src/test/kotlin/LeapTest.kt +1 -1
- data/tracks/kotlin/scripts/canonical_data_check.sh +1 -1
- data/tracks/perl6/bin/README.md +1 -4
- data/tracks/perl6/bin/exercise-gen.pl6 +3 -4
- data/tracks/perl6/exercises/accumulate/example.yaml +2 -2
- data/tracks/perl6/exercises/all-your-base/example.yaml +9 -9
- data/tracks/perl6/exercises/allergies/example.yaml +7 -7
- data/tracks/perl6/exercises/anagram/example.yaml +3 -3
- data/tracks/perl6/exercises/atbash-cipher/example.yaml +3 -3
- data/tracks/perl6/exercises/bob/example.yaml +4 -4
- data/tracks/perl6/exercises/clock/example.yaml +6 -6
- data/tracks/perl6/exercises/flatten-array/example.yaml +4 -4
- data/tracks/perl6/exercises/grade-school/example.yaml +6 -6
- data/tracks/perl6/exercises/grains/example.yaml +3 -3
- data/tracks/perl6/exercises/hello-world/example.yaml +5 -5
- data/tracks/perl6/exercises/leap/example.yaml +4 -4
- data/tracks/perl6/exercises/linked-list/example.yaml +14 -14
- data/tracks/perl6/exercises/luhn/example.yaml +3 -3
- data/tracks/perl6/exercises/phone-number/example.yaml +3 -3
- data/tracks/perl6/exercises/raindrops/example.yaml +3 -3
- data/tracks/perl6/exercises/rna-transcription/example.yaml +3 -3
- data/tracks/perl6/exercises/robot-name/example.yaml +8 -8
- data/tracks/perl6/exercises/scrabble-score/example.yaml +3 -3
- data/tracks/perl6/exercises/space-age/example.yaml +8 -8
- data/tracks/perl6/exercises/word-count/example.yaml +3 -3
- data/tracks/perl6/exercises/wordy/example.yaml +3 -3
- data/tracks/python/config.json +14 -0
- data/tracks/python/config/maintainers.json +30 -0
- data/tracks/python/docs/EXERCISE_README_INSERT.md +1 -2
- data/tracks/python/exercises/accumulate/README.md +1 -5
- data/tracks/python/exercises/acronym/README.md +1 -3
- data/tracks/python/exercises/all-your-base/README.md +2 -3
- data/tracks/python/exercises/all-your-base/all_your_base_test.py +13 -13
- data/tracks/python/exercises/allergies/README.md +1 -3
- data/tracks/python/exercises/alphametics/README.md +3 -4
- data/tracks/python/exercises/anagram/README.md +1 -2
- data/tracks/python/exercises/atbash-cipher/README.md +3 -3
- data/tracks/python/exercises/beer-song/README.md +2 -3
- data/tracks/python/exercises/binary-search/README.md +1 -2
- data/tracks/python/exercises/binary/README.md +3 -2
- data/tracks/python/exercises/bob/README.md +1 -2
- data/tracks/python/exercises/book-store/README.md +6 -7
- data/tracks/python/exercises/bracket-push/README.md +1 -2
- data/tracks/python/exercises/change/README.md +2 -3
- data/tracks/python/exercises/circular-buffer/README.md +14 -8
- data/tracks/python/exercises/clock/README.md +1 -2
- data/tracks/python/exercises/clock/clock_test.py +2 -0
- data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +3 -0
- data/tracks/python/exercises/collatz-conjecture/README.md +6 -19
- data/tracks/python/exercises/complex-numbers/README.md +28 -2
- data/tracks/python/exercises/crypto-square/README.md +11 -10
- data/tracks/python/exercises/diamond/README.md +7 -8
- data/tracks/python/exercises/difference-of-squares/README.md +1 -2
- data/tracks/python/exercises/diffie-hellman/.meta/hints.md +1 -1
- data/tracks/python/exercises/diffie-hellman/README.md +3 -2
- data/tracks/python/exercises/error-handling/.meta/hints.md +8 -0
- data/tracks/python/exercises/error-handling/README.md +10 -2
- data/tracks/python/exercises/error-handling/error_handling_test.py +15 -3
- data/tracks/python/exercises/etl/README.md +3 -2
- data/tracks/python/exercises/flatten-array/README.md +2 -4
- data/tracks/python/exercises/food-chain/README.md +3 -4
- data/tracks/python/exercises/forth/README.md +2 -6
- data/tracks/python/exercises/gigasecond/README.md +1 -2
- data/tracks/python/exercises/grade-school/README.md +1 -3
- data/tracks/python/exercises/grains/README.md +1 -3
- data/tracks/python/exercises/grep/README.md +13 -14
- data/tracks/python/exercises/hamming/README.md +1 -2
- data/tracks/python/exercises/hamming/hamming_test.py +6 -6
- data/tracks/python/exercises/hello-world/README.md +1 -2
- data/tracks/python/exercises/hexadecimal/README.md +1 -2
- data/tracks/python/exercises/hexadecimal/example.py +6 -6
- data/tracks/python/exercises/house/README.md +2 -4
- data/tracks/python/exercises/isogram/README.md +3 -3
- data/tracks/python/exercises/kindergarten-garden/README.md +14 -15
- data/tracks/python/exercises/largest-series-product/README.md +1 -2
- data/tracks/python/exercises/leap/README.md +2 -3
- data/tracks/python/exercises/linked-list/README.md +11 -12
- data/tracks/python/exercises/list-ops/README.md +1 -2
- data/tracks/python/exercises/luhn/README.md +8 -9
- data/tracks/python/exercises/markdown/README.md +1 -6
- data/tracks/python/exercises/matrix/README.md +7 -6
- data/tracks/python/exercises/meetup/README.md +2 -4
- data/tracks/python/exercises/minesweeper/README.md +1 -2
- data/tracks/python/exercises/nth-prime/README.md +1 -2
- data/tracks/python/exercises/nucleotide-count/README.md +9 -24
- data/tracks/python/exercises/ocr-numbers/README.md +6 -7
- data/tracks/python/exercises/octal/README.md +7 -4
- data/tracks/python/exercises/palindrome-products/README.md +16 -18
- data/tracks/python/exercises/pangram/README.md +2 -3
- data/tracks/python/exercises/pascals-triangle/README.md +2 -3
- data/tracks/python/exercises/perfect-numbers/README.md +3 -4
- data/tracks/python/exercises/phone-number/README.md +4 -4
- data/tracks/python/exercises/pig-latin/README.md +1 -2
- data/tracks/python/exercises/point-mutations/README.md +1 -2
- data/tracks/python/exercises/poker/README.md +1 -2
- data/tracks/python/exercises/prime-factors/README.md +1 -2
- data/tracks/python/exercises/protein-translation/README.md +5 -7
- data/tracks/python/exercises/proverb/README.md +12 -11
- data/tracks/python/exercises/pythagorean-triplet/README.md +4 -5
- data/tracks/python/exercises/queen-attack/README.md +2 -3
- data/tracks/python/exercises/rail-fence-cipher/README.md +13 -9
- data/tracks/python/exercises/raindrops/README.md +1 -2
- data/tracks/python/exercises/rectangles/README.md +8 -9
- data/tracks/python/exercises/rectangles/example.py +3 -3
- data/tracks/python/exercises/rna-transcription/README.md +1 -2
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +4 -3
- data/tracks/python/exercises/robot-name/README.md +1 -2
- data/tracks/python/exercises/robot-simulator/README.md +1 -2
- data/tracks/python/exercises/roman-numerals/README.md +2 -3
- data/tracks/python/exercises/rotational-cipher/README.md +3 -3
- data/tracks/python/exercises/run-length-encoding/README.md +5 -6
- data/tracks/python/exercises/run-length-encoding/example.py +2 -2
- data/tracks/python/exercises/saddle-points/README.md +2 -3
- data/tracks/python/exercises/say/README.md +1 -2
- data/tracks/python/exercises/scale-generator/README.md +1 -3
- data/tracks/python/exercises/scrabble-score/README.md +4 -3
- data/tracks/python/exercises/secret-handshake/README.md +2 -3
- data/tracks/python/exercises/series/README.md +1 -2
- data/tracks/python/exercises/sieve/README.md +1 -2
- data/tracks/python/exercises/simple-cipher/README.md +3 -4
- data/tracks/python/exercises/space-age/README.md +2 -3
- data/tracks/python/exercises/space-age/space_age_test.py +18 -29
- data/tracks/python/exercises/strain/README.md +1 -2
- data/tracks/python/exercises/sublist/README.md +1 -2
- data/tracks/python/exercises/sum-of-multiples/README.md +1 -5
- data/tracks/python/exercises/tournament/README.md +6 -7
- data/tracks/python/exercises/transpose/README.md +8 -9
- data/tracks/python/exercises/tree-building/README.md +25 -0
- data/tracks/python/exercises/tree-building/example.py +46 -0
- data/tracks/python/exercises/tree-building/tree_building.py +50 -0
- data/tracks/python/exercises/tree-building/tree_building_test.py +183 -0
- data/tracks/python/exercises/triangle/README.md +10 -8
- data/tracks/python/exercises/trinary/README.md +2 -3
- data/tracks/python/exercises/twelve-days/README.md +2 -3
- data/tracks/python/exercises/two-bucket/README.md +4 -5
- data/tracks/python/exercises/two-bucket/two_bucket_test.py +2 -0
- data/tracks/python/exercises/two-fer/README.md +4 -5
- data/tracks/python/exercises/two-fer/two_fer_test.py +5 -2
- data/tracks/python/exercises/variable-length-quantity/README.md +7 -9
- data/tracks/python/exercises/word-count/README.md +2 -4
- data/tracks/python/exercises/word-search/README.md +2 -3
- data/tracks/python/exercises/wordy/README.md +1 -7
- data/tracks/python/exercises/wordy/example.py +8 -8
- data/tracks/python/exercises/wordy/wordy_test.py +36 -32
- data/tracks/python/exercises/zebra-puzzle/README.md +1 -2
- data/tracks/python/requirements-travis.txt +1 -1
- data/tracks/ruby/config.json +11 -0
- data/tracks/ruby/docs/TESTS.md +6 -0
- data/tracks/ruby/exercises/pangram/.meta/.version +1 -1
- data/tracks/ruby/exercises/pangram/.meta/solutions/pangram.rb +1 -1
- data/tracks/ruby/exercises/pangram/pangram_test.rb +11 -4
- data/tracks/ruby/exercises/two-fer/.meta/.version +1 -0
- data/tracks/ruby/exercises/two-fer/.meta/generator/two_fer_case.rb +12 -0
- data/tracks/ruby/exercises/two-fer/.meta/solutions/two_fer.rb +9 -0
- data/tracks/ruby/exercises/two-fer/README.md +69 -0
- data/tracks/ruby/exercises/two-fer/two_fer_test.rb +42 -0
- data/tracks/rust/config.json +12 -0
- data/tracks/rust/exercises/binary-search/.meta/hints.md +38 -0
- data/tracks/rust/exercises/binary-search/Cargo.lock +4 -0
- data/tracks/rust/exercises/binary-search/Cargo.toml +6 -0
- data/tracks/rust/exercises/binary-search/README.md +113 -0
- data/tracks/rust/exercises/binary-search/example.rs +29 -0
- data/tracks/rust/exercises/binary-search/src/lib.rs +0 -0
- data/tracks/rust/exercises/binary-search/tests/binary-search.rs +96 -0
- data/tracks/typescript/common/package.json +6 -6
- data/tracks/typescript/common/yarn.lock +929 -610
- data/tracks/typescript/exercises/acronym/package.json +6 -6
- data/tracks/typescript/exercises/acronym/yarn.lock +929 -610
- data/tracks/typescript/exercises/anagram/package.json +6 -6
- data/tracks/typescript/exercises/anagram/yarn.lock +929 -610
- data/tracks/typescript/exercises/beer-song/package.json +6 -6
- data/tracks/typescript/exercises/beer-song/yarn.lock +929 -610
- data/tracks/typescript/exercises/binary-search-tree/package.json +6 -6
- data/tracks/typescript/exercises/binary-search-tree/yarn.lock +929 -610
- data/tracks/typescript/exercises/binary-search/package.json +6 -6
- data/tracks/typescript/exercises/binary-search/yarn.lock +929 -610
- data/tracks/typescript/exercises/bob/package.json +6 -6
- data/tracks/typescript/exercises/bob/yarn.lock +929 -610
- data/tracks/typescript/exercises/circular-buffer/package.json +6 -6
- data/tracks/typescript/exercises/circular-buffer/yarn.lock +929 -610
- data/tracks/typescript/exercises/clock/package.json +6 -6
- data/tracks/typescript/exercises/clock/yarn.lock +929 -610
- data/tracks/typescript/exercises/difference-of-squares/package.json +6 -6
- data/tracks/typescript/exercises/difference-of-squares/yarn.lock +929 -610
- data/tracks/typescript/exercises/etl/package.json +6 -6
- data/tracks/typescript/exercises/etl/yarn.lock +929 -610
- data/tracks/typescript/exercises/food-chain/package.json +6 -6
- data/tracks/typescript/exercises/food-chain/yarn.lock +929 -610
- data/tracks/typescript/exercises/gigasecond/package.json +6 -6
- data/tracks/typescript/exercises/gigasecond/yarn.lock +929 -610
- data/tracks/typescript/exercises/grade-school/package.json +6 -6
- data/tracks/typescript/exercises/grade-school/yarn.lock +929 -610
- data/tracks/typescript/exercises/hamming/package.json +6 -6
- data/tracks/typescript/exercises/hamming/yarn.lock +929 -610
- data/tracks/typescript/exercises/hello-world/README.md +354 -0
- data/tracks/typescript/exercises/hello-world/package.json +6 -6
- data/tracks/typescript/exercises/hello-world/yarn.lock +929 -610
- data/tracks/typescript/exercises/largest-series-product/package.json +6 -6
- data/tracks/typescript/exercises/largest-series-product/yarn.lock +929 -610
- data/tracks/typescript/exercises/leap/package.json +6 -6
- data/tracks/typescript/exercises/leap/yarn.lock +929 -610
- data/tracks/typescript/exercises/linked-list/package.json +6 -6
- data/tracks/typescript/exercises/linked-list/yarn.lock +929 -610
- data/tracks/typescript/exercises/nth-prime/package.json +6 -6
- data/tracks/typescript/exercises/nth-prime/yarn.lock +929 -610
- data/tracks/typescript/exercises/pangram/package.json +6 -6
- data/tracks/typescript/exercises/pangram/yarn.lock +929 -610
- data/tracks/typescript/exercises/pascals-triangle/package.json +6 -6
- data/tracks/typescript/exercises/pascals-triangle/yarn.lock +929 -610
- data/tracks/typescript/exercises/phone-number/package.json +6 -6
- data/tracks/typescript/exercises/phone-number/yarn.lock +929 -610
- data/tracks/typescript/exercises/prime-factors/package.json +6 -6
- data/tracks/typescript/exercises/prime-factors/yarn.lock +929 -610
- data/tracks/typescript/exercises/raindrops/package.json +6 -6
- data/tracks/typescript/exercises/raindrops/yarn.lock +929 -610
- data/tracks/typescript/exercises/rna-transcription/package.json +6 -6
- data/tracks/typescript/exercises/rna-transcription/yarn.lock +929 -610
- data/tracks/typescript/exercises/robot-name/package.json +6 -6
- data/tracks/typescript/exercises/robot-name/yarn.lock +929 -610
- data/tracks/typescript/exercises/robot-simulator/package.json +6 -6
- data/tracks/typescript/exercises/robot-simulator/yarn.lock +929 -610
- data/tracks/typescript/exercises/rotational-cipher/package.json +6 -6
- data/tracks/typescript/exercises/rotational-cipher/yarn.lock +929 -610
- data/tracks/typescript/exercises/say/package.json +6 -6
- data/tracks/typescript/exercises/say/yarn.lock +929 -610
- data/tracks/typescript/exercises/scrabble-score/package.json +6 -6
- data/tracks/typescript/exercises/scrabble-score/yarn.lock +929 -610
- data/tracks/typescript/exercises/series/package.json +6 -6
- data/tracks/typescript/exercises/series/yarn.lock +929 -610
- data/tracks/typescript/exercises/space-age/package.json +6 -6
- data/tracks/typescript/exercises/space-age/yarn.lock +929 -610
- data/tracks/typescript/exercises/strain/package.json +6 -6
- data/tracks/typescript/exercises/strain/yarn.lock +929 -610
- data/tracks/typescript/exercises/sum-of-multiples/package.json +6 -6
- data/tracks/typescript/exercises/sum-of-multiples/yarn.lock +929 -610
- data/tracks/typescript/exercises/triangle/package.json +6 -6
- data/tracks/typescript/exercises/triangle/yarn.lock +929 -610
- data/tracks/typescript/exercises/word-count/package.json +6 -6
- data/tracks/typescript/exercises/word-count/yarn.lock +929 -610
- data/tracks/typescript/exercises/wordy/package.json +6 -6
- data/tracks/typescript/exercises/wordy/yarn.lock +929 -610
- metadata +37 -2
@@ -2,7 +2,7 @@ exercise: Bob
|
|
2
2
|
version: 1
|
3
3
|
plan: 28
|
4
4
|
methods: hey
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
# Go through the cases and check that Bob gives us the correct responses.
|
7
7
|
is ::($exercise).?hey(.<input>), |.<expected description> for @($c-data<cases>);
|
8
8
|
|
@@ -17,12 +17,12 @@ methods_comment: "Check that the class 'Bob' can use all of the methods\nneeded
|
|
17
17
|
exercism_comment: "Don't worry about the stuff below here for your exercise.\nThis is for Exercism folks to check that everything is in order."
|
18
18
|
|
19
19
|
unit: class
|
20
|
-
unit_comment:
|
20
|
+
unit_comment: |-
|
21
21
|
#`[
|
22
22
|
Declare class 'Bob' with version and unit-scope the class
|
23
23
|
i.e. everything in this file is part of 'Bob'.
|
24
24
|
]
|
25
|
-
example:
|
25
|
+
example: |-
|
26
26
|
method hey ($msg) {
|
27
27
|
given $msg.trim {
|
28
28
|
when !* { 'Fine. Be that way!' }
|
@@ -31,7 +31,7 @@ example: |
|
|
31
31
|
default { 'Whatever.' }
|
32
32
|
}
|
33
33
|
}
|
34
|
-
stub:
|
34
|
+
stub: |-
|
35
35
|
method hey ($msg) {
|
36
36
|
#`[
|
37
37
|
Remove the comments and write some code here to pass the test suite.
|
@@ -2,7 +2,7 @@ exercise: Clock
|
|
2
2
|
version: 1
|
3
3
|
methods: time add-minutes
|
4
4
|
plan: 54
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
for @($c-data<cases>) {
|
7
7
|
for @(.<cases>) -> $case {
|
8
8
|
given $case<property> {
|
@@ -23,22 +23,22 @@ tests: |
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
}
|
26
|
-
|
26
|
+
|
27
27
|
todo 'optional test' unless %*ENV<EXERCISM>;
|
28
28
|
is ::($exercise).new(:0hour,:0minute).?add-minutes(65).?time, '01:05', 'add-minutes method can be chained';
|
29
29
|
|
30
30
|
unit: class
|
31
|
-
example:
|
31
|
+
example: |-
|
32
32
|
has Int:D $.hour = 0;
|
33
33
|
has Int:D $.minute = 0;
|
34
|
-
|
34
|
+
|
35
35
|
method time {
|
36
36
|
sprintf '%02d:%02d', ($!hour + $!minute div 60) % 24, $!minute % 60;
|
37
37
|
}
|
38
|
-
|
38
|
+
|
39
39
|
method add-minutes (Int:D $min) {
|
40
40
|
$!minute += $min and return self;
|
41
41
|
}
|
42
|
-
stub:
|
42
|
+
stub: |-
|
43
43
|
has $.hour;
|
44
44
|
has $.minute;
|
@@ -2,15 +2,15 @@ exercise: FlattenArray
|
|
2
2
|
version: 1
|
3
3
|
plan: 8
|
4
4
|
imports: '&flatten-array'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
is-deeply flatten-array(.<input>), |.<expected description> for @($c-data<cases>);
|
7
7
|
|
8
8
|
unit: module
|
9
|
-
example:
|
9
|
+
example: |-
|
10
10
|
sub flatten-array(@input --> Array) is export {
|
11
11
|
@input.&denest;
|
12
12
|
return my @result;
|
13
|
-
|
13
|
+
|
14
14
|
sub denest(@array) {
|
15
15
|
for @array {
|
16
16
|
.&denest when Array;
|
@@ -18,6 +18,6 @@ example: |
|
|
18
18
|
}
|
19
19
|
}
|
20
20
|
}
|
21
|
-
stub:
|
21
|
+
stub: |-
|
22
22
|
sub flatten-array(@input) is export {
|
23
23
|
}
|
@@ -2,7 +2,7 @@ exercise: GradeSchool
|
|
2
2
|
version: 1
|
3
3
|
plan: 10
|
4
4
|
imports: Roster
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
subtest "Roster class methods", {
|
7
7
|
plan 3;
|
8
8
|
ok ::('Roster').can($_), $_ for <add-student list-grade list-all>;
|
@@ -23,23 +23,23 @@ tests: |
|
|
23
23
|
is $roster.?list-all, ('Grade 1', <Anna Barb Charlie>, 'Grade 2', <Alex Jim Zoe>, 'Grade 3', <Dick Harry Tom>), 'List all';
|
24
24
|
|
25
25
|
unit: module
|
26
|
-
example:
|
26
|
+
example: |-
|
27
27
|
class Roster is export {
|
28
28
|
has %!roster;
|
29
|
-
|
29
|
+
|
30
30
|
method add-student (Str:D :$name!, Int:D :$grade!) {
|
31
31
|
%!roster.append($grade, $name);
|
32
32
|
}
|
33
|
-
|
33
|
+
|
34
34
|
method list-grade (Int:D $grade --> Seq:D) {
|
35
35
|
%!roster{$grade}.sort;
|
36
36
|
}
|
37
|
-
|
37
|
+
|
38
38
|
method list-all {
|
39
39
|
my @list.append("Grade $_", %!roster{$_}.sort) for %!roster.keys.sort;
|
40
40
|
return @list;
|
41
41
|
}
|
42
42
|
}
|
43
|
-
stub:
|
43
|
+
stub: |-
|
44
44
|
class Roster is export {
|
45
45
|
}
|
@@ -2,7 +2,7 @@ exercise: Grains
|
|
2
2
|
version: 1
|
3
3
|
plan: 13
|
4
4
|
imports: '&grains-on-square &total-grains'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
for @($c-data<cases>[0]<cases>) {
|
7
7
|
if .<expected> == -1 {
|
8
8
|
throws-like { grains-on-square(.<input>) }, Exception, .<description>;
|
@@ -13,12 +13,12 @@ tests: |
|
|
13
13
|
is total-grains, |$c-data<cases>[1]<expected description>;
|
14
14
|
|
15
15
|
unit: module
|
16
|
-
example:
|
16
|
+
example: |-
|
17
17
|
sub grains-on-square ($number) is export {
|
18
18
|
die if $number < 1 or $number > 64;
|
19
19
|
2**($number-1);
|
20
20
|
}
|
21
|
-
|
21
|
+
|
22
22
|
sub total-grains is export {
|
23
23
|
my Int $total;
|
24
24
|
for 1..64 { $total += grains-on-square($_) }
|
@@ -2,7 +2,7 @@ exercise: HelloWorld
|
|
2
2
|
version: 2
|
3
3
|
plan: 3
|
4
4
|
imports: '&hello'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
# Go through the cases and check that &hello gives us the correct response.
|
7
7
|
is hello, |.<expected description> for @($c-data<cases>);
|
8
8
|
|
@@ -17,21 +17,21 @@ imports_comment: Import '&hello' from 'HelloWorld'
|
|
17
17
|
exercism_comment: "Don't worry about the stuff below here for your exercise.\nThis is for Exercism folks to check that everything is in order."
|
18
18
|
|
19
19
|
unit: module
|
20
|
-
unit_comment:
|
20
|
+
unit_comment: |-
|
21
21
|
#`(
|
22
22
|
This is a 'stub' file. It's a little start on your solution.
|
23
23
|
It is not a complete solution though; you will have to write some code.
|
24
|
-
|
24
|
+
|
25
25
|
The ':ver<>' adverb defines the version of a module or class.
|
26
26
|
The version is checked in the test suite to ensure the exercise
|
27
27
|
and test suite line up. If the test is updated, it will indicate
|
28
28
|
to others who test your code that some tests may no longer pass.
|
29
29
|
)
|
30
|
-
example:
|
30
|
+
example: |-
|
31
31
|
sub hello is export {
|
32
32
|
'Hello, World!'
|
33
33
|
}
|
34
|
-
stub:
|
34
|
+
stub: |-
|
35
35
|
sub hello is export {
|
36
36
|
# Write your solution to pass the test suite here.
|
37
37
|
# Be sure to remove all stock comments once you are done!
|
@@ -2,20 +2,20 @@ exercise: Leap
|
|
2
2
|
version: 2
|
3
3
|
plan: 6
|
4
4
|
imports: '&is-leap-year'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
is is-leap-year(.<input>), |.<expected description> for @($c-data<cases>);
|
7
7
|
|
8
8
|
unit: module
|
9
|
-
example:
|
9
|
+
example: |-
|
10
10
|
sub is-leap-year ($year) is export {
|
11
11
|
is-divisible($year, 400)
|
12
12
|
|| is-divisible($year, 4)
|
13
13
|
&& !is-divisible($year, 100);
|
14
14
|
}
|
15
|
-
|
15
|
+
|
16
16
|
sub is-divisible($year, $number) {
|
17
17
|
$year % $number == 0 ?? True !! False;
|
18
18
|
}
|
19
|
-
stub:
|
19
|
+
stub: |-
|
20
20
|
sub is-leap-year ($year) is export {
|
21
21
|
}
|
@@ -4,7 +4,7 @@ plan: 7
|
|
4
4
|
modules:
|
5
5
|
- use: JSON::Fast
|
6
6
|
methods: 'push-list pop-list shift-list unshift-list'
|
7
|
-
tests:
|
7
|
+
tests: |-
|
8
8
|
my $cases = from-json $=pod.pop.contents;
|
9
9
|
for $cases.values -> $case {
|
10
10
|
subtest $case.<name>, sub {
|
@@ -22,7 +22,7 @@ tests: |
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
}
|
25
|
-
|
25
|
+
|
26
26
|
=head2 Test Data
|
27
27
|
=begin code
|
28
28
|
[
|
@@ -81,16 +81,16 @@ tests: |
|
|
81
81
|
=end code
|
82
82
|
|
83
83
|
unit: class
|
84
|
-
example:
|
84
|
+
example: |-
|
85
85
|
class ListNode {
|
86
86
|
has $.next is rw;
|
87
87
|
has $.previous is rw;
|
88
88
|
has $.value;
|
89
89
|
}
|
90
|
-
|
90
|
+
|
91
91
|
has $!first;
|
92
92
|
has $!last;
|
93
|
-
|
93
|
+
|
94
94
|
method push-list($value) {
|
95
95
|
my $next = ListNode.new( value => $value, previous => $!last );
|
96
96
|
if ( $!last ) {
|
@@ -100,7 +100,7 @@ example: |
|
|
100
100
|
$!first = $!last = $next;
|
101
101
|
}
|
102
102
|
}
|
103
|
-
|
103
|
+
|
104
104
|
method unshift-list($value) {
|
105
105
|
my $next = ListNode.new( value => $value, next => $!first );
|
106
106
|
if ( $!first ) {
|
@@ -110,23 +110,23 @@ example: |
|
|
110
110
|
$!first = $!last = $next;
|
111
111
|
}
|
112
112
|
}
|
113
|
-
|
113
|
+
|
114
114
|
method shift-list() {
|
115
115
|
my $f = $!first;
|
116
|
-
|
116
|
+
|
117
117
|
$!first = $!first.next;
|
118
|
-
|
118
|
+
|
119
119
|
unless $!first { $!last = $!first }
|
120
|
-
|
120
|
+
|
121
121
|
return $f.value;
|
122
122
|
}
|
123
|
-
|
123
|
+
|
124
124
|
method pop-list() {
|
125
125
|
my $f = $!last;
|
126
|
-
|
126
|
+
|
127
127
|
$!last = $!last.previous;
|
128
|
-
|
128
|
+
|
129
129
|
unless $!.last { $!first = $!last }
|
130
|
-
|
130
|
+
|
131
131
|
return $f.value;
|
132
132
|
}
|
@@ -2,11 +2,11 @@ exercise: Luhn
|
|
2
2
|
version: 1
|
3
3
|
plan: 15
|
4
4
|
imports: '&is-luhn-valid'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
is .<input>.&is-luhn-valid, |.<expected description> for @($c-data<cases>);
|
7
7
|
|
8
8
|
unit: module
|
9
|
-
example:
|
9
|
+
example: |-
|
10
10
|
sub is-luhn-valid ($input is copy) is export {
|
11
11
|
$input ~~ s:g/\s+//;
|
12
12
|
return False if $input.chars < 2 || $input ~~ /\D/;
|
@@ -20,6 +20,6 @@ example: |
|
|
20
20
|
}
|
21
21
|
return ($sum %% 10).so;
|
22
22
|
}
|
23
|
-
stub:
|
23
|
+
stub: |-
|
24
24
|
sub is-luhn-valid ($input) is export {
|
25
25
|
}
|
@@ -2,7 +2,7 @@ exercise: Phone
|
|
2
2
|
version: 3
|
3
3
|
plan: 14
|
4
4
|
imports: '&clean-number'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
for @($c-data<cases>[0]<cases>) {
|
7
7
|
if .<expected> {
|
8
8
|
is clean-number(.<phrase>), |.<expected description>;
|
@@ -12,11 +12,11 @@ tests: |
|
|
12
12
|
}
|
13
13
|
|
14
14
|
unit: module
|
15
|
-
example:
|
15
|
+
example: |-
|
16
16
|
sub clean-number ($number is copy) is export {
|
17
17
|
$number ~~ s:g/<:!Nd>//;
|
18
18
|
$number ~~ /^ 1? ( [ <[2..9]> <:Nd> ** 2 ] ** 2 <:Nd> ** 4 ) $/ ?? ~$0 !! Nil;
|
19
19
|
}
|
20
|
-
stub:
|
20
|
+
stub: |-
|
21
21
|
sub clean-number ($number) is export {
|
22
22
|
}
|
@@ -2,7 +2,7 @@ exercise: Raindrops
|
|
2
2
|
version: 1
|
3
3
|
plan: 20
|
4
4
|
imports: '&convert'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
for @($c-data<cases>) {
|
7
7
|
subtest {
|
8
8
|
plan 2;
|
@@ -12,7 +12,7 @@ tests: |
|
|
12
12
|
}
|
13
13
|
|
14
14
|
unit: module
|
15
|
-
example:
|
15
|
+
example: |-
|
16
16
|
sub convert (Int:D $num --> Str:D) is export {
|
17
17
|
my $str = '';
|
18
18
|
given $num {
|
@@ -22,6 +22,6 @@ example: |
|
|
22
22
|
}
|
23
23
|
return $str ?? $str !! $num.Str;
|
24
24
|
}
|
25
|
-
stub:
|
25
|
+
stub: |-
|
26
26
|
sub convert ($num) is export {
|
27
27
|
}
|
@@ -2,7 +2,7 @@ exercise: RNA
|
|
2
2
|
version: 1
|
3
3
|
plan: 10
|
4
4
|
imports: '&to-rna'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
for @($c-data<cases>) {
|
7
7
|
if .<expected> {
|
8
8
|
is .<dna>.&to-rna, |.<expected description>;
|
@@ -12,11 +12,11 @@ tests: |
|
|
12
12
|
}
|
13
13
|
|
14
14
|
unit: module
|
15
|
-
example:
|
15
|
+
example: |-
|
16
16
|
sub to-rna ($dna) is export {
|
17
17
|
fail if $dna ~~ /<-[AGCT]>/;
|
18
18
|
$dna.trans(<A G C T> => <U C G A>);
|
19
19
|
}
|
20
|
-
stub:
|
20
|
+
stub: |-
|
21
21
|
sub to-rna ($dna) is export {
|
22
22
|
}
|
@@ -2,23 +2,23 @@ exercise: Robot
|
|
2
2
|
version: 1
|
3
3
|
methods: name reset-name
|
4
4
|
plan: 8
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
srand 1;
|
7
7
|
my $robot = ::($exercise).?new;
|
8
8
|
my Str $name = $robot.?name;
|
9
9
|
like $name, /^^<[A..Z]>**2 <[0..9]>**3$$/, 'Name matches schema';
|
10
|
-
|
10
|
+
|
11
11
|
srand 2;
|
12
12
|
is $robot.?name, $name, 'Name is persistent';
|
13
13
|
srand 1;
|
14
14
|
isnt ::($exercise).new.?name, $name, 'New Robot cannot claim previous Robot name';
|
15
|
-
|
15
|
+
|
16
16
|
srand 1;
|
17
17
|
$robot.?reset-name;
|
18
18
|
$robot.?reset_name; # Allows next test to still pass for older solutions
|
19
|
-
|
19
|
+
|
20
20
|
isnt $robot.?name, $name, "'reset-name' cannot use previous Robot name";
|
21
|
-
|
21
|
+
|
22
22
|
diag "\nCreating 100 robots...";
|
23
23
|
push my @names, ::($exercise).new.name for 1..100;
|
24
24
|
is @names, @names.unique, 'All names are unique';
|
@@ -29,15 +29,15 @@ tests: |
|
|
29
29
|
}
|
30
30
|
|
31
31
|
unit: class
|
32
|
-
example:
|
32
|
+
example: |-
|
33
33
|
subset Name of Str where * ~~ /^<[A..Z]>**2 <[0..9]>**3$/;
|
34
34
|
has Name $.name = self.reset-name;
|
35
|
-
|
35
|
+
|
36
36
|
method reset-name {
|
37
37
|
state Promise:D $promise = start ('AA000'..'ZZ999').pick: *;
|
38
38
|
state Bool:D %record{Name:D};
|
39
39
|
state Int:D $i = 0;
|
40
|
-
|
40
|
+
|
41
41
|
if $promise.status ~~ 'Kept' {
|
42
42
|
($!name = $promise.result[$i++]) or die 'All names used.';
|
43
43
|
} else {
|
@@ -2,11 +2,11 @@ exercise: Scrabble
|
|
2
2
|
version: 1
|
3
3
|
plan: 13
|
4
4
|
imports: '&score'
|
5
|
-
tests:
|
5
|
+
tests: |-
|
6
6
|
is .<input>.&score, |.<expected description> for @($c-data<cases>);
|
7
7
|
|
8
8
|
unit: module
|
9
|
-
example:
|
9
|
+
example: |-
|
10
10
|
sub score (Str:D $word --> Int:D) is export {
|
11
11
|
my $score = 0;
|
12
12
|
for $word.lc.split('',:skip-empty) -> $letter {
|
@@ -22,6 +22,6 @@ example: |
|
|
22
22
|
}
|
23
23
|
return $score;
|
24
24
|
}
|
25
|
-
stub:
|
25
|
+
stub: |-
|
26
26
|
sub score ($word) is export {
|
27
27
|
}
|