trackler 2.2.1.131 → 2.2.1.132
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/react/canonical-data.json +95 -74
- data/tracks/ceylon/exercises/react/source/react/ReactorTest.ceylon +19 -1
- data/tracks/perl5/.travis.yml +1 -0
- data/tracks/perl5/exercises/bob/.meta/exercise-data.yaml +3 -3
- data/tracks/perl5/exercises/bob/.meta/solutions/Bob.pm +3 -1
- data/tracks/perl5/exercises/bob/Bob.pm +3 -1
- data/tracks/perl5/exercises/bob/bob.t +6 -11
- data/tracks/perl5/exercises/clock/.meta/exercise-data.yaml +8 -8
- data/tracks/perl5/exercises/clock/.meta/solutions/Clock.pm +1 -1
- data/tracks/perl5/exercises/clock/Clock.pm +1 -1
- data/tracks/perl5/exercises/clock/clock.t +10 -15
- data/tracks/perl5/exercises/hello-world/.meta/exercise-data.yaml +3 -3
- data/tracks/perl5/exercises/hello-world/.meta/solutions/HelloWorld.pm +3 -1
- data/tracks/perl5/exercises/hello-world/HelloWorld.pm +3 -1
- data/tracks/perl5/exercises/hello-world/hello-world.t +6 -11
- data/tracks/perl5/exercises/leap/.meta/exercise-data.yaml +3 -3
- data/tracks/perl5/exercises/leap/.meta/solutions/Leap.pm +3 -1
- data/tracks/perl5/exercises/leap/Leap.pm +3 -1
- data/tracks/perl5/exercises/leap/leap.t +6 -11
- data/tracks/perl5/exercises/luhn/.meta/exercise-data.yaml +3 -3
- data/tracks/perl5/exercises/luhn/.meta/solutions/Luhn.pm +3 -1
- data/tracks/perl5/exercises/luhn/Luhn.pm +3 -1
- data/tracks/perl5/exercises/luhn/luhn.t +6 -11
- data/tracks/perl5/exercises/phone-number/.meta/exercise-data.yaml +3 -3
- data/tracks/perl5/exercises/phone-number/.meta/solutions/PhoneNumber.pm +3 -1
- data/tracks/perl5/exercises/phone-number/PhoneNumber.pm +3 -1
- data/tracks/perl5/exercises/phone-number/phone-number.t +6 -11
- data/tracks/perl5/templates/module.mustache +3 -1
- data/tracks/perl5/templates/test.mustache +7 -11
- data/tracks/typescript/config.json +17 -0
- data/tracks/typescript/exercises/custom-set/README.md +36 -0
- data/tracks/typescript/exercises/custom-set/custom-set.example.ts +79 -0
- data/tracks/typescript/exercises/custom-set/custom-set.test.ts +222 -0
- data/tracks/typescript/exercises/custom-set/custom-set.ts +0 -0
- data/tracks/typescript/exercises/custom-set/package.json +36 -0
- data/tracks/typescript/exercises/custom-set/tsconfig.json +22 -0
- data/tracks/typescript/exercises/custom-set/tslint.json +127 -0
- data/tracks/typescript/exercises/custom-set/yarn.lock +2624 -0
- metadata +10 -2
@@ -1,9 +1,9 @@
|
|
1
1
|
exercise: HelloWorld
|
2
|
-
version:
|
3
|
-
plan:
|
2
|
+
version: 2
|
3
|
+
plan: 2
|
4
4
|
subs: hello
|
5
5
|
tests: |-
|
6
|
-
is
|
6
|
+
is hello($_->{input}), $_->{expected}, $_->{description} foreach @{$C_DATA->{cases}};
|
7
7
|
|
8
8
|
exercise_comment: '# The name of this exercise.'
|
9
9
|
version_comment: '# The version we will be matching against the exercise.'
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# Declare package 'HelloWorld' with version
|
2
|
-
package HelloWorld
|
2
|
+
package HelloWorld 2;
|
3
3
|
use strict;
|
4
4
|
use warnings;
|
5
|
+
use Exporter 'import';
|
6
|
+
our @EXPORT_OK = qw(hello);
|
5
7
|
|
6
8
|
sub hello {
|
7
9
|
# Remove the comments and write some code here to pass the test suite.
|
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env perl
|
2
2
|
use strict;
|
3
3
|
use warnings;
|
4
|
+
use JSON::PP;
|
4
5
|
use FindBin;
|
5
6
|
use lib $FindBin::Bin; # Look for the module inside the same directory as this test file.
|
6
|
-
use
|
7
|
+
use HelloWorld qw(hello);
|
7
8
|
|
8
9
|
my $exercise = 'HelloWorld'; # The name of this exercise.
|
9
|
-
my $test_version =
|
10
|
-
use Test::More tests =>
|
11
|
-
|
12
|
-
use_ok $exercise or BAIL_OUT; # Check that the module can be use-d.
|
10
|
+
my $test_version = 2; # The version we will be matching against the exercise.
|
11
|
+
use Test::More tests => 2; # This is how many tests we expect to run.
|
13
12
|
|
14
13
|
# If the exercise is updated, we want to make sure other people testing
|
15
14
|
# your code don't think you've made a mistake if things have changed!
|
@@ -21,14 +20,10 @@ if ($exercise_version != $test_version) {
|
|
21
20
|
BAIL_OUT if $ENV{EXERCISM};
|
22
21
|
}
|
23
22
|
|
24
|
-
|
25
|
-
foreach ( qw(hello) ) {
|
26
|
-
can_ok $exercise, $_;
|
27
|
-
$subs{$_} = $exercise->can($_);
|
28
|
-
}
|
23
|
+
can_ok $exercise, 'import' or BAIL_OUT 'Cannot import subroutines from module';
|
29
24
|
|
30
25
|
my $C_DATA = do { local $/; decode_json(<DATA>); };
|
31
|
-
is
|
26
|
+
is hello($_->{input}), $_->{expected}, $_->{description} foreach @{$C_DATA->{cases}};
|
32
27
|
|
33
28
|
__DATA__
|
34
29
|
{
|
@@ -1,9 +1,9 @@
|
|
1
1
|
exercise: Leap
|
2
|
-
version:
|
3
|
-
plan:
|
2
|
+
version: 3
|
3
|
+
plan: 5
|
4
4
|
subs: is_leap
|
5
5
|
tests: |-
|
6
|
-
is
|
6
|
+
is is_leap($_->{input}{year}), $_->{expected}, $_->{description} foreach @{$C_DATA->{cases}};
|
7
7
|
|
8
8
|
exercise_comment: '# The name of this exercise.'
|
9
9
|
version_comment: '# The version we will be matching against the exercise.'
|
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env perl
|
2
2
|
use strict;
|
3
3
|
use warnings;
|
4
|
+
use JSON::PP;
|
4
5
|
use FindBin;
|
5
6
|
use lib $FindBin::Bin; # Look for the module inside the same directory as this test file.
|
6
|
-
use
|
7
|
+
use Leap qw(is_leap);
|
7
8
|
|
8
9
|
my $exercise = 'Leap'; # The name of this exercise.
|
9
|
-
my $test_version =
|
10
|
-
use Test::More tests =>
|
11
|
-
|
12
|
-
use_ok $exercise or BAIL_OUT; # Check that the module can be use-d.
|
10
|
+
my $test_version = 3; # The version we will be matching against the exercise.
|
11
|
+
use Test::More tests => 5; # This is how many tests we expect to run.
|
13
12
|
|
14
13
|
# If the exercise is updated, we want to make sure other people testing
|
15
14
|
# your code don't think you've made a mistake if things have changed!
|
@@ -21,14 +20,10 @@ if ($exercise_version != $test_version) {
|
|
21
20
|
BAIL_OUT if $ENV{EXERCISM};
|
22
21
|
}
|
23
22
|
|
24
|
-
|
25
|
-
foreach ( qw(is_leap) ) {
|
26
|
-
can_ok $exercise, $_;
|
27
|
-
$subs{$_} = $exercise->can($_);
|
28
|
-
}
|
23
|
+
can_ok $exercise, 'import' or BAIL_OUT 'Cannot import subroutines from module';
|
29
24
|
|
30
25
|
my $C_DATA = do { local $/; decode_json(<DATA>); };
|
31
|
-
is
|
26
|
+
is is_leap($_->{input}{year}), $_->{expected}, $_->{description} foreach @{$C_DATA->{cases}};
|
32
27
|
|
33
28
|
__DATA__
|
34
29
|
{
|
@@ -1,9 +1,9 @@
|
|
1
1
|
exercise: Luhn
|
2
|
-
version:
|
3
|
-
plan:
|
2
|
+
version: 3
|
3
|
+
plan: 14
|
4
4
|
subs: is_luhn_valid
|
5
5
|
tests: |-
|
6
|
-
is
|
6
|
+
is is_luhn_valid($_->{input}{value}), $_->{expected}, $_->{description} foreach @{$C_DATA->{cases}};
|
7
7
|
|
8
8
|
example: |-
|
9
9
|
sub is_luhn_valid {
|
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env perl
|
2
2
|
use strict;
|
3
3
|
use warnings;
|
4
|
+
use JSON::PP;
|
4
5
|
use FindBin;
|
5
6
|
use lib $FindBin::Bin;
|
6
|
-
use
|
7
|
+
use Luhn qw(is_luhn_valid);
|
7
8
|
|
8
9
|
my $exercise = 'Luhn';
|
9
|
-
my $test_version =
|
10
|
-
use Test::More tests =>
|
11
|
-
|
12
|
-
use_ok $exercise or BAIL_OUT;
|
10
|
+
my $test_version = 3;
|
11
|
+
use Test::More tests => 14;
|
13
12
|
|
14
13
|
my $exercise_version = $exercise->VERSION // 0;
|
15
14
|
if ($exercise_version != $test_version) {
|
@@ -19,14 +18,10 @@ if ($exercise_version != $test_version) {
|
|
19
18
|
BAIL_OUT if $ENV{EXERCISM};
|
20
19
|
}
|
21
20
|
|
22
|
-
|
23
|
-
foreach ( qw(is_luhn_valid) ) {
|
24
|
-
can_ok $exercise, $_;
|
25
|
-
$subs{$_} = $exercise->can($_);
|
26
|
-
}
|
21
|
+
can_ok $exercise, 'import' or BAIL_OUT 'Cannot import subroutines from module';
|
27
22
|
|
28
23
|
my $C_DATA = do { local $/; decode_json(<DATA>); };
|
29
|
-
is
|
24
|
+
is is_luhn_valid($_->{input}{value}), $_->{expected}, $_->{description} foreach @{$C_DATA->{cases}};
|
30
25
|
|
31
26
|
__DATA__
|
32
27
|
{
|
@@ -1,10 +1,10 @@
|
|
1
1
|
exercise: PhoneNumber
|
2
|
-
version:
|
3
|
-
plan:
|
2
|
+
version: 4
|
3
|
+
plan: 15
|
4
4
|
subs: clean_number
|
5
5
|
tests: |-
|
6
6
|
foreach my $subcases (@{$C_DATA->{cases}}) {
|
7
|
-
is
|
7
|
+
is clean_number($_->{input}{phrase}), $_->{expected}, $_->{description} foreach @{$subcases->{cases}};
|
8
8
|
}
|
9
9
|
|
10
10
|
example: |
|
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env perl
|
2
2
|
use strict;
|
3
3
|
use warnings;
|
4
|
+
use JSON::PP;
|
4
5
|
use FindBin;
|
5
6
|
use lib $FindBin::Bin;
|
6
|
-
use
|
7
|
+
use PhoneNumber qw(clean_number);
|
7
8
|
|
8
9
|
my $exercise = 'PhoneNumber';
|
9
|
-
my $test_version =
|
10
|
-
use Test::More tests =>
|
11
|
-
|
12
|
-
use_ok $exercise or BAIL_OUT;
|
10
|
+
my $test_version = 4;
|
11
|
+
use Test::More tests => 15;
|
13
12
|
|
14
13
|
my $exercise_version = $exercise->VERSION // 0;
|
15
14
|
if ($exercise_version != $test_version) {
|
@@ -19,15 +18,11 @@ if ($exercise_version != $test_version) {
|
|
19
18
|
BAIL_OUT if $ENV{EXERCISM};
|
20
19
|
}
|
21
20
|
|
22
|
-
|
23
|
-
foreach ( qw(clean_number) ) {
|
24
|
-
can_ok $exercise, $_;
|
25
|
-
$subs{$_} = $exercise->can($_);
|
26
|
-
}
|
21
|
+
can_ok $exercise, 'import' or BAIL_OUT 'Cannot import subroutines from module';
|
27
22
|
|
28
23
|
my $C_DATA = do { local $/; decode_json(<DATA>); };
|
29
24
|
foreach my $subcases (@{$C_DATA->{cases}}) {
|
30
|
-
is
|
25
|
+
is clean_number($_->{input}{phrase}), $_->{expected}, $_->{description} foreach @{$subcases->{cases}};
|
31
26
|
}
|
32
27
|
|
33
28
|
__DATA__
|
@@ -1,7 +1,9 @@
|
|
1
1
|
{{#package_comment}}{{&package_comment}}
|
2
2
|
{{/package_comment}}package {{&exercise}} {{&version}};
|
3
3
|
use strict;
|
4
|
-
use warnings;{{#
|
4
|
+
use warnings;{{#subs}}
|
5
|
+
use Exporter 'import';
|
6
|
+
our @EXPORT_OK = qw({{&subs}});{{/subs}}{{#module_file}}
|
5
7
|
|
6
8
|
{{&module_file}}{{/module_file}}
|
7
9
|
|
@@ -1,16 +1,15 @@
|
|
1
1
|
#!/usr/bin/env perl
|
2
2
|
use strict;
|
3
|
-
use warnings;
|
3
|
+
use warnings;{{#cdata}}
|
4
|
+
use JSON::PP;{{/cdata}}
|
4
5
|
use FindBin;
|
5
|
-
use lib $FindBin::Bin;{{#lib_comment}} {{&lib_comment}}{{/lib_comment}}
|
6
|
-
use
|
6
|
+
use lib $FindBin::Bin;{{#lib_comment}} {{&lib_comment}}{{/lib_comment}}
|
7
|
+
use {{&exercise}} {{#subs}}qw{{/subs}}({{&subs}});{{#modules}}
|
7
8
|
use {{&use}};{{/modules}}
|
8
9
|
|
9
10
|
my $exercise{{#exercise}} = '{{&exercise}}'{{/exercise}};{{#exercise_comment}} {{&exercise_comment}}{{/exercise_comment}}
|
10
11
|
my $test_version{{#version}} = {{&version}}{{/version}};{{#version_comment}} {{&version_comment}}{{/version_comment}}
|
11
12
|
use Test::More{{#plan}} tests => {{&plan}}{{/plan}};{{#plan_comment}} {{&plan_comment}}{{/plan_comment}}
|
12
|
-
|
13
|
-
use_ok $exercise or BAIL_OUT;{{#use_test_comment}} {{&use_test_comment}}{{/use_test_comment}}
|
14
13
|
{{#version_test_comment}}
|
15
14
|
{{&version_test_comment}}{{/version_test_comment}}
|
16
15
|
my $exercise_version = $exercise->VERSION // 0;
|
@@ -22,12 +21,9 @@ if ($exercise_version != $test_version) {
|
|
22
21
|
}
|
23
22
|
{{#subs}}
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
$subs{$_} = $exercise->can($_);
|
29
|
-
}
|
30
|
-
{{/subs}}{{#cdata}}
|
24
|
+
can_ok $exercise, 'import' or BAIL_OUT 'Cannot import subroutines from module';{{/subs}}{{#methods}}
|
25
|
+
can_ok $exercise, qw({{&methods}});{{/methods}}{{#cdata}}
|
26
|
+
|
31
27
|
my $C_DATA = do { local $/; decode_json(<DATA>); };{{/cdata}}
|
32
28
|
{{&tests}}
|
33
29
|
{{#cdata}}
|
@@ -587,6 +587,23 @@
|
|
587
587
|
],
|
588
588
|
"uuid": "32e79fd7-f002-4bdc-b6bd-7a91d8c1af61"
|
589
589
|
},
|
590
|
+
{
|
591
|
+
"core": false,
|
592
|
+
"difficulty": 6,
|
593
|
+
"slug": "custom-set",
|
594
|
+
"topics": [
|
595
|
+
"control_flow_conditionals",
|
596
|
+
"control_flow_loops",
|
597
|
+
"data_structures",
|
598
|
+
"arrays",
|
599
|
+
"lists",
|
600
|
+
"sets",
|
601
|
+
"equality",
|
602
|
+
"recursion"
|
603
|
+
],
|
604
|
+
"unlocked_by": "linked-list",
|
605
|
+
"uuid": "e2cfc3b4-5c71-4344-a692-5d55609f097b"
|
606
|
+
},
|
590
607
|
{
|
591
608
|
"core": true,
|
592
609
|
"difficulty": 7,
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Custom Set
|
2
|
+
|
3
|
+
Create a custom set type.
|
4
|
+
|
5
|
+
Sometimes it is necessary to define a custom data structure of some
|
6
|
+
type, like a set. In this exercise you will define your own set. How it
|
7
|
+
works internally doesn't matter, as long as it behaves like a set of
|
8
|
+
unique elements.
|
9
|
+
|
10
|
+
## Setup
|
11
|
+
|
12
|
+
Go through the setup instructions for TypeScript to
|
13
|
+
install the necessary dependencies:
|
14
|
+
|
15
|
+
http://exercism.io/languages/typescript
|
16
|
+
|
17
|
+
## Requirements
|
18
|
+
|
19
|
+
Install assignment dependencies:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ yarn install
|
23
|
+
```
|
24
|
+
|
25
|
+
## Making the test suite pass
|
26
|
+
|
27
|
+
Execute the tests with:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
$ yarn test
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
## Submitting Incomplete Solutions
|
36
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,79 @@
|
|
1
|
+
export default class CustomSet<T> {
|
2
|
+
data: Set<T>
|
3
|
+
|
4
|
+
constructor(data: T[] = []) {
|
5
|
+
this.data = new Set<T>()
|
6
|
+
data.forEach((el) => this.add(el))
|
7
|
+
}
|
8
|
+
|
9
|
+
add(el: T) {
|
10
|
+
this.data.add(el)
|
11
|
+
return this
|
12
|
+
}
|
13
|
+
|
14
|
+
delete(el: T) {
|
15
|
+
this.data.delete(el)
|
16
|
+
return this
|
17
|
+
}
|
18
|
+
|
19
|
+
size() {
|
20
|
+
return this.data.size
|
21
|
+
}
|
22
|
+
|
23
|
+
empty() {
|
24
|
+
return this.data.size === 0
|
25
|
+
}
|
26
|
+
|
27
|
+
contains(el: T) {
|
28
|
+
return this.data.has(el)
|
29
|
+
}
|
30
|
+
|
31
|
+
eql(other: CustomSet<T>) {
|
32
|
+
if (this.data.size !== other.data.size) {
|
33
|
+
return false
|
34
|
+
}
|
35
|
+
for (const item of this.data) {
|
36
|
+
if (!other.data.has(item)) {
|
37
|
+
return false
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return true
|
41
|
+
}
|
42
|
+
|
43
|
+
difference(other: CustomSet<T>) {
|
44
|
+
const result = new CustomSet<T>()
|
45
|
+
for (const item of this.data) {
|
46
|
+
if (!other.data.has(item)) {
|
47
|
+
result.add(item)
|
48
|
+
}
|
49
|
+
}
|
50
|
+
return result
|
51
|
+
}
|
52
|
+
|
53
|
+
disjoint(other: CustomSet<T>) {
|
54
|
+
return this.size() === 0 || this.difference(other).size() === this.size()
|
55
|
+
}
|
56
|
+
|
57
|
+
intersection(other: CustomSet<T>) {
|
58
|
+
return this.difference(this.difference(other))
|
59
|
+
}
|
60
|
+
|
61
|
+
union(other: CustomSet<T>) {
|
62
|
+
const result = new CustomSet<T>()
|
63
|
+
for (const item of this.data) {
|
64
|
+
result.add(item)
|
65
|
+
}
|
66
|
+
for (const item of other.data) {
|
67
|
+
result.add(item)
|
68
|
+
}
|
69
|
+
return result
|
70
|
+
}
|
71
|
+
|
72
|
+
subset(other: CustomSet<T>) {
|
73
|
+
return this.eql(this.intersection(other))
|
74
|
+
}
|
75
|
+
|
76
|
+
toList() {
|
77
|
+
return Object.values(this.data)
|
78
|
+
}
|
79
|
+
}
|