trackler 2.0.5.5 → 2.0.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/csharp/config.json +15 -0
  4. data/tracks/csharp/exercises/list-ops/Example.cs +77 -0
  5. data/tracks/csharp/exercises/list-ops/HINTS.md +2 -0
  6. data/tracks/csharp/exercises/list-ops/ListOpsTest.cs +195 -0
  7. data/tracks/csharp/exercises/two-bucket/Example.cs +109 -0
  8. data/tracks/csharp/exercises/two-bucket/TwoBucketTest.cs +71 -0
  9. data/tracks/ecmascript/config.json +13 -30
  10. data/tracks/ecmascript/exercises/all-your-base/all-your-base.spec.js +139 -0
  11. data/tracks/ecmascript/exercises/all-your-base/example.js +55 -0
  12. data/tracks/ecmascript/exercises/all-your-base/gulpfile.js +89 -0
  13. data/tracks/ecmascript/exercises/all-your-base/package.json +28 -0
  14. data/tracks/fsharp/exercises/diffie-hellman/HINTS.md +3 -0
  15. data/tracks/fsharp/exercises/gigasecond/HINTS.md +2 -0
  16. data/tracks/fsharp/exercises/palindrome-products/HINTS.md +2 -0
  17. data/tracks/java/config.json +6 -0
  18. data/tracks/java/docs/INSTALLATION.md +1 -0
  19. data/tracks/java/exercises/custom-set/build.gradle +18 -0
  20. data/tracks/java/exercises/custom-set/src/example/java/CustomSet.java +74 -0
  21. data/tracks/java/exercises/custom-set/src/main/java/.keep +0 -0
  22. data/tracks/java/exercises/custom-set/src/test/java/CustomSetTest.java +505 -0
  23. data/tracks/java/exercises/settings.gradle +1 -0
  24. data/tracks/purescript/config.json +25 -0
  25. data/tracks/purescript/exercises/accumulate/bower.json +16 -0
  26. data/tracks/purescript/exercises/accumulate/examples/src/Accumulate.purs +15 -0
  27. data/tracks/purescript/exercises/accumulate/src/Accumulate.purs +3 -0
  28. data/tracks/purescript/exercises/accumulate/test/Main.purs +41 -0
  29. data/tracks/purescript/exercises/acronym/bower.json +1 -1
  30. data/tracks/purescript/exercises/bob/bower.json +1 -1
  31. data/tracks/purescript/exercises/pangram/bower.json +1 -1
  32. data/tracks/purescript/exercises/raindrops/bower.json +1 -1
  33. data/tracks/purescript/exercises/scrabble-score/bower.json +16 -0
  34. data/tracks/purescript/exercises/scrabble-score/examples/src/ScrabbleScore.purs +47 -0
  35. data/tracks/purescript/exercises/scrabble-score/src/ScrabbleScore.purs +3 -0
  36. data/tracks/purescript/exercises/scrabble-score/test/Main.purs +45 -0
  37. data/tracks/purescript/exercises/triangle/bower.json +19 -0
  38. data/tracks/purescript/exercises/triangle/examples/src/Triangle.purs +40 -0
  39. data/tracks/purescript/exercises/triangle/src/Triangle.purs +4 -0
  40. data/tracks/purescript/exercises/triangle/test/Main.purs +66 -0
  41. data/tracks/ruby/.rubocop.yml +3 -0
  42. data/tracks/ruby/README.md +1 -1
  43. metadata +30 -2
@@ -104,6 +104,7 @@ If you are using Debian or its derivatives (like Ubuntu or Linux Mint), use APT:
104
104
  $ sudo add-apt-repository ppa:webupd8team/java
105
105
  $ sudo apt-get update
106
106
  $ sudo apt-get install oracle-java8-installer
107
+ $ sudo apt install oracle-java8-set-default
107
108
  ```
108
109
  - Install Gradle:
109
110
 
@@ -0,0 +1,18 @@
1
+ apply plugin: "java"
2
+ apply plugin: "eclipse"
3
+ apply plugin: "idea"
4
+
5
+ repositories {
6
+ mavenCentral()
7
+ }
8
+
9
+ dependencies {
10
+ testCompile "junit:junit:4.12"
11
+ }
12
+
13
+ test {
14
+ testLogging {
15
+ exceptionFormat = 'full'
16
+ events = ["passed", "failed", "skipped"]
17
+ }
18
+ }
@@ -0,0 +1,74 @@
1
+
2
+ import java.util.Collection;
3
+ import java.util.Collections;
4
+ import java.util.HashSet;
5
+ import java.util.Set;
6
+ import java.util.function.Predicate;
7
+ import java.util.stream.Collectors;
8
+
9
+ public class CustomSet<T> {
10
+
11
+ private Set<T> set;
12
+
13
+ public CustomSet() {
14
+ this(Collections.EMPTY_LIST);
15
+ }
16
+
17
+ public CustomSet(Collection<T> data) {
18
+ set = new HashSet<>(data.size());
19
+ this.set.addAll(data);
20
+ }
21
+
22
+ public boolean isEmpty() {
23
+ return set.isEmpty();
24
+ }
25
+
26
+ public boolean contains(T element) {
27
+ return set.contains(element);
28
+ }
29
+
30
+ public boolean isSubset(CustomSet<T> anotherSet) {
31
+ return set.containsAll(anotherSet.set);
32
+ }
33
+
34
+ public boolean isDisjoint(CustomSet<T> anotherSet) {
35
+ if (set.isEmpty() || anotherSet.set.isEmpty()) {
36
+ return true;
37
+ }
38
+ return set.stream()
39
+ .filter(elem -> anotherSet.set.contains(elem))
40
+ .count() == 0;
41
+ }
42
+
43
+ public boolean equals(CustomSet<T> anotherSet) {
44
+ return set.equals(anotherSet.set);
45
+ }
46
+
47
+ public boolean add(T element) {
48
+ return set.add(element);
49
+ }
50
+
51
+ public CustomSet<T> getIntersection(CustomSet<T> anotherSet) {
52
+ return new CustomSet<>(
53
+ set.stream()
54
+ .filter(anotherSet.set::contains)
55
+ .collect(Collectors.toList())
56
+ );
57
+ }
58
+
59
+ public CustomSet<T> getUnion(CustomSet<T> anotherSet) {
60
+ final Set<T> union = new HashSet<>(set);
61
+ union.addAll(anotherSet.set);
62
+ return new CustomSet<>(union);
63
+ }
64
+
65
+ public CustomSet<T> getDifference(CustomSet<T> anotherSet) {
66
+ final Predicate<T> predicate = anotherSet::contains;
67
+ return new CustomSet<>(
68
+ set.stream()
69
+ .filter(predicate.negate())
70
+ .collect(Collectors.toList())
71
+ );
72
+ }
73
+
74
+ }
@@ -0,0 +1,505 @@
1
+
2
+ import java.util.Arrays;
3
+ import java.util.Collections;
4
+ import static org.junit.Assert.assertFalse;
5
+ import static org.junit.Assert.assertNotNull;
6
+ import static org.junit.Assert.assertTrue;
7
+ import org.junit.Test;
8
+ import org.junit.Ignore;
9
+
10
+ public class CustomSetTest {
11
+
12
+ @Test
13
+ public void setsWithNoElementsAreEmpty() {
14
+ final boolean actual
15
+ = new CustomSet<>(Collections.EMPTY_LIST)
16
+ .isEmpty();
17
+ assertTrue(actual);
18
+ }
19
+
20
+ @Test
21
+ @Ignore
22
+ public void setsWithElementsAreNotEmpty() {
23
+ final boolean actual
24
+ = new CustomSet<>(Arrays.asList(1))
25
+ .isEmpty();
26
+
27
+ assertFalse(actual);
28
+ }
29
+
30
+ @Test
31
+ @Ignore
32
+ public void nothingIsContainedInAnEmptySet() {
33
+ final boolean actual
34
+ = new CustomSet<>(Collections.EMPTY_LIST)
35
+ .contains(1);
36
+
37
+ assertFalse(actual);
38
+ }
39
+
40
+ @Test
41
+ @Ignore
42
+ public void whenTheElementIsInTheSet() {
43
+ final boolean actual
44
+ = new CustomSet<>(Arrays.asList(1, 2, 3))
45
+ .contains(1);
46
+
47
+ assertTrue(actual);
48
+ }
49
+
50
+ @Test
51
+ @Ignore
52
+ public void whenTheElementIsNotInTheSet() {
53
+ final boolean actual
54
+ = new CustomSet<>(Arrays.asList(1, 2, 3))
55
+ .contains(4);
56
+
57
+ assertFalse(actual);
58
+ }
59
+
60
+ @Test
61
+ @Ignore
62
+ public void emptySetIsASubsetOfAnotherEmptySet() {
63
+ final boolean actual
64
+ = new CustomSet<>(Collections.EMPTY_LIST)
65
+ .isSubset(
66
+ new CustomSet<>(Collections.EMPTY_LIST)
67
+ );
68
+
69
+ assertTrue(actual);
70
+ }
71
+
72
+ @Test
73
+ @Ignore
74
+ public void emptySetIsASubsetOfNonEemptySet() {
75
+ final boolean actual
76
+ = new CustomSet<>(Arrays.asList(1))
77
+ .isSubset(
78
+ new CustomSet<>(Collections.EMPTY_LIST)
79
+ );
80
+
81
+ assertTrue(actual);
82
+ }
83
+
84
+ @Test
85
+ @Ignore
86
+ public void nonEmptySetIsNotASubsetOfEmptySet() {
87
+ final boolean actual
88
+ = new CustomSet<>(Collections.EMPTY_LIST)
89
+ .isSubset(
90
+ new CustomSet<>(Arrays.asList(1))
91
+ );
92
+
93
+ assertFalse(actual);
94
+ }
95
+
96
+ @Test
97
+ @Ignore
98
+ public void setIsASubsetOfSetWithExactSameElements() {
99
+ final boolean actual
100
+ = new CustomSet<>(Arrays.asList(1, 2, 3))
101
+ .isSubset(
102
+ new CustomSet<>(Arrays.asList(1, 2, 3))
103
+ );
104
+
105
+ assertTrue(actual);
106
+ }
107
+
108
+ @Test
109
+ @Ignore
110
+ public void setIsASubsetOfLargerSetWithSameElements() {
111
+ final boolean actual
112
+ = new CustomSet<>(Arrays.asList(4, 1, 2, 3))
113
+ .isSubset(
114
+ new CustomSet<>(Arrays.asList(1, 2, 3))
115
+ );
116
+
117
+ assertTrue(actual);
118
+ }
119
+
120
+ @Test
121
+ @Ignore
122
+ public void setIsNotASubsetOfSetThatDoesNotContainItsElements() {
123
+ final boolean actual
124
+ = new CustomSet<>(Arrays.asList(4, 1, 3))
125
+ .isSubset(
126
+ new CustomSet<>(Arrays.asList(1, 2, 3))
127
+ );
128
+
129
+ assertFalse(actual);
130
+ }
131
+
132
+ @Test
133
+ @Ignore
134
+ public void theEmptySetIsDisjointWithItself() {
135
+ final boolean actual
136
+ = new CustomSet<>(Collections.EMPTY_LIST)
137
+ .isDisjoint(
138
+ new CustomSet<>(Collections.EMPTY_LIST)
139
+ );
140
+
141
+ assertTrue(actual);
142
+ }
143
+
144
+ @Test
145
+ @Ignore
146
+ public void emptySetIsDisjointWithNonEmptySet() {
147
+ final boolean actual
148
+ = new CustomSet<>(Collections.EMPTY_LIST)
149
+ .isDisjoint(
150
+ new CustomSet<>(Arrays.asList(1))
151
+ );
152
+
153
+ assertTrue(actual);
154
+ }
155
+
156
+ @Test
157
+ @Ignore
158
+ public void nonEmptySetIsDisjointWithEmptySet() {
159
+ final boolean actual
160
+ = new CustomSet<>(Arrays.asList(1))
161
+ .isDisjoint(
162
+ new CustomSet<>(Collections.EMPTY_LIST)
163
+ );
164
+
165
+ assertTrue(actual);
166
+ }
167
+
168
+ @Test
169
+ @Ignore
170
+ public void setsAreNotDisjointIfTheyShareAnElement() {
171
+ final boolean actual
172
+ = new CustomSet<>(Arrays.asList(1, 2))
173
+ .isDisjoint(
174
+ new CustomSet<>(Arrays.asList(2, 3))
175
+ );
176
+
177
+ assertFalse(actual);
178
+ }
179
+
180
+ @Test
181
+ @Ignore
182
+ public void setsAreDisjointIfTheyShareNoElements() {
183
+ final boolean actual
184
+ = new CustomSet<>(Arrays.asList(1, 2))
185
+ .isDisjoint(
186
+ new CustomSet<>(Arrays.asList(3, 4))
187
+ );
188
+
189
+ assertTrue(actual);
190
+ }
191
+
192
+ @Test
193
+ @Ignore
194
+ public void emptySetsAreEqual() {
195
+ final boolean actual
196
+ = new CustomSet<>(Collections.EMPTY_LIST)
197
+ .equals(
198
+ new CustomSet<>(Collections.EMPTY_LIST)
199
+ );
200
+
201
+ assertTrue(actual);
202
+ }
203
+
204
+ @Test
205
+ @Ignore
206
+ public void emptySetIsNotEqualToNonEmptySet() {
207
+ final boolean actual
208
+ = new CustomSet<>(Collections.EMPTY_LIST)
209
+ .equals(
210
+ new CustomSet<>(Arrays.asList(1, 2, 3))
211
+ );
212
+
213
+ assertFalse(actual);
214
+ }
215
+
216
+ @Test
217
+ @Ignore
218
+ public void nonEmptySetIsNotEqualToEmptySet() {
219
+ final boolean actual
220
+ = new CustomSet<>(Arrays.asList(1, 2, 3))
221
+ .equals(
222
+ new CustomSet<>(Collections.EMPTY_LIST)
223
+ );
224
+
225
+ assertFalse(actual);
226
+ }
227
+
228
+ @Test
229
+ @Ignore
230
+ public void setsWithTheSameElementsAreEqual() {
231
+ final boolean actual
232
+ = new CustomSet<>(Arrays.asList(1, 2))
233
+ .equals(
234
+ new CustomSet<>(Arrays.asList(2, 1))
235
+ );
236
+
237
+ assertTrue(actual);
238
+ }
239
+
240
+ @Test
241
+ @Ignore
242
+ public void setsWithDifferentElementsAreNotEqual() {
243
+ final boolean actual
244
+ = new CustomSet<>(Arrays.asList(1, 2, 3))
245
+ .equals(
246
+ new CustomSet<>(Arrays.asList(1, 2, 4))
247
+ );
248
+
249
+ assertFalse(actual);
250
+ }
251
+
252
+ @Test
253
+ @Ignore
254
+ public void addToEmptySet() {
255
+ final int element = 3;
256
+ final CustomSet<Integer> expected
257
+ = new CustomSet<>(
258
+ Collections.unmodifiableList(Arrays.asList(element))
259
+ );
260
+ final CustomSet<Integer> actual
261
+ = new CustomSet<>(Collections.EMPTY_LIST);
262
+
263
+ actual.add(element);
264
+
265
+ assertNotNull(actual);
266
+ assertFalse(actual.isEmpty());
267
+ assertTrue(expected.equals(actual));
268
+ }
269
+
270
+ @Test
271
+ @Ignore
272
+ public void addToNonEmptySet() {
273
+ final int element = 3;
274
+ final CustomSet<Integer> expected
275
+ = new CustomSet<>(
276
+ Collections.unmodifiableList(Arrays.asList(1, 2, 3, 4))
277
+ );
278
+ final CustomSet<Integer> actual
279
+ = new CustomSet<>(Arrays.asList(1, 2, 4));
280
+
281
+ actual.add(element);
282
+
283
+ assertNotNull(actual);
284
+ assertFalse(actual.isEmpty());
285
+ assertTrue(expected.equals(actual));
286
+ }
287
+
288
+ @Test
289
+ @Ignore
290
+ public void addingAnExistingElementDoesNotChangeTheSet() {
291
+ final int element = 3;
292
+ final CustomSet<Integer> expected
293
+ = new CustomSet<>(
294
+ Collections.unmodifiableList(Arrays.asList(1, 2, 3))
295
+ );
296
+ final CustomSet<Integer> actual
297
+ = new CustomSet<>(Arrays.asList(1, 2, 3));
298
+
299
+ actual.add(element);
300
+
301
+ assertNotNull(actual);
302
+ assertTrue(expected.equals(actual));
303
+ }
304
+
305
+ @Test
306
+ @Ignore
307
+ public void intersectionOfTwoEmptySetsIsAnEmptySet() {
308
+ final CustomSet<Integer> actual
309
+ = new CustomSet<>(Collections.EMPTY_LIST)
310
+ .getIntersection(
311
+ new CustomSet<>(Collections.EMPTY_LIST)
312
+ );
313
+
314
+ assertNotNull(actual);
315
+ assertTrue(actual.isEmpty());
316
+ }
317
+
318
+ @Test
319
+ @Ignore
320
+ public void intersectionOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
321
+ final CustomSet<Integer> actual
322
+ = new CustomSet<>(Collections.EMPTY_LIST)
323
+ .getIntersection(
324
+ new CustomSet<>(Arrays.asList(3, 2, 5))
325
+ );
326
+
327
+ assertNotNull(actual);
328
+ assertTrue(actual.isEmpty());
329
+ }
330
+
331
+ @Test
332
+ @Ignore
333
+ public void intersectionOfANonEmptySetAndAnEmptySetIsAnEmptySet() {
334
+ final CustomSet<Integer> actual
335
+ = new CustomSet<>(Arrays.asList(1, 2, 3, 4))
336
+ .getIntersection(
337
+ new CustomSet<>(Collections.EMPTY_LIST)
338
+ );
339
+
340
+ assertNotNull(actual);
341
+ assertTrue(actual.isEmpty());
342
+
343
+ }
344
+
345
+ @Test
346
+ @Ignore
347
+ public void intersectionOfTwoSetsWithNoSharedElementsIsAnEmptySet() {
348
+ final CustomSet<Integer> actual
349
+ = new CustomSet<>(Arrays.asList(1, 2, 3))
350
+ .getIntersection(
351
+ new CustomSet<>(Arrays.asList(4, 5, 6))
352
+ );
353
+
354
+ assertNotNull(actual);
355
+ assertTrue(actual.isEmpty());
356
+ }
357
+
358
+ @Test
359
+ @Ignore
360
+ public void intersectionOfTwoSetsWithSharedElementsIsASetOfTheSharedElements() {
361
+ final CustomSet<Integer> expected
362
+ = new CustomSet<>(
363
+ Collections.unmodifiableList(Arrays.asList(2, 3))
364
+ );
365
+ final CustomSet<Integer> actual
366
+ = new CustomSet<>(Arrays.asList(1, 2, 3, 4))
367
+ .getIntersection(
368
+ new CustomSet<>(Arrays.asList(3, 2, 5))
369
+ );
370
+
371
+ assertNotNull(actual);
372
+ assertFalse(actual.isEmpty());
373
+ assertTrue(expected.equals(actual));
374
+ }
375
+
376
+ @Test
377
+ @Ignore
378
+ public void differenceOfTwoEmptySetsIsAnEmptySet() {
379
+ final CustomSet<Integer> actual
380
+ = new CustomSet<>(Collections.EMPTY_LIST)
381
+ .getDifference(
382
+ new CustomSet<>(Collections.EMPTY_LIST)
383
+ );
384
+
385
+ assertNotNull(actual);
386
+ assertTrue(actual.isEmpty());
387
+ }
388
+
389
+ @Test
390
+ @Ignore
391
+ public void differenceOfAnEmptySetAndNonEmptySetIsAnEmptySet() {
392
+ final CustomSet<Integer> actual
393
+ = new CustomSet<>(Collections.EMPTY_LIST)
394
+ .getDifference(
395
+ new CustomSet<>(Arrays.asList(3, 2, 5))
396
+ );
397
+
398
+ assertNotNull(actual);
399
+ assertTrue(actual.isEmpty());
400
+ }
401
+
402
+ @Test
403
+ @Ignore
404
+ public void differenceOfANonEmptySetAndAnEmptySetIsTheNonEmptySet() {
405
+ final CustomSet<Integer> expected
406
+ = new CustomSet<>(
407
+ Collections.unmodifiableList(Arrays.asList(1, 2, 3, 4))
408
+ );
409
+ final CustomSet<Integer> actual
410
+ = new CustomSet<>(Arrays.asList(1, 2, 3, 4))
411
+ .getDifference(
412
+ new CustomSet<>(Collections.EMPTY_LIST)
413
+ );
414
+
415
+ assertNotNull(actual);
416
+ assertFalse(actual.isEmpty());
417
+ assertTrue(expected.equals(actual));
418
+ }
419
+
420
+ @Test
421
+ @Ignore
422
+ public void differenceOfTwoNonEmptySetsIsASetOfElementsThatAreOnlyInTheFirstSet() {
423
+ final CustomSet<Integer> expected
424
+ = new CustomSet<>(
425
+ Collections.unmodifiableList(Arrays.asList(1, 3))
426
+ );
427
+ final CustomSet<Integer> actual
428
+ = new CustomSet<>(Arrays.asList(3, 2, 1))
429
+ .getDifference(
430
+ new CustomSet<>(Arrays.asList(2, 4))
431
+ );
432
+
433
+ assertNotNull(actual);
434
+ assertFalse(actual.isEmpty());
435
+ assertTrue(expected.equals(actual));
436
+ }
437
+
438
+ @Test
439
+ @Ignore
440
+ public void unionOfTwoEmptySetsIsAnEmptySet() {
441
+ final CustomSet<Integer> actual
442
+ = new CustomSet<>(Collections.EMPTY_LIST)
443
+ .getUnion(
444
+ new CustomSet<>(Collections.EMPTY_LIST)
445
+ );
446
+
447
+ assertNotNull(actual);
448
+ assertTrue(actual.isEmpty());
449
+ }
450
+
451
+ @Test
452
+ @Ignore
453
+ public void unionOfAnEmptySetAndNonEmptySetIsTheNonEmptySet() {
454
+ final CustomSet<Integer> expected
455
+ = new CustomSet<>(
456
+ Collections.unmodifiableList(Arrays.asList(2))
457
+ );
458
+ final CustomSet<Integer> actual
459
+ = new CustomSet<>(Collections.EMPTY_LIST)
460
+ .getUnion(
461
+ new CustomSet<>(Arrays.asList(2))
462
+ );
463
+
464
+ assertNotNull(actual);
465
+ assertFalse(actual.isEmpty());
466
+ assertTrue(expected.equals(actual));
467
+ }
468
+
469
+ @Test
470
+ @Ignore
471
+ public void unionOfANonEmptySetAndAnEmptySetIsTheNonEmptySet() {
472
+ final CustomSet<Integer> expected
473
+ = new CustomSet<>(
474
+ Collections.unmodifiableList(Arrays.asList(1, 3))
475
+ );
476
+ final CustomSet<Integer> actual
477
+ = new CustomSet<>(Arrays.asList(1, 3))
478
+ .getUnion(
479
+ new CustomSet<>(Collections.EMPTY_LIST)
480
+ );
481
+
482
+ assertNotNull(actual);
483
+ assertFalse(actual.isEmpty());
484
+ assertTrue(expected.equals(actual));
485
+ }
486
+
487
+ @Test
488
+ @Ignore
489
+ public void unionOfTwoNonEmptySetsContainsAllUniqueElements() {
490
+ final CustomSet<Integer> expected
491
+ = new CustomSet<>(
492
+ Collections.unmodifiableList(Arrays.asList(3, 2, 1))
493
+ );
494
+ final CustomSet<Integer> actual
495
+ = new CustomSet<>(Arrays.asList(1, 3))
496
+ .getUnion(
497
+ new CustomSet<>(Arrays.asList(2, 3))
498
+ );
499
+
500
+ assertNotNull(actual);
501
+ assertFalse(actual.isEmpty());
502
+ assertTrue(expected.equals(actual));
503
+ }
504
+
505
+ }