trackler 2.1.0.33 → 2.1.0.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/bash/config.json +39 -20
  4. data/tracks/bash/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  5. data/tracks/bash/exercises/difference-of-squares/difference_of_squares_test.sh +71 -0
  6. data/tracks/bash/exercises/difference-of-squares/example.sh +25 -0
  7. data/tracks/clojurescript/config.json +0 -5
  8. data/tracks/clojurescript/{exercises/TRACK_HINTS.md → docs/EXERCISE_README_INSERT.md} +0 -0
  9. data/tracks/coffeescript/config.json +63 -26
  10. data/tracks/coffeescript/{SETUP.md → docs/EXERCISE_README_INSERT.md} +4 -2
  11. data/tracks/coffeescript/exercises/luhn/luhn_test.spec.coffee +2 -2
  12. data/tracks/coffeescript/exercises/palindrome-products/palindrome_products_test.spec.coffee +1 -1
  13. data/tracks/crystal/config.json +27 -10
  14. data/tracks/dlang/config.json +2 -3
  15. data/tracks/dlang/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  16. data/tracks/haxe/config.json +7 -2
  17. data/tracks/haxe/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  18. data/tracks/java/{exercises/_template → _template}/build.gradle +0 -0
  19. data/tracks/java/{exercises/_template → _template}/src/example/java/.keep +0 -0
  20. data/tracks/java/{exercises/_template → _template}/src/main/java/.keep +0 -0
  21. data/tracks/java/{exercises/_template → _template}/src/test/java/.keep +0 -0
  22. data/tracks/java/config.json +201 -77
  23. data/tracks/julia/config.json +1 -7
  24. data/tracks/kotlin/{exercises/_template → _template}/build.gradle +0 -0
  25. data/tracks/kotlin/{exercises/_template → _template}/src/example/kotlin/.keep +0 -0
  26. data/tracks/kotlin/{exercises/_template → _template}/src/main/kotlin/.keep +0 -0
  27. data/tracks/kotlin/{exercises/_template → _template}/src/test/kotlin/.keep +0 -0
  28. data/tracks/mips/config.json +42 -14
  29. data/tracks/mips/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  30. data/tracks/nasm/config.json +1 -0
  31. data/tracks/nasm/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  32. data/tracks/nasm/exercises/.keep +0 -2
  33. data/tracks/nim/config.json +6 -0
  34. data/tracks/nim/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  35. data/tracks/nim/exercises/raindrops/example.nim +18 -0
  36. data/tracks/nim/exercises/raindrops/raindrops_test.nim +51 -0
  37. data/tracks/ocaml/config.json +97 -30
  38. data/tracks/perl5/config.json +186 -66
  39. data/tracks/perl5/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  40. data/tracks/perl6/bin/README.md +16 -6
  41. data/tracks/perl6/bin/exercise-gen.pl6 +21 -6
  42. data/tracks/perl6/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  43. data/tracks/perl6/exercises/accumulate/example.yaml +10 -0
  44. data/tracks/perl6/exercises/all-your-base/all-your-base.t +1 -0
  45. data/tracks/perl6/exercises/all-your-base/example.yaml +49 -0
  46. data/tracks/perl6/exercises/allergies/Allergies.pm6 +1 -1
  47. data/tracks/perl6/exercises/allergies/example.yaml +21 -0
  48. data/tracks/perl6/exercises/anagram/example.yaml +19 -0
  49. data/tracks/perl6/exercises/atbash-cipher/AtbashCipher.pm6 +1 -1
  50. data/tracks/perl6/exercises/atbash-cipher/example.yaml +15 -0
  51. data/tracks/perl6/exercises/bob/Example.pm6 +4 -0
  52. data/tracks/perl6/exercises/bob/example.yaml +24 -0
  53. data/tracks/perl6/exercises/clock/clock.t +1 -0
  54. data/tracks/perl6/exercises/clock/example.yaml +17 -0
  55. data/tracks/perl6/exercises/flatten-array/example.yaml +17 -0
  56. data/tracks/perl6/exercises/grade-school/example.yaml +22 -0
  57. data/tracks/perl6/exercises/grains/example.yaml +13 -0
  58. data/tracks/perl6/exercises/hello-world/Example.pm6 +9 -0
  59. data/tracks/perl6/exercises/hello-world/example.yaml +21 -0
  60. data/tracks/perl6/exercises/leap/Example.pm6 +1 -1
  61. data/tracks/perl6/exercises/leap/Leap.pm6 +1 -1
  62. data/tracks/perl6/exercises/leap/example.yaml +15 -0
  63. data/tracks/perl6/exercises/linked-list/LinkedList.pm6 +1 -1
  64. data/tracks/perl6/exercises/linked-list/example.yaml +51 -0
  65. data/tracks/perl6/exercises/linked-list/linked-list.t +0 -1
  66. data/tracks/perl6/exercises/luhn/example.yaml +19 -0
  67. data/tracks/perl6/exercises/phone-number/{PhoneNumber.pm6 → Phone.pm6} +0 -0
  68. data/tracks/perl6/exercises/phone-number/example.yaml +10 -0
  69. data/tracks/perl6/exercises/raindrops/example.yaml +15 -0
  70. data/tracks/perl6/exercises/rna-transcription/example.yaml +10 -0
  71. data/tracks/perl6/exercises/robot-name/example.yaml +24 -0
  72. data/tracks/perl6/exercises/robot-name/robot-name.t +4 -0
  73. data/tracks/perl6/exercises/scrabble-score/example.yaml +21 -0
  74. data/tracks/perl6/exercises/space-age/example.yaml +52 -0
  75. data/tracks/perl6/exercises/word-count/example.yaml +9 -0
  76. data/tracks/perl6/exercises/wordy/example.yaml +20 -0
  77. data/tracks/perl6/templates/module.mustache +4 -0
  78. data/tracks/perl6/templates/test.mustache +2 -1
  79. data/tracks/plsql/config.json +30 -10
  80. data/tracks/plsql/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  81. data/tracks/pony/config.json +0 -6
  82. data/tracks/pony/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  83. data/tracks/powershell/config.json +6 -2
  84. data/tracks/powershell/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  85. data/tracks/python/config.json +101 -39
  86. data/tracks/r/config.json +0 -4
  87. data/tracks/ruby/config.json +84 -6
  88. data/tracks/ruby/{exercises/TRACK_HINTS.md → docs/EXERCISE_README_INSERT.md} +0 -0
  89. data/tracks/tcl/config.json +1 -0
  90. data/tracks/tcl/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  91. data/tracks/tcl/exercises/.keep +0 -2
  92. data/tracks/teco/config.json +0 -4
  93. data/tracks/teco/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  94. data/tracks/vbnet/config.json +1 -0
  95. data/tracks/vbnet/{SETUP.md → docs/EXERCISE_README_INSERT.md} +0 -0
  96. data/tracks/vimscript/config.json +64 -19
  97. data/tracks/vimscript/{TRACK_HINTS.md → docs/EXERCISE_README_INSERT.md} +0 -0
  98. data/tracks/vimscript/exercises/beer-song/beer_song.vader +50 -0
  99. data/tracks/vimscript/exercises/beer-song/beer_song.vim +24 -0
  100. data/tracks/vimscript/exercises/beer-song/example.vim +21 -0
  101. metadata +37 -29
@@ -4,3 +4,18 @@ plan: 6
4
4
  imports: '&is-leap-year'
5
5
  tests: |
6
6
  is &::('is-leap-year')(.<input>), |.<expected description> for @($c-data<cases>);
7
+
8
+ unit: module
9
+ example: |
10
+ sub is-leap-year ($year) is export {
11
+ is-divisible($year, 400)
12
+ || is-divisible($year, 4)
13
+ && !is-divisible($year, 100);
14
+ }
15
+
16
+ sub is-divisible($year, $number) {
17
+ $year % $number == 0 ?? True !! False;
18
+ }
19
+ stub: |
20
+ sub is-leap-year ($year) is export {
21
+ }
@@ -1 +1 @@
1
- unit class LinkedList:ver<1>;
1
+ unit class LinkedList:ver<1>;
@@ -79,3 +79,54 @@ after_done_testing: |
79
79
  ]
80
80
 
81
81
  }
82
+
83
+ unit: class
84
+ example: |
85
+ class ListNode {
86
+ has $.next is rw;
87
+ has $.previous is rw;
88
+ has $.value;
89
+ }
90
+
91
+ has $!first;
92
+ has $!last;
93
+
94
+ method push-list($value) {
95
+ my $next = ListNode.new( value => $value, previous => $!last );
96
+ if ( $!last ) {
97
+ $!last = $!last.next= $next ;
98
+ }
99
+ else {
100
+ $!first = $!last = $next;
101
+ }
102
+ }
103
+
104
+ method unshift-list($value) {
105
+ my $next = ListNode.new( value => $value, next => $!first );
106
+ if ( $!first ) {
107
+ $!first = $!first.previous = $next ;
108
+ }
109
+ else {
110
+ $!first = $!last = $next;
111
+ }
112
+ }
113
+
114
+ method shift-list() {
115
+ my $f = $!first;
116
+
117
+ $!first = $!first.next;
118
+
119
+ unless $!first { $!last = $!first }
120
+
121
+ return $f.value;
122
+ }
123
+
124
+ method pop-list() {
125
+ my $f = $!last;
126
+
127
+ $!last = $!last.previous;
128
+
129
+ unless $!.last { $!first = $!last }
130
+
131
+ return $f.value;
132
+ }
@@ -99,4 +99,3 @@ INIT {
99
99
  ]
100
100
 
101
101
  }
102
-
@@ -4,3 +4,22 @@ plan: 15
4
4
  imports: '&is-luhn-valid'
5
5
  tests: |
6
6
  is .<input>.&is-luhn-valid, |.<expected description> for @($c-data<cases>);
7
+
8
+ unit: module
9
+ example: |
10
+ sub is-luhn-valid ($input is copy) is export {
11
+ $input ~~ s:g/\s+//;
12
+ return False if $input.chars < 2 || $input ~~ /\D/;
13
+ my @num = $input.split('', :skip-empty);
14
+ @num.unshift: 0 if @num % 2;
15
+ my $sum;
16
+ for @num -> $a, $b {
17
+ $sum += $a * 2;
18
+ $sum -= 9 if $a * 2 > 9;
19
+ $sum += $b;
20
+ }
21
+ return ($sum %% 10).so;
22
+ }
23
+ stub: |
24
+ sub is-luhn-valid ($input) is export {
25
+ }
@@ -10,3 +10,13 @@ tests: |
10
10
  nok clean-number(.<phrase>), .<description>;
11
11
  }
12
12
  }
13
+
14
+ unit: module
15
+ example: |
16
+ sub clean-number ($number is copy) is export {
17
+ $number ~~ s:g/<:!Nd>//;
18
+ $number ~~ /^ 1? ( [ <[2..9]> <:Nd> ** 2 ] ** 2 <:Nd> ** 4 ) $/ ?? ~$0 !! Nil;
19
+ }
20
+ stub: |
21
+ sub clean-number ($number) is export {
22
+ }
@@ -10,3 +10,18 @@ tests: |
10
10
  isa-ok .<number>.&convert, Str;
11
11
  }
12
12
  }
13
+
14
+ unit: module
15
+ example: |
16
+ sub convert (Int:D $num --> Str:D) is export {
17
+ my $str = '';
18
+ given $num {
19
+ when * %% 3 {$str ~= 'Pling'; proceed}
20
+ when * %% 5 {$str ~= 'Plang'; proceed}
21
+ when * %% 7 {$str ~= 'Plong'}
22
+ }
23
+ return $str ?? $str !! $num.Str;
24
+ }
25
+ stub: |
26
+ sub convert ($num) is export {
27
+ }
@@ -10,3 +10,13 @@ tests: |
10
10
  throws-like {.<dna>.&to-rna}, Exception;
11
11
  }
12
12
  }
13
+
14
+ unit: module
15
+ example: |
16
+ sub to-rna ($dna) is export {
17
+ fail if $dna ~~ /<-[AGCT]>/;
18
+ $dna.trans(<A G C T> => <U C G A>);
19
+ }
20
+ stub: |
21
+ sub to-rna ($dna) is export {
22
+ }
@@ -7,14 +7,18 @@ tests: |
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
  srand 2;
11
12
  is $robot.?name, $name, 'Name is persistent';
12
13
  srand 1;
13
14
  isnt ::($exercise).new.?name, $name, 'New Robot cannot claim previous Robot name';
15
+
14
16
  srand 1;
15
17
  $robot.?reset-name;
16
18
  $robot.?reset_name; # Allows next test to still pass for older solutions
19
+
17
20
  isnt $robot.?name, $name, "'reset-name' cannot use previous Robot name";
21
+
18
22
  diag "\nCreating 100 robots...";
19
23
  push my @names, ::($exercise).new.name for 1..100;
20
24
  is @names, @names.unique, 'All names are unique';
@@ -23,3 +27,23 @@ tests: |
23
27
  isnt @names, @names.sort, 'Names not ordered';
24
28
  isnt @names, @names.sort.reverse, 'Names not reverse ordered';
25
29
  }
30
+
31
+ unit: class
32
+ example: |
33
+ subset Name of Str where * ~~ /^<[A..Z]>**2 <[0..9]>**3$/;
34
+ has Name $.name = self.reset-name;
35
+
36
+ method reset-name {
37
+ state Promise:D $promise = start ('AA000'..'ZZ999').pick: *;
38
+ state Bool:D %record{Name:D};
39
+ state Int:D $i = 0;
40
+
41
+ if $promise.status ~~ 'Kept' {
42
+ ($!name = $promise.result[$i++]) or die 'All names used.';
43
+ } else {
44
+ $!name = ('A'..'Z').roll(2).join ~ (^10).roll(3).join;
45
+ }
46
+ self.reset-name if %record{$!name}:exists;
47
+ %record{$!name} = True;
48
+ return $!name;
49
+ }
@@ -26,14 +26,18 @@ srand 1;
26
26
  my $robot = ::($exercise).?new;
27
27
  my Str $name = $robot.?name;
28
28
  like $name, /^^<[A..Z]>**2 <[0..9]>**3$$/, 'Name matches schema';
29
+
29
30
  srand 2;
30
31
  is $robot.?name, $name, 'Name is persistent';
31
32
  srand 1;
32
33
  isnt ::($exercise).new.?name, $name, 'New Robot cannot claim previous Robot name';
34
+
33
35
  srand 1;
34
36
  $robot.?reset-name;
35
37
  $robot.?reset_name; # Allows next test to still pass for older solutions
38
+
36
39
  isnt $robot.?name, $name, "'reset-name' cannot use previous Robot name";
40
+
37
41
  diag "\nCreating 100 robots...";
38
42
  push my @names, ::($exercise).new.name for 1..100;
39
43
  is @names, @names.unique, 'All names are unique';
@@ -4,3 +4,24 @@ plan: 13
4
4
  imports: '&score'
5
5
  tests: |
6
6
  is .<input>.&score, |.<expected description> for @($c-data<cases>);
7
+
8
+ unit: module
9
+ example: |
10
+ sub score (Str:D $word --> Int:D) is export {
11
+ my $score = 0;
12
+ for $word.lc.split('',:skip-empty) -> $letter {
13
+ given $letter {
14
+ when * ~~ /<[aeioulnrst]>/ { $score += 1 }
15
+ when * ~~ /<[dg]>/ { $score += 2 }
16
+ when * ~~ /<[bcmp]>/ { $score += 3 }
17
+ when * ~~ /<[fhvwy]>/ { $score += 4 }
18
+ when * ~~ /k/ { $score += 5 }
19
+ when * ~~ /<[jx]>/ { $score += 8 }
20
+ when * ~~ /<[qz]>/ { $score += 10 }
21
+ }
22
+ }
23
+ return $score;
24
+ }
25
+ stub: |
26
+ sub score ($word) is export {
27
+ }
@@ -4,3 +4,55 @@ plan: 10
4
4
  imports: Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune
5
5
  tests: |
6
6
  is (age-on ::(.<planet>): .<seconds>), |.<expected description> for @($c-data<cases>);
7
+
8
+ unit: module
9
+ example: |
10
+ role Planet {
11
+ method age-on ($seconds) {
12
+ ($seconds / self.orbital-period).round(0.01);
13
+ }
14
+ }
15
+
16
+ class Earth does Planet is export {
17
+ my $.orbital-period = 31557600;
18
+ }
19
+
20
+ my %planets = (
21
+ :Mercury(0.2408467),
22
+ :Venus(0.61519726),
23
+ :Mars(1.8808158),
24
+ :Jupiter(11.862615),
25
+ :Saturn(29.447498),
26
+ :Uranus(84.016846),
27
+ :Neptune(164.79132),
28
+ );
29
+ for %planets.kv -> $planet, $relative {
30
+ use MONKEY-SEE-NO-EVAL;
31
+ OUR::EXPORT::ALL::{$planet} := OUR::EXPORT::DEFAULT::{$planet} := EVAL "class $planet does Planet is export " ~
32
+ '{ my $.orbital-period = calculate-orbital-period $relative }';
33
+ }
34
+
35
+ sub calculate-orbital-period ($relative-to-earth) {
36
+ Earth.orbital-period * $relative-to-earth;
37
+ }
38
+ stub: |
39
+ role Planet {
40
+ method age-on ($seconds) {
41
+ }
42
+ }
43
+
44
+ class Earth does Planet is export {
45
+ my $.orbital-period = 31557600;
46
+ }
47
+
48
+ =for comment
49
+ ---
50
+ Orbital periods relative to Earth:
51
+ Mercury: 0.2408467
52
+ Venus: 0.61519726
53
+ Mars: 1.8808158
54
+ Jupiter: 11.862615
55
+ Saturn: 29.447498
56
+ Uranus: 84.016846
57
+ Neptune: 164.79132
58
+ ...
@@ -4,3 +4,12 @@ plan: 12
4
4
  imports: '&count-words'
5
5
  tests: |
6
6
  is-deeply (% = .<input>.&count-words), |.<expected description> for @($c-data<cases>);
7
+
8
+ unit: module
9
+ example: |
10
+ sub count-words (Str:D $str --> Hash:D) is export {
11
+ $str.lc.comb(/ <alnum>+ (\'<alnum>+)? /).Bag.hash
12
+ }
13
+ stub: |
14
+ sub count-words ($str) is export {
15
+ }
@@ -10,3 +10,23 @@ tests: |
10
10
  is .<input>.&answer, |.<expected description>;
11
11
  }
12
12
  }
13
+
14
+ unit: module
15
+ example: |
16
+ sub answer ($q is copy) is export {
17
+ given $q {
18
+ s:s:g/^What is|\?$//;
19
+ s:g/plus/+/;
20
+ s:g/minus/−/;
21
+ loop {
22
+ last unless
23
+ s:s/(.*) multiplied by/($0)×/
24
+ or s:s/(.*) divided by/($0)÷/;
25
+ }
26
+ }
27
+ use MONKEY-SEE-NO-EVAL;
28
+ EVAL $q or fail;
29
+ }
30
+ stub: |
31
+ sub answer ($question) is export {
32
+ }
@@ -0,0 +1,4 @@
1
+ {{#unit_comment}}{{&unit_comment}}
2
+ {{/unit_comment}}unit {{&unit}} {{&exercise}}:ver<{{&version}}>;{{#module_file}}
3
+
4
+ {{&module_file}}{{/module_file}}
@@ -34,7 +34,8 @@ subtest 'Class methods', {
34
34
  }
35
35
  #`{{/methods}}#`{{#cdata}}
36
36
  my $c-data;#`{{/cdata}}
37
- #`{{&tests}}#`{{#cdata}}#`{{#cdata_test_comment}}
37
+ #`{{&tests}}
38
+ #`{{#cdata}}#`{{#cdata_test_comment}}
38
39
  #`[#`{{&cdata_test_comment}}]#`{{/cdata_test_comment}}
39
40
  if %*ENV<EXERCISM> && (my $c-data-file =
40
41
  "$dir/../../x-common/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f
@@ -18,52 +18,72 @@
18
18
  {
19
19
  "difficulty": 1,
20
20
  "slug": "hamming",
21
- "topics": []
21
+ "topics": [
22
+
23
+ ]
22
24
  },
23
25
  {
24
26
  "difficulty": 1,
25
27
  "slug": "gigasecond",
26
- "topics": []
28
+ "topics": [
29
+
30
+ ]
27
31
  },
28
32
  {
29
33
  "difficulty": 1,
30
34
  "slug": "rna-transcription",
31
- "topics": []
35
+ "topics": [
36
+
37
+ ]
32
38
  },
33
39
  {
34
40
  "difficulty": 1,
35
41
  "slug": "raindrops",
36
- "topics": []
42
+ "topics": [
43
+
44
+ ]
37
45
  },
38
46
  {
39
47
  "difficulty": 1,
40
48
  "slug": "difference-of-squares",
41
- "topics": []
49
+ "topics": [
50
+
51
+ ]
42
52
  },
43
53
  {
44
54
  "difficulty": 1,
45
55
  "slug": "roman-numerals",
46
- "topics": []
56
+ "topics": [
57
+
58
+ ]
47
59
  },
48
60
  {
49
61
  "difficulty": 1,
50
62
  "slug": "nth-prime",
51
- "topics": []
63
+ "topics": [
64
+
65
+ ]
52
66
  },
53
67
  {
54
68
  "difficulty": 1,
55
69
  "slug": "leap",
56
- "topics": []
70
+ "topics": [
71
+
72
+ ]
57
73
  },
58
74
  {
59
75
  "difficulty": 1,
60
76
  "slug": "grains",
61
- "topics": []
77
+ "topics": [
78
+
79
+ ]
62
80
  },
63
81
  {
64
82
  "difficulty": 1,
65
83
  "slug": "binary",
66
- "topics": []
84
+ "topics": [
85
+
86
+ ]
67
87
  }
68
88
  ]
69
89
  }