trackler 2.0.8.11 → 2.0.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/common/README.md +70 -15
  3. data/common/canonical-schema.json +137 -0
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/elixir/config.json +7 -0
  6. data/tracks/elixir/exercises/simple-linked-list/example.exs +86 -0
  7. data/tracks/elixir/exercises/simple-linked-list/linked_list.exs +83 -0
  8. data/tracks/elixir/exercises/simple-linked-list/linked_list_test.exs +154 -0
  9. data/tracks/factor/README.md +0 -6
  10. data/tracks/factor/config.json +13 -3
  11. data/tracks/factor/docs/INSTALLATION.md +26 -29
  12. data/tracks/factor/exercises/hello-world/hello-world-example.factor +2 -2
  13. data/tracks/factor/exercises/leap/leap-example.factor +9 -0
  14. data/tracks/factor/exercises/leap/leap-tests.factor +32 -0
  15. data/tracks/go/exercises/phone-number/phone_number_test.go +5 -2
  16. data/tracks/go/exercises/pig-latin/example.go +2 -0
  17. data/tracks/go/exercises/pig-latin/pig_latin_test.go +8 -0
  18. data/tracks/java/config.json +5 -0
  19. data/tracks/java/exercises/anagram/src/test/java/AnagramTest.java +14 -0
  20. data/tracks/java/exercises/ocr-numbers/build.gradle +17 -0
  21. data/tracks/java/exercises/ocr-numbers/src/example/java/Digit.java +63 -0
  22. data/tracks/java/exercises/ocr-numbers/src/example/java/OpticalCharacterReader.java +67 -0
  23. data/tracks/java/exercises/ocr-numbers/src/main/java/OpticalCharacterReader.java +5 -0
  24. data/tracks/java/exercises/ocr-numbers/src/test/java/OpticalCharacterReaderTest.java +248 -0
  25. data/tracks/java/exercises/perfect-numbers/src/example/java/NaturalNumber.java +1 -1
  26. data/tracks/java/exercises/perfect-numbers/src/test/java/NaturalNumberTest.java +52 -5
  27. data/tracks/java/exercises/settings.gradle +1 -0
  28. data/tracks/java/img/icon.png +0 -0
  29. data/tracks/javascript/exercises/phone-number/phone-number.spec.js +22 -2
  30. data/tracks/julia/exercises/bob/example.jl +1 -1
  31. data/tracks/julia/exercises/custom-set/HINTS.md +2 -0
  32. data/tracks/julia/exercises/custom-set/runtests.jl +2 -2
  33. data/tracks/julia/img/{logo.png → icon.png} +0 -0
  34. data/tracks/julia/img/{logo.svg → icon.svg} +0 -0
  35. data/tracks/prolog/README.md +6 -2
  36. data/tracks/prolog/config.json +1 -1
  37. data/tracks/prolog/img/icon.png +0 -0
  38. data/tracks/scala/exercises/simple-linked-list/build.sbt +3 -0
  39. data/tracks/vimscript/README.md +7 -0
  40. data/tracks/vimscript/img/icon.png +0 -0
  41. metadata +17 -5
  42. data/tracks/vimscript/img/.keep +0 -0
@@ -0,0 +1,5 @@
1
+ final class OpticalCharacterReader {
2
+
3
+
4
+
5
+ }
@@ -0,0 +1,248 @@
1
+ import org.junit.Ignore;
2
+ import org.junit.Rule;
3
+ import org.junit.Test;
4
+ import org.junit.rules.ExpectedException;
5
+
6
+ import java.util.Arrays;
7
+
8
+ import static org.junit.Assert.assertEquals;
9
+
10
+ public final class OpticalCharacterReaderTest {
11
+
12
+ /*
13
+ * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
14
+ * ExpectedExceptions in particular.
15
+ */
16
+ @Rule
17
+ public ExpectedException expectedException = ExpectedException.none();
18
+
19
+ @Test
20
+ public void testReaderRecognizesSingle0() {
21
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
22
+ " _ ",
23
+ "| |",
24
+ "|_|",
25
+ " "
26
+ ));
27
+
28
+ assertEquals("0", parsedInput);
29
+ }
30
+
31
+ @Ignore
32
+ @Test
33
+ public void testReaderRecognizesSingle1() {
34
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
35
+ " ",
36
+ " |",
37
+ " |",
38
+ " "
39
+ ));
40
+
41
+ assertEquals("1", parsedInput);
42
+ }
43
+
44
+ @Ignore
45
+ @Test
46
+ public void testReaderReturnsQuestionMarkForUnreadableButCorrectlySizedInput() {
47
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
48
+ " ",
49
+ " _",
50
+ " |",
51
+ " "
52
+ ));
53
+
54
+ assertEquals("?", parsedInput);
55
+ }
56
+
57
+ @Ignore
58
+ @Test
59
+ public void testReaderThrowsExceptionWhenNumberOfInputLinesIsNotAMultipleOf4() {
60
+ expectedException.expect(IllegalArgumentException.class);
61
+ expectedException.expectMessage("Number of input rows must be a positive multiple of 4");
62
+
63
+ new OpticalCharacterReader().parse(Arrays.asList(
64
+ " _ ",
65
+ "| |",
66
+ " "
67
+ ));
68
+ }
69
+
70
+ @Ignore
71
+ @Test
72
+ public void testReaderThrowsExceptionWhenNumberOfInputColumnsIsNotAMultipleOf3() {
73
+ expectedException.expect(IllegalArgumentException.class);
74
+ expectedException.expectMessage("Number of input columns must be a positive multiple of 3");
75
+
76
+ new OpticalCharacterReader().parse(Arrays.asList(
77
+ " ",
78
+ " |",
79
+ " |",
80
+ " "
81
+ ));
82
+ }
83
+
84
+ @Ignore
85
+ @Test
86
+ public void testReaderRecognizesBinarySequence110101100() {
87
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
88
+ " _ _ _ _ ",
89
+ " | || | || | | || || |",
90
+ " | ||_| ||_| | ||_||_|",
91
+ " "
92
+ ));
93
+
94
+ assertEquals("110101100", parsedInput);
95
+ }
96
+
97
+ @Ignore
98
+ @Test
99
+ public void testReaderReplacesUnreadableDigitsWithQuestionMarksWithinSequence() {
100
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
101
+ " _ _ _ ",
102
+ " | || | || | || || |",
103
+ " | | _| ||_| | ||_||_|",
104
+ " "
105
+ ));
106
+
107
+ assertEquals("11?10?1?0", parsedInput);
108
+ }
109
+
110
+ @Ignore
111
+ @Test
112
+ public void testReaderRecognizesSingle2() {
113
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
114
+ " _ ",
115
+ " _|",
116
+ "|_ ",
117
+ " "
118
+ ));
119
+
120
+ assertEquals("2", parsedInput);
121
+ }
122
+
123
+ @Ignore
124
+ @Test
125
+ public void testReaderRecognizesSingle3() {
126
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
127
+ " _ ",
128
+ " _|",
129
+ " _|",
130
+ " "
131
+ ));
132
+
133
+ assertEquals("3", parsedInput);
134
+ }
135
+
136
+ @Ignore
137
+ @Test
138
+ public void testReaderRecognizesSingle4() {
139
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
140
+ " ",
141
+ "|_|",
142
+ " |",
143
+ " "
144
+ ));
145
+
146
+ assertEquals("4", parsedInput);
147
+ }
148
+
149
+ @Ignore
150
+ @Test
151
+ public void testReaderRecognizesSingle5() {
152
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
153
+ " _ ",
154
+ "|_ ",
155
+ " _|",
156
+ " "
157
+ ));
158
+
159
+ assertEquals("5", parsedInput);
160
+ }
161
+
162
+ @Ignore
163
+ @Test
164
+ public void testReaderRecognizesSingle6() {
165
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
166
+ " _ ",
167
+ "|_ ",
168
+ "|_|",
169
+ " "
170
+ ));
171
+
172
+ assertEquals("6", parsedInput);
173
+ }
174
+
175
+ @Ignore
176
+ @Test
177
+ public void testReaderRecognizesSingle7() {
178
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
179
+ " _ ",
180
+ " |",
181
+ " |",
182
+ " "
183
+ ));
184
+
185
+ assertEquals("7", parsedInput);
186
+ }
187
+
188
+ @Ignore
189
+ @Test
190
+ public void testReaderRecognizesSingle8() {
191
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
192
+ " _ ",
193
+ "|_|",
194
+ "|_|",
195
+ " "
196
+ ));
197
+
198
+ assertEquals("8", parsedInput);
199
+ }
200
+
201
+ @Ignore
202
+ @Test
203
+ public void testReaderRecognizesSingle9() {
204
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
205
+ " _ ",
206
+ "|_|",
207
+ " _|",
208
+ " "
209
+ ));
210
+
211
+ assertEquals("9", parsedInput);
212
+ }
213
+
214
+ @Ignore
215
+ @Test
216
+ public void testReaderRecognizesSequence1234567890() {
217
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
218
+ " _ _ _ _ _ _ _ _ ",
219
+ " | _| _||_||_ |_ ||_||_|| |",
220
+ " ||_ _| | _||_| ||_| _||_|",
221
+ " "
222
+ ));
223
+
224
+ assertEquals("1234567890", parsedInput);
225
+ }
226
+
227
+ @Ignore
228
+ @Test
229
+ public void testReaderRecognizesAndCorrectlyFormatsMultiRowInput() {
230
+ String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
231
+ " _ _ ",
232
+ " | _| _|",
233
+ " ||_ _|",
234
+ " ",
235
+ " _ _ ",
236
+ "|_||_ |_ ",
237
+ " | _||_|",
238
+ " ",
239
+ " _ _ _ ",
240
+ " ||_||_|",
241
+ " ||_| _|",
242
+ " "
243
+ ));
244
+
245
+ assertEquals("123,456,789", parsedInput);
246
+ }
247
+
248
+ }
@@ -5,7 +5,7 @@ final class NaturalNumber {
5
5
  private final int naturalNumber;
6
6
 
7
7
  NaturalNumber(int naturalNumber) {
8
- if (naturalNumber <= 0) throw new IllegalStateException("Natural numbers are all positive.");
8
+ if (naturalNumber <= 0) throw new IllegalArgumentException("You must supply a natural number (positive integer)");
9
9
  this.naturalNumber = naturalNumber;
10
10
  }
11
11
 
@@ -1,10 +1,23 @@
1
1
  import org.junit.Ignore;
2
+ import org.junit.Rule;
2
3
  import org.junit.Test;
4
+ import org.junit.rules.ExpectedException;
3
5
 
4
6
  import static org.junit.Assert.assertEquals;
5
7
 
8
+ /*
9
+ * version: 1.0.0
10
+ * https://github.com/exercism/x-common/blob/19d0c7714ce664a1ad762af624c17f8e269fa8b2/exercises/perfect-numbers/canonical-data.json
11
+ */
6
12
  public final class NaturalNumberTest {
7
13
 
14
+ /*
15
+ * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
16
+ * ExpectedExceptions in particular.
17
+ */
18
+ @Rule
19
+ public ExpectedException expectedException = ExpectedException.none();
20
+
8
21
  @Test
9
22
  public void testSmallPerfectNumberIsClassifiedCorrectly() {
10
23
  assertEquals(Classification.PERFECT, new NaturalNumber(6).getClassification());
@@ -31,7 +44,7 @@ public final class NaturalNumberTest {
31
44
  @Ignore
32
45
  @Test
33
46
  public void testMediumAbundantNumberIsClassifiedCorrectly() {
34
- assertEquals(Classification.ABUNDANT, new NaturalNumber(24).getClassification());
47
+ assertEquals(Classification.ABUNDANT, new NaturalNumber(30).getClassification());
35
48
  }
36
49
 
37
50
  @Ignore
@@ -42,14 +55,20 @@ public final class NaturalNumberTest {
42
55
 
43
56
  @Ignore
44
57
  @Test
45
- public void testSmallDeficientNumberIsClassifiedCorrectly() {
46
- assertEquals(Classification.DEFICIENT, new NaturalNumber(8).getClassification());
58
+ public void testSmallestPrimeDeficientNumberIsClassifiedCorrectly() {
59
+ assertEquals(Classification.DEFICIENT, new NaturalNumber(2).getClassification());
60
+ }
61
+
62
+ @Ignore
63
+ @Test
64
+ public void testSmallestNonPrimeDeficientNumberIsClassifiedCorrectly() {
65
+ assertEquals(Classification.DEFICIENT, new NaturalNumber(4).getClassification());
47
66
  }
48
67
 
49
68
  @Ignore
50
69
  @Test
51
- public void testMediumNumberIsClassifiedCorrectly() {
52
- assertEquals(Classification.DEFICIENT, new NaturalNumber(31).getClassification());
70
+ public void testMediumDeficientNumberIsClassifiedCorrectly() {
71
+ assertEquals(Classification.DEFICIENT, new NaturalNumber(32).getClassification());
53
72
  }
54
73
 
55
74
  @Ignore
@@ -58,4 +77,32 @@ public final class NaturalNumberTest {
58
77
  assertEquals(Classification.DEFICIENT, new NaturalNumber(33550337).getClassification());
59
78
  }
60
79
 
80
+ @Ignore
81
+ @Test
82
+ /*
83
+ * The number 1 has no proper divisors (https://en.wikipedia.org/wiki/Divisor#Further_notions_and_facts), and the
84
+ * additive identity is 0, so the aliquot sum of 1 should be 0. Hence 1 should be classified as deficient.
85
+ */
86
+ public void testThatOneIsCorrectlyClassifiedAsDeficient() {
87
+ assertEquals(Classification.DEFICIENT, new NaturalNumber(1).getClassification());
88
+ }
89
+
90
+ @Ignore
91
+ @Test
92
+ public void testThatNonNegativeIntegerIsRejected() {
93
+ expectedException.expect(IllegalArgumentException.class);
94
+ expectedException.expectMessage("You must supply a natural number (positive integer)");
95
+
96
+ new NaturalNumber(0);
97
+ }
98
+
99
+ @Ignore
100
+ @Test
101
+ public void testThatNegativeIntegerIsRejected() {
102
+ expectedException.expect(IllegalArgumentException.class);
103
+ expectedException.expectMessage("You must supply a natural number (positive integer)");
104
+
105
+ new NaturalNumber(-1);
106
+ }
107
+
61
108
  }
@@ -32,6 +32,7 @@ include 'meetup'
32
32
  include 'minesweeper'
33
33
  include 'nth-prime'
34
34
  include 'nucleotide-count'
35
+ include 'ocr-numbers'
35
36
  include 'octal'
36
37
  include 'palindrome-products'
37
38
  include 'pangram'
Binary file
@@ -11,13 +11,23 @@ describe('PhoneNumber()', function() {
11
11
  expect(phone.number()).toEqual('1234567890');
12
12
  });
13
13
 
14
+ xit('cleans some other number with dots', function() {
15
+ var phone = new PhoneNumber('555.456.7890');
16
+ expect(phone.number()).toEqual('5554567890');
17
+ });
18
+
14
19
  xit('valid when 11 digits and first digit is 1', function() {
15
20
  var phone = new PhoneNumber('11234567890');
16
21
  expect(phone.number()).toEqual('1234567890');
17
22
  });
18
23
 
19
- xit('invalid when 11 digits', function() {
20
- var phone = new PhoneNumber('21234567890');
24
+ xit('invalid when 11 digits and the first digit is NOT 1', function() {
25
+ var phone = new PhoneNumber('2 1234567890');
26
+ expect(phone.number()).toEqual('0000000000');
27
+ });
28
+
29
+ xit('invalid when 12 digits', function() {
30
+ var phone = new PhoneNumber('991234567890');
21
31
  expect(phone.number()).toEqual('0000000000');
22
32
  });
23
33
 
@@ -31,8 +41,18 @@ describe('PhoneNumber()', function() {
31
41
  expect(phone.areaCode()).toEqual('123');
32
42
  });
33
43
 
44
+ xit('has some other area code', function() {
45
+ var phone = new PhoneNumber('5554567890');
46
+ expect(phone.areaCode()).toEqual('555');
47
+ });
48
+
34
49
  xit('formats a number', function() {
35
50
  var phone = new PhoneNumber('1234567890');
36
51
  expect(phone.toString()).toEqual('(123) 456-7890');
37
52
  });
53
+
54
+ xit('formats some other number', function() {
55
+ var phone = new PhoneNumber('5554567890');
56
+ expect(phone.toString()).toEqual('(555) 456-7890');
57
+ });
38
58
  });
@@ -16,7 +16,7 @@ issilence(stimulus::AbstractString) = isempty(stimulus)
16
16
  isquestion(stimulus::AbstractString) = endswith(stimulus, '?')
17
17
 
18
18
  function isshouting(stimulus::AbstractString)
19
- isupper(stimulus) && return true
19
+ all(isupper, stimulus) && return true
20
20
  !any(isalpha, stimulus) && return false
21
21
 
22
22
  for c in stimulus
@@ -1 +1,3 @@
1
1
  The tests require a constructor that takes an array. The internals of your custom set implementation can use other data structures but you may have to implement an outer constructor that takes exactly one array for the tests to pass.
2
+
3
+ Certain methods have a unicode operator equivalent. E.g. `intersect(CustomSet([1, 2, 3, 4]), CustomSet([]))` is equivalent to `CustomSet([1, 2, 3, 4]) ∩ CustomSet([])`.
@@ -14,7 +14,7 @@ end
14
14
  @test !(4 in CustomSet([1, 2, 3]))
15
15
  end
16
16
 
17
- @testset "subset" begin # TODO ⊆, ⊈
17
+ @testset "subset" begin
18
18
  @test issubset(CustomSet([]), CustomSet([]))
19
19
  @test issubset(CustomSet([]), CustomSet([1]))
20
20
  @test !issubset(CustomSet([1]), CustomSet([]))
@@ -90,7 +90,7 @@ end
90
90
  cs1 == CustomSet([2, 3])
91
91
  end
92
92
  end
93
- @testset "not in-place" begin # TODO use operator ∩
93
+ @testset "not in-place" begin
94
94
  @test isempty(intersect(CustomSet([]), CustomSet([])))
95
95
  @test isempty(intersect(CustomSet([]), CustomSet([3, 2, 5])))
96
96
  @test isempty(intersect(CustomSet([1, 2, 3, 4]), CustomSet([])))
File without changes
File without changes
@@ -45,7 +45,7 @@ file for the real implementation. The example solution should have the
45
45
  This allows the tests to be run on CI and configures tests to be skipped with
46
46
  the `condition(pending)` flag.
47
47
 
48
- ```prolog
48
+ ```prolog
49
49
  pending :-
50
50
  current_prolog_flag(argv, ['--all'|_]).
51
51
  pending :-
@@ -58,7 +58,7 @@ pending :-
58
58
  first test should have `condition(true)` as an example of how to change the
59
59
  tests to run. Here are the first two tests in the `hello_world` exercise.
60
60
 
61
- ```prolog
61
+ ```prolog
62
62
  test(hello_world, condition(true)) :-
63
63
  hello_world('Hello World!').
64
64
 
@@ -74,3 +74,7 @@ with `bin/build.sh`. Please run this command before submitting your PR.
74
74
  The MIT License (MIT)
75
75
 
76
76
  Copyright (c) 2016 Katrina Owen, _@kytrinyx.com
77
+
78
+ ### [SWI Prolog icon](https://github.com/exercism/xprolog/tree/master/img/icon.png)
79
+
80
+ The SWI Prolog "Owlie" logo is owned by the SWI Prolog maintainers and released under the Simplified BSD license. We have adapted it for use on Exercism, changing the colour scheme, with [the express permission of `anne@swiprolog.org`](https://github.com/exercism/xprolog/issues/1#issuecomment-283122027).