trackler 2.0.3.5 → 2.0.3.6

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/leap/canonical-data.json +8 -23
  3. data/lib/trackler/version.rb +1 -1
  4. data/tracks/c/exercises/meetup/makefile +1 -1
  5. data/tracks/crystal/config.json +0 -18
  6. data/tracks/dlang/config.json +13 -94
  7. data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTreeTest.fs +2 -2
  8. data/tracks/haskell/README.md +118 -24
  9. data/tracks/perl5/config.json +5 -0
  10. data/tracks/perl5/exercises/all-your-base/Example.pm +32 -0
  11. data/tracks/perl5/exercises/all-your-base/all-your-base.t +184 -0
  12. data/tracks/perl6/config.json +5 -0
  13. data/tracks/perl6/exercises/trinary/Example.p6 +6 -0
  14. data/tracks/perl6/exercises/trinary/trinary.t +60 -0
  15. data/tracks/rust/exercises/allergies/.gitignore +7 -0
  16. data/tracks/rust/exercises/anagram/.gitignore +7 -0
  17. data/tracks/rust/exercises/beer-song/.gitignore +7 -0
  18. data/tracks/rust/exercises/bob/.gitignore +7 -0
  19. data/tracks/rust/exercises/bracket-push/.gitignore +7 -0
  20. data/tracks/rust/exercises/circular-buffer/.gitignore +7 -0
  21. data/tracks/rust/exercises/custom-set/.gitignore +7 -0
  22. data/tracks/rust/exercises/difference-of-squares/.gitignore +7 -0
  23. data/tracks/rust/exercises/dominoes/.gitignore +7 -0
  24. data/tracks/rust/exercises/etl/.gitignore +7 -0
  25. data/tracks/rust/exercises/forth/.gitignore +7 -0
  26. data/tracks/rust/exercises/gigasecond/.gitignore +7 -0
  27. data/tracks/rust/exercises/grade-school/.gitignore +7 -0
  28. data/tracks/rust/exercises/hamming/.gitignore +7 -0
  29. data/tracks/rust/exercises/hello-world/.gitignore +7 -0
  30. data/tracks/rust/exercises/hexadecimal/.gitignore +7 -0
  31. data/tracks/rust/exercises/leap/.gitignore +7 -0
  32. data/tracks/rust/exercises/minesweeper/.gitignore +7 -0
  33. data/tracks/rust/exercises/nucleotide-codons/.gitignore +7 -0
  34. data/tracks/rust/exercises/nucleotide-count/.gitignore +7 -0
  35. data/tracks/rust/exercises/ocr-numbers/.gitignore +7 -0
  36. data/tracks/rust/exercises/pangram/.gitignore +7 -0
  37. data/tracks/rust/exercises/parallel-letter-frequency/.gitignore +7 -0
  38. data/tracks/rust/exercises/phone-number/.gitignore +7 -0
  39. data/tracks/rust/exercises/queen-attack/.gitignore +7 -0
  40. data/tracks/rust/exercises/raindrops/.gitignore +7 -0
  41. data/tracks/rust/exercises/rectangles/.gitignore +7 -0
  42. data/tracks/rust/exercises/rna-transcription/.gitignore +7 -0
  43. data/tracks/rust/exercises/robot-name/.gitignore +7 -0
  44. data/tracks/rust/exercises/robot-simulator/.gitignore +7 -0
  45. data/tracks/rust/exercises/roman-numerals/.gitignore +7 -0
  46. data/tracks/rust/exercises/scrabble-score/.gitignore +7 -0
  47. data/tracks/rust/exercises/sieve/.gitignore +7 -0
  48. data/tracks/rust/exercises/space-age/.gitignore +7 -0
  49. data/tracks/rust/exercises/sublist/.gitignore +7 -0
  50. data/tracks/rust/exercises/tournament/.gitignore +7 -0
  51. data/tracks/rust/exercises/variable-length-quantity/.gitignore +7 -0
  52. data/tracks/rust/exercises/word-count/.gitignore +7 -0
  53. data/tracks/rust/exercises/wordy/.gitignore +7 -0
  54. metadata +45 -2
@@ -320,6 +320,11 @@
320
320
  "difficulty": 1,
321
321
  "slug": "sublist",
322
322
  "topics": []
323
+ },
324
+ {
325
+ "difficulty": 1,
326
+ "slug": "all-your-base",
327
+ "topics": []
323
328
  }
324
329
  ]
325
330
  }
@@ -0,0 +1,32 @@
1
+ package Example;
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ use Carp;
7
+
8
+ sub convert_base {
9
+ my( $digits, $in_base, $out_base ) = @_;
10
+
11
+ croak "base must be greater than 1" if grep { $_ <= 1 } $in_base, $out_base;
12
+
13
+ croak 'negative digit not allowed' if grep { $_ < 0 } @$digits;
14
+
15
+ croak 'digit equal of greater than the base' if grep { $_ >= $in_base } @$digits;
16
+
17
+ my $number = 0;
18
+ $number = $number * $in_base + $_ for @$digits;
19
+
20
+ my @output;
21
+
22
+ while( $number ) {
23
+ unshift @output, $number % $out_base;
24
+ $number = int $number / $out_base;
25
+ }
26
+
27
+ push @output, 0 unless @output;
28
+
29
+ return \@output;
30
+ }
31
+
32
+ 1;
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env perl
2
+ use strict;
3
+ use warnings;
4
+
5
+ use Test::More;
6
+ use FindBin;
7
+ my $dir;
8
+ BEGIN { $dir = $FindBin::Bin . '/' };
9
+ use lib $dir;
10
+
11
+ my $module = $ENV{EXERCISM} ? 'Example' : 'AllYourBase';
12
+
13
+ my $function = 'convert_base';
14
+
15
+ plan tests => 24;
16
+
17
+ ok -e "${dir}${module}.pm", "$module.pm present"
18
+ or BAIL_OUT "You need to create file: $module.pm";
19
+
20
+ eval "use $module";
21
+ ok !$@, "can load $module"
22
+ or BAIL_OUT "Cannot load $module. Does it compile? Does it end with 1;?";
23
+ can_ok $module, $function
24
+ or BAIL_OUT "Missing package $module; or missing sub $function()?";
25
+
26
+ my $sub = \&{ join '::', $module, $function };
27
+
28
+ sub testcase {
29
+ my %test = @_;
30
+
31
+ my $r = eval {
32
+ # cloning the input_digits to make sure the sub doesn't modify the
33
+ # original array
34
+ $sub->( [ @{$test{input_digits}} ], $test{input_base}, $test{output_base} )
35
+ };
36
+
37
+ my $success = $test{error}
38
+ ? like( $@ => $test{error}, $test{description} )
39
+ : is_deeply( $r, $test{output_digits}, $test{description} )
40
+ ;
41
+
42
+ return if $success;
43
+
44
+ $test{got} = $r;
45
+ diag explain \%test;
46
+ BAIL_OUT( 'a test failed, try again!' );
47
+ }
48
+
49
+ testcase(%$_) for
50
+ { "description" => "single bit one to decimal"
51
+ , "input_base" => 2
52
+ , "input_digits" => [1]
53
+ , "output_base" => 10
54
+ , "output_digits"=> [1]
55
+ },
56
+ { "description" => "binary to single decimal"
57
+ , "input_base" => 2
58
+ , "input_digits" => [1, 0, 1]
59
+ , "output_base" => 10
60
+ , "output_digits"=> [5]
61
+ },
62
+ { "description" => "single decimal to binary"
63
+ , "input_base" => 10
64
+ , "input_digits" => [5]
65
+ , "output_base" => 2
66
+ , "output_digits"=> [1, 0, 1]
67
+ },
68
+ { "description" => "binary to multiple decimal"
69
+ , "input_base" => 2
70
+ , "input_digits" => [1, 0, 1, 0, 1, 0]
71
+ , "output_base" => 10
72
+ , "output_digits"=> [4, 2]
73
+ },
74
+ { "description" => "decimal to binary"
75
+ , "input_base" => 10
76
+ , "input_digits" => [4, 2]
77
+ , "output_base" => 2
78
+ , "output_digits"=> [1, 0, 1, 0, 1, 0]
79
+ },
80
+ { "description" => "trinary to hexadecimal"
81
+ , "input_base" => 3
82
+ , "input_digits" => [1, 1, 2, 0]
83
+ , "output_base" => 16
84
+ , "output_digits"=> [2, 10]
85
+ },
86
+ { "description" => "hexadecimal to trinary"
87
+ , "input_base" => 16
88
+ , "input_digits" => [2, 10]
89
+ , "output_base" => 3
90
+ , "output_digits"=> [1, 1, 2, 0]
91
+ },
92
+ { "description" => "15-bit integer"
93
+ , "input_base" => 97
94
+ , "input_digits" => [3,46,60]
95
+ , "output_base" => 73
96
+ , "output_digits"=> [6,10,45]
97
+ },
98
+ { "description" => "empty list"
99
+ , "input_base" => 2
100
+ , "input_digits" => []
101
+ , "output_base" => 10
102
+ , "output_digits"=> [0]
103
+ },
104
+ { "description" => "single zero"
105
+ , "input_base" => 10
106
+ , "input_digits" => [0]
107
+ , "output_base" => 2
108
+ , "output_digits"=> [0]
109
+ },
110
+ { "description" => "multiple zeros"
111
+ , "input_base" => 10
112
+ , "input_digits" => [0, 0, 0]
113
+ , "output_base" => 2
114
+ , "output_digits"=> [0]
115
+ },
116
+ { "description" => "leading zeros"
117
+ , "input_base" => 7
118
+ , "input_digits" => [0, 6, 0]
119
+ , "output_base" => 10
120
+ , "output_digits"=> [ 4, 2 ]
121
+ },
122
+ { "description" => "negative digit"
123
+ , "input_base" => 2
124
+ , "input_digits" => [1, -1, 1, 0, 1, 0]
125
+ , "output_base" => 10
126
+ , "output_digits"=> undef
127
+ , error => qr/negative digit not allowed/
128
+ },
129
+ { "description" => "invalid positive digit"
130
+ , "input_base" => 2
131
+ , "input_digits" => [1, 2, 1, 0, 1, 0]
132
+ , "output_base" => 10
133
+ , "output_digits"=> undef
134
+ , error => qr/digit equal of greater than the base/
135
+ },
136
+ { "description" => "first base is one"
137
+ , "input_base" => 1
138
+ , "input_digits" => []
139
+ , "output_base" => 10
140
+ , "output_digits"=> undef
141
+ , error => qr/base must be greater than 1/
142
+ },
143
+ { "description" => "second base is one"
144
+ , "input_base" => 2
145
+ , "input_digits" => [1, 0, 1, 0, 1, 0]
146
+ , "output_base" => 1
147
+ , "output_digits"=> undef
148
+ , error => qr/base must be greater than 1/
149
+ },
150
+ { "description" => "first base is zero"
151
+ , "input_base" => 0
152
+ , "input_digits" => []
153
+ , "output_base" => 10
154
+ , "output_digits"=> undef
155
+ , error => qr/base must be greater than 1/
156
+ },
157
+ { "description" => "second base is zero"
158
+ , "input_base" => 10
159
+ , "input_digits" => [7]
160
+ , "output_base" => 0
161
+ , "output_digits"=> undef
162
+ , error => qr/base must be greater than 1/
163
+ },
164
+ { "description" => "first base is negative"
165
+ , "input_base" => -2
166
+ , "input_digits" => [1]
167
+ , "output_base" => 10
168
+ , "output_digits"=> undef
169
+ , error => qr/base must be greater than 1/
170
+ },
171
+ { "description" => "second base is negative"
172
+ , "input_base" => 2
173
+ , "input_digits" => [1]
174
+ , "output_base" => -7
175
+ , "output_digits"=> undef
176
+ , error => qr/base must be greater than 1/
177
+ },
178
+ { "description" => "both bases are negative"
179
+ , "input_base" => -2
180
+ , "input_digits" => [1]
181
+ , "output_base" => -7
182
+ , "output_digits"=> undef
183
+ , error => qr/base must be greater than 1/
184
+ };
@@ -75,6 +75,11 @@
75
75
  "difficulty": 1,
76
76
  "slug": "binary",
77
77
  "topics": []
78
+ },
79
+ {
80
+ "difficulty": 1,
81
+ "slug": "trinary",
82
+ "topics": []
78
83
  }
79
84
  ]
80
85
  }
@@ -0,0 +1,6 @@
1
+ sub to-decimal($num) is export {
2
+
3
+ return 0 if $num ~~ /<-[012]>/;
4
+
5
+ return reduce { 3 * $^a + $^b }, 0, |$num.comb;
6
+ }
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env perl6
2
+
3
+ use Test;
4
+
5
+ use lib ( my $dir = IO::Path.new($?FILE).parent ).path;
6
+
7
+ my $module_name = %*ENV<EXERCISM>.so ?? 'Example' !! 'Trinary';
8
+ my @potential_module = <p6 pm6 pm>.map: $module_name ~ '.' ~ *;
9
+
10
+ my $module = first { $dir.child($_).e }, |@potential_module
11
+ or die "No file '$module_name.p6' found\n";
12
+
13
+ require $module <&to-decimal>;
14
+
15
+ my @cases = (
16
+ {
17
+ input => 1,
18
+ expected => 1,
19
+ },
20
+ {
21
+ input => 2,
22
+ expected => 2,
23
+ },
24
+ {
25
+ input => 10,
26
+ expected => 3,
27
+ },
28
+ {
29
+ input => 11,
30
+ expected => 4,
31
+ },
32
+ {
33
+ input => 100,
34
+ expected => 9,
35
+ },
36
+ {
37
+ input => 10,
38
+ expected => 3,
39
+ },
40
+ {
41
+ input => 112,
42
+ expected => 14,
43
+ },
44
+ {
45
+ input => 222,
46
+ expected => 26,
47
+ },
48
+ {
49
+ input => 1122000120,
50
+ expected => 32091,
51
+ },
52
+ {
53
+ input => "carrot",
54
+ expected => 0,
55
+ }
56
+ );
57
+
58
+ plan @cases.elems;
59
+
60
+ is to-decimal( .<input> ), .<expected>, .<input> for @cases;
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock