trackler 2.0.3.0 → 2.0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/fixtures/common/exercises/no-metadata/description.md +1 -0
  3. data/lib/trackler/problem.rb +12 -0
  4. data/lib/trackler/problems.rb +8 -12
  5. data/lib/trackler/version.rb +1 -1
  6. data/tracks/bash/README.md +2 -0
  7. data/tracks/c/config.json +9 -2
  8. data/tracks/c/exercises/sieve/makefile +15 -0
  9. data/tracks/c/exercises/sieve/src/example.c +50 -0
  10. data/tracks/c/exercises/sieve/src/sieve.h +10 -0
  11. data/tracks/c/exercises/sieve/test/test_sieve.c +113 -0
  12. data/tracks/c/exercises/sieve/test/vendor/unity.c +1300 -0
  13. data/tracks/c/exercises/sieve/test/vendor/unity.h +274 -0
  14. data/tracks/c/exercises/sieve/test/vendor/unity_internals.h +701 -0
  15. data/tracks/coffeescript/.travis.yml +1 -0
  16. data/tracks/coldfusion/.travis.yml +1 -0
  17. data/tracks/crystal/Makefile +18 -15
  18. data/tracks/crystal/README.md +5 -5
  19. data/tracks/crystal/config.json +6 -0
  20. data/tracks/crystal/exercises/acronym/src/acronym.cr +1 -0
  21. data/tracks/crystal/exercises/anagram/src/anagram.cr +1 -0
  22. data/tracks/crystal/exercises/atbash-cipher/src/atbash_cipher.cr +1 -0
  23. data/tracks/crystal/exercises/binary/src/binary.cr +1 -0
  24. data/tracks/crystal/exercises/bob/src/bob.cr +1 -0
  25. data/tracks/crystal/exercises/bracket-push/src/bracket_push.cr +1 -0
  26. data/tracks/crystal/exercises/difference-of-squares/spec/difference_of_squares_spec.cr +44 -0
  27. data/tracks/crystal/exercises/difference-of-squares/src/example.cr +15 -0
  28. data/tracks/crystal/exercises/forth/src/forth.cr +1 -0
  29. data/tracks/crystal/exercises/gigasecond/src/gigasecond.cr +1 -0
  30. data/tracks/crystal/exercises/hamming/src/hamming.cr +1 -0
  31. data/tracks/crystal/exercises/hello-world/src/hello_world.cr +1 -0
  32. data/tracks/crystal/exercises/largest-series-product/src/largest_series_product.cr +1 -0
  33. data/tracks/crystal/exercises/leap/src/leap.cr +1 -0
  34. data/tracks/crystal/exercises/pangram/src/pangram.cr +1 -0
  35. data/tracks/crystal/exercises/raindrops/src/raindrops.cr +1 -0
  36. data/tracks/crystal/exercises/react/src/react.cr +1 -0
  37. data/tracks/crystal/exercises/rna-transcription/src/rna_transcription.cr +1 -0
  38. data/tracks/crystal/exercises/roman-numerals/src/roman_numerals.cr +1 -0
  39. data/tracks/crystal/exercises/sieve/src/sieve.cr +1 -0
  40. data/tracks/crystal/src/generator/exercises/difference_of_squares.cr +39 -0
  41. data/tracks/go/exercises/allergies/allergies_test.go +2 -2
  42. data/tracks/go/exercises/anagram/anagram_test.go +3 -3
  43. data/tracks/go/exercises/grade-school/grade_school_test.go +3 -3
  44. data/tracks/go/exercises/secret-handshake/secret_handshake_test.go +1 -1
  45. data/tracks/java/config.json +13 -1
  46. data/tracks/java/exercises/binary-search-tree/build.gradle +18 -0
  47. data/tracks/java/exercises/binary-search-tree/src/example/java/BST.java +122 -0
  48. data/tracks/java/exercises/binary-search-tree/src/main/java/.keep +0 -0
  49. data/tracks/java/exercises/binary-search-tree/src/test/java/.keep +0 -0
  50. data/tracks/java/exercises/binary-search-tree/src/test/java/BSTTest.java +163 -0
  51. data/tracks/java/exercises/pythagorean-triplet/build.gradle +18 -0
  52. data/tracks/java/exercises/pythagorean-triplet/src/example/java/PythagoreanTriplet.java +117 -0
  53. data/tracks/java/exercises/pythagorean-triplet/src/main/java/PythagoreanTriplet.java +3 -0
  54. data/tracks/java/exercises/pythagorean-triplet/src/test/java/PythagoreanTripletTest.java +95 -0
  55. data/tracks/java/exercises/settings.gradle +2 -0
  56. data/tracks/julia/README.md +16 -0
  57. data/tracks/perl5/README.md +2 -0
  58. data/tracks/perl6/README.md +2 -1
  59. data/tracks/php/config.json +5 -0
  60. data/tracks/php/exercises/sieve/example.php +29 -0
  61. data/tracks/php/exercises/sieve/sieve_test.php +201 -0
  62. data/tracks/pony/.travis.yml +1 -0
  63. data/tracks/python/exercises/anagram/anagram_test.py +1 -0
  64. data/tracks/python/exercises/beer-song/beer_song_test.py +1 -0
  65. data/tracks/python/exercises/binary-search/binary_search_test.py +1 -0
  66. data/tracks/python/exercises/binary/binary_test.py +1 -0
  67. data/tracks/python/exercises/bob/bob_test.py +1 -0
  68. data/tracks/python/exercises/clock/clock_test.py +1 -0
  69. data/tracks/python/exercises/etl/etl_test.py +1 -0
  70. data/tracks/python/exercises/gigasecond/gigasecond_test.py +1 -0
  71. data/tracks/python/exercises/grains/grains_test.py +1 -0
  72. data/tracks/python/exercises/leap/leap_test.py +1 -0
  73. data/tracks/python/exercises/meetup/meetup_test.py +1 -0
  74. data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +1 -0
  75. data/tracks/python/exercises/ocr-numbers/example.py +1 -0
  76. data/tracks/python/exercises/ocr-numbers/ocr_test.py +1 -0
  77. data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +1 -0
  78. data/tracks/python/exercises/phone-number/phone_number_test.py +1 -0
  79. data/tracks/python/exercises/pig-latin/pig_latin_test.py +1 -0
  80. data/tracks/python/exercises/point-mutations/point_mutations_test.py +1 -0
  81. data/tracks/python/exercises/poker/poker_test.py +1 -0
  82. data/tracks/python/exercises/prime-factors/prime_factors_test.py +1 -0
  83. data/tracks/python/exercises/pythagorean-triplet/example.py +2 -3
  84. data/tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py +1 -0
  85. data/tracks/python/exercises/raindrops/raindrops_test.py +1 -0
  86. data/tracks/python/exercises/rectangles/rectangles_count_test.py +1 -0
  87. data/tracks/python/exercises/robot-simulator/robot_simulator_test.py +1 -0
  88. data/tracks/python/exercises/roman-numerals/roman_numerals_test.py +1 -0
  89. data/tracks/python/exercises/run-length-encoding/run_length_test.py +1 -0
  90. data/tracks/python/exercises/say/say_test.py +1 -0
  91. data/tracks/python/exercises/scrabble-score/scrabble_score_test.py +1 -0
  92. data/tracks/python/exercises/sieve/sieve_test.py +1 -0
  93. data/tracks/python/exercises/space-age/space_age_test.py +1 -0
  94. data/tracks/python/exercises/triangle/triangle_test.py +1 -0
  95. data/tracks/python/exercises/word-count/word_count_test.py +1 -0
  96. data/tracks/python/requirements-travis.txt +1 -1
  97. data/tracks/ruby/docs/24pullrequests.md +21 -0
  98. data/tracks/ruby/exercises/bowling/.version +1 -1
  99. data/tracks/ruby/exercises/bowling/bowling_test.rb +44 -15
  100. data/tracks/ruby/exercises/bowling/example.rb +10 -5
  101. data/tracks/ruby/exercises/bowling/example.tt +4 -2
  102. data/tracks/ruby/lib/bowling_cases.rb +1 -1
  103. data/tracks/scala/exercises/bank-account/HINTS.md +11 -0
  104. data/tracks/scala/exercises/bank-account/example.scala +2 -4
  105. data/tracks/scala/exercises/bank-account/src/main/scala/BankAccount.scala +13 -0
  106. data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +5 -5
  107. data/tracks/scala/exercises/hamming/HINTS.md +57 -0
  108. data/tracks/scala/exercises/hello-world/HINTS.md +8 -0
  109. data/tracks/scala/exercises/nucleotide-count/HINTS.md +61 -0
  110. metadata +48 -2
@@ -0,0 +1,163 @@
1
+
2
+ import java.util.Arrays;
3
+ import java.util.Collections;
4
+ import java.util.List;
5
+ import static org.junit.Assert.assertEquals;
6
+ import static org.junit.Assert.assertNotNull;
7
+ import org.junit.Ignore;
8
+ import org.junit.Test;
9
+
10
+ public class BSTTest {
11
+
12
+ @Test
13
+ public void dataIsRetained() {
14
+ BST<Integer> sut = new BST();
15
+ final int actual = 4;
16
+ sut.insert(actual);
17
+ final BST.Node<Integer> root = sut.getRoot();
18
+ assertNotNull(root);
19
+ final int expected = root.getData();
20
+ assertEquals(expected, actual);
21
+ }
22
+
23
+ @Test
24
+ @Ignore
25
+ public void insertsLess() {
26
+ BST<Integer> sut = new BST();
27
+ final int expectedRoot = 4;
28
+ final int expectedLeft = 2;
29
+
30
+ sut.insert(expectedRoot);
31
+ sut.insert(expectedLeft);
32
+
33
+ final BST.Node<Integer> root = sut.getRoot();
34
+ assertNotNull(root);
35
+ final BST.Node<Integer> left = root.getLeft();
36
+ assertNotNull(left);
37
+
38
+ final int actualRoot = root.getData();
39
+ final int actualLeft = left.getData();
40
+ assertEquals(expectedLeft, actualLeft);
41
+ assertEquals(expectedRoot, actualRoot);
42
+ }
43
+
44
+ @Test
45
+ @Ignore
46
+ public void insertsSame() {
47
+ BST<Integer> sut = new BST();
48
+ final int expectedRoot = 4;
49
+ final int expectedLeft = 4;
50
+
51
+ sut.insert(expectedRoot);
52
+ sut.insert(expectedLeft);
53
+
54
+ final BST.Node<Integer> root = sut.getRoot();
55
+ assertNotNull(root);
56
+ final BST.Node<Integer> left = root.getLeft();
57
+ assertNotNull(left);
58
+
59
+ final int actualRoot = root.getData();
60
+ final int actualLeft = left.getData();
61
+ assertEquals(expectedLeft, actualLeft);
62
+ assertEquals(expectedRoot, actualRoot);
63
+ }
64
+
65
+ @Test
66
+ @Ignore
67
+ public void insertsRight() {
68
+ BST<Integer> sut = new BST();
69
+ final int expectedRoot = 4;
70
+ final int expectedRight = 5;
71
+
72
+ sut.insert(expectedRoot);
73
+ sut.insert(expectedRight);
74
+
75
+ final BST.Node<Integer> root = sut.getRoot();
76
+ assertNotNull(root);
77
+ final BST.Node<Integer> right = root.getRight();
78
+ assertNotNull(right);
79
+
80
+ final int actualRoot = root.getData();
81
+ final int actualRight = right.getData();
82
+ assertEquals(expectedRight, actualRight);
83
+ assertEquals(expectedRoot, actualRoot);
84
+ }
85
+
86
+ @Test
87
+ @Ignore
88
+ public void createsComplexTree() {
89
+ BST<Integer> sut = new BST<>();
90
+ List<Integer> expected = Collections.unmodifiableList(
91
+ Arrays.asList(4, 2, 6, 1, 3, 5, 7)
92
+ );
93
+
94
+ List<Integer> treeData = Collections.unmodifiableList(
95
+ Arrays.asList(4, 2, 6, 1, 3, 7, 5)
96
+ );
97
+ treeData.forEach(value -> sut.insert(value));
98
+
99
+ List<Integer> actual = sut.getAsLevelOrderList();
100
+ assertEquals(expected, actual);
101
+ }
102
+
103
+ @Test
104
+ @Ignore
105
+ public void sortsSingleElement() {
106
+ BST<Integer> sut = new BST<>();
107
+ List<Integer> expected = Collections.unmodifiableList(
108
+ Arrays.asList(4)
109
+ );
110
+
111
+ sut.insert(4);
112
+
113
+ List<Integer> actual = sut.getAsSortedList();
114
+ assertEquals(expected, actual);
115
+ }
116
+
117
+ @Test
118
+ @Ignore
119
+ public void sortsCollectionOfTwoIfSecondInsertedIsSmallerThanFirst() {
120
+ BST<Integer> sut = new BST<>();
121
+ List<Integer> expected = Collections.unmodifiableList(
122
+ Arrays.asList(2, 4)
123
+ );
124
+
125
+ sut.insert(4);
126
+ sut.insert(2);
127
+
128
+ List<Integer> actual = sut.getAsSortedList();
129
+ assertEquals(expected, actual);
130
+ }
131
+
132
+ @Test
133
+ @Ignore
134
+ public void sortsCollectionOfTwoIfSecondInsertedIsBiggerThanFirst() {
135
+ BST<Integer> sut = new BST<>();
136
+ List<Integer> expected = Collections.unmodifiableList(
137
+ Arrays.asList(4, 5)
138
+ );
139
+
140
+ sut.insert(4);
141
+ sut.insert(5);
142
+
143
+ List<Integer> actual = sut.getAsSortedList();
144
+ assertEquals(expected, actual);
145
+ }
146
+
147
+ @Test
148
+ @Ignore
149
+ public void iteratesOverComplexTree() {
150
+ BST<Integer> sut = new BST<>();
151
+ List<Integer> expected = Collections.unmodifiableList(
152
+ Arrays.asList(1, 2, 3, 4, 5, 6, 7)
153
+ );
154
+
155
+ List<Integer> treeData = Collections.unmodifiableList(
156
+ Arrays.asList(4, 2, 1, 3, 6, 7, 5)
157
+ );
158
+ treeData.forEach(value -> sut.insert(value));
159
+
160
+ List<Integer> actual = sut.getAsSortedList();
161
+ assertEquals(expected, actual);
162
+ }
163
+ }
@@ -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,117 @@
1
+
2
+ import java.util.ArrayList;
3
+ import java.util.List;
4
+ import java.util.Objects;
5
+ import java.util.stream.Collectors;
6
+
7
+ public class PythagoreanTriplet {
8
+
9
+ private int a;
10
+ private int b;
11
+ private int c;
12
+
13
+ public PythagoreanTriplet(final int a, final int b, final int c) {
14
+ this.a = a;
15
+ this.b = b;
16
+ this.c = c;
17
+ }
18
+
19
+ public static TripletListBuilder makeTripletsList() {
20
+ return new TripletListBuilder();
21
+ }
22
+
23
+ public int calculateSum() {
24
+ return this.a + this.b + this.c;
25
+ }
26
+
27
+ public long calculateProduct() {
28
+ return this.a * this.b * this.c;
29
+ }
30
+
31
+ public boolean isPythagorean() {
32
+ return this.a * this.a + this.b * this.b == this.c * this.c;
33
+ }
34
+
35
+ @Override
36
+ public int hashCode() {
37
+ return Objects.hash(a, b, c);
38
+ }
39
+
40
+ @Override
41
+ public boolean equals(Object obj) {
42
+ if (this == obj) {
43
+ return true;
44
+ }
45
+ if (obj == null) {
46
+ return false;
47
+ }
48
+ if (getClass() != obj.getClass()) {
49
+ return false;
50
+ }
51
+ final PythagoreanTriplet other = (PythagoreanTriplet) obj;
52
+ if (this.a != other.a) {
53
+ return false;
54
+ }
55
+ if (this.b != other.b) {
56
+ return false;
57
+ }
58
+ if (this.c != other.c) {
59
+ return false;
60
+ }
61
+ return true;
62
+ }
63
+
64
+ public static class TripletListBuilder {
65
+
66
+ private static final int MAX_FACTOR_DEFAULT_VALUE = 0;
67
+ private static final int SUM_DEFAULT_VALUE = -1;
68
+
69
+ private int maxFactor = MAX_FACTOR_DEFAULT_VALUE;
70
+ private int minFactor = 1;
71
+ private int sum = SUM_DEFAULT_VALUE;
72
+
73
+ public TripletListBuilder() {
74
+ }
75
+
76
+ public TripletListBuilder withFactorsLessThanOrEqualTo(
77
+ final int maxFactor) {
78
+ this.maxFactor = maxFactor;
79
+ return this;
80
+ }
81
+
82
+ public TripletListBuilder withFactorsGreaterThanOrEqualTo(
83
+ final int minFactor) {
84
+ this.minFactor = minFactor;
85
+ return this;
86
+ }
87
+
88
+ public TripletListBuilder thatSumTo(final int sum) {
89
+ this.sum = sum;
90
+ return this;
91
+ }
92
+
93
+ public List<PythagoreanTriplet> build() {
94
+ List<PythagoreanTriplet> triplets = new ArrayList<>();
95
+ if (this.maxFactor == MAX_FACTOR_DEFAULT_VALUE) {
96
+ return triplets;
97
+ }
98
+ double sqrt;
99
+ int floor;
100
+ for (int n = minFactor; n < maxFactor; n++) {
101
+ for (int m = n + 1; m < maxFactor; m++) {
102
+ sqrt = Math.sqrt(n * n + m * m);
103
+ floor = (int) Math.floor(sqrt);
104
+ if (sqrt == floor) {
105
+ triplets.add(new PythagoreanTriplet(m, n, floor));
106
+ }
107
+ }
108
+ }
109
+ if (sum != SUM_DEFAULT_VALUE) {
110
+ return triplets.stream()
111
+ .filter(t -> t.calculateSum() == sum)
112
+ .collect(Collectors.toList());
113
+ }
114
+ return triplets;
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,3 @@
1
+
2
+ public class PythagoreanTriplet {
3
+ }
@@ -0,0 +1,95 @@
1
+
2
+ import java.util.Arrays;
3
+ import java.util.HashMap;
4
+ import java.util.List;
5
+ import java.util.Map;
6
+ import java.util.stream.Collectors;
7
+ import static org.junit.Assert.assertEquals;
8
+ import static org.junit.Assert.assertFalse;
9
+ import static org.junit.Assert.assertTrue;
10
+ import org.junit.Test;
11
+ import org.junit.Ignore;
12
+
13
+ public class PythagoreanTripletTest {
14
+
15
+ @Test
16
+ public void shouldCalculateSum() {
17
+ PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
18
+ final int expected = 12;
19
+ final int actual = sut.calculateSum();
20
+ assertEquals(expected, actual);
21
+ }
22
+
23
+ @Test
24
+ @Ignore
25
+ public void shouldCalculateProduct() {
26
+ PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
27
+ final long expected = 60l;
28
+ final long actual = sut.calculateProduct();
29
+ assertEquals(expected, actual);
30
+ }
31
+
32
+ @Test
33
+ @Ignore
34
+ public void testIsPythagoreanOK() {
35
+ PythagoreanTriplet sut = new PythagoreanTriplet(3, 4, 5);
36
+ assertTrue(sut.isPythagorean());
37
+ }
38
+
39
+ @Test
40
+ @Ignore
41
+ public void testIsPythagoreanFail() {
42
+ PythagoreanTriplet sut = new PythagoreanTriplet(5, 6, 7);
43
+ assertFalse(sut.isPythagorean());
44
+ }
45
+
46
+ @Test
47
+ @Ignore
48
+ public void shouldMakeTripletsUpToTen() {
49
+ final List<Long> actual
50
+ = PythagoreanTriplet
51
+ .makeTripletsList()
52
+ .withFactorsLessThanOrEqualTo(10)
53
+ .build()
54
+ .stream()
55
+ .map(t -> t.calculateProduct())
56
+ .sorted()
57
+ .collect(Collectors.toList());
58
+ final List<Long> expected = Arrays.asList(60l, 480l);
59
+ assertEquals(expected, actual);
60
+ }
61
+
62
+ @Test
63
+ @Ignore
64
+ public void shouldMakeTripletsElevenToTwenty() {
65
+ final List<Long> actual
66
+ = PythagoreanTriplet
67
+ .makeTripletsList()
68
+ .withFactorsGreaterThanOrEqualTo(11)
69
+ .withFactorsLessThanOrEqualTo(20)
70
+ .build()
71
+ .stream()
72
+ .map(t -> t.calculateProduct())
73
+ .sorted((p1, p2) -> Double.compare(p1, p2))
74
+ .collect(Collectors.toList());
75
+ final List<Long> expected = Arrays.asList(3840l);
76
+ assertEquals(expected, actual);
77
+ }
78
+
79
+ @Test
80
+ @Ignore
81
+ public void shouldMakeTripletsAndFilterOnSum() {
82
+ final List<Long> actual
83
+ = PythagoreanTriplet
84
+ .makeTripletsList()
85
+ .withFactorsLessThanOrEqualTo(100)
86
+ .thatSumTo(180)
87
+ .build()
88
+ .stream()
89
+ .map(t -> t.calculateProduct())
90
+ .sorted((p1, p2) -> Double.compare(p1, p2))
91
+ .collect(Collectors.toList());
92
+ final List<Long> expected = Arrays.asList(118080l, 168480l, 202500l);
93
+ assertEquals(expected, actual);
94
+ }
95
+ }
@@ -5,6 +5,7 @@ include 'anagram'
5
5
  include 'atbash-cipher'
6
6
  include 'beer-song'
7
7
  include 'binary'
8
+ include 'binary-search-tree'
8
9
  include 'bob'
9
10
  include 'bracket-push'
10
11
  include 'crypto-square'
@@ -34,6 +35,7 @@ include 'robot-name'
34
35
  include 'robot-simulator'
35
36
  include 'roman-numerals'
36
37
  include 'prime-factors'
38
+ include 'pythagorean-triplet'
37
39
  include 'scrabble-score'
38
40
  include 'series'
39
41
  include 'sieve'
@@ -9,3 +9,19 @@ _Document how to contribute to the Julia track._
9
9
  ## Contributing Guide
10
10
 
11
11
  Please see the [contributing guide](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md).
12
+
13
+ ## Working on the Exercises
14
+
15
+ A pool of exercises can be found in the [x-Common repo](https://github.com/exercism/x-common).
16
+
17
+ Exercises for the Julia track go in the `exercises` directory and should follow the following filename conventions:
18
+
19
+ `exercises/<slug>/<slug>.jl` Skeleton for the function that is called by the test suite. Provide (abstract) parameter and return types to ensure compatibility with the test suite.
20
+
21
+ `exercises/<slug>/runtests.jl` Test suite for the exercise. Group related tests using [testsets](http://docs.julialang.org/en/release-0.5/stdlib/test/#working-with-test-sets).
22
+
23
+ `exercises/<slug>/example.jl` Example solution for the exercise. It should follow the [Julia Style Guide](http://docs.julialang.org/en/release-0.5/manual/style-guide/).
24
+
25
+ Replace `<slug>` with the exercise slug of the exercise you're working on.
26
+
27
+ See [Issue #2](https://github.com/exercism/xjulia/issues/2) for discussion on the structure.
@@ -1,5 +1,7 @@
1
1
  # xPerl5
2
2
 
3
+ [![Gitter](https://badges.gitter.im/exercism/xperl.svg)](https://gitter.im/exercism/xperl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
4
+
3
5
  Exercism exercises in Perl 5
4
6
 
5
7
  ## Dependencies