trackler 2.0.6.22 → 2.0.6.23
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.
- checksums.yaml +4 -4
- data/common/exercises/book-store/canonical-data.json +61 -80
- data/common/exercises/etl/canonical-data.json +69 -0
- data/lib/trackler/version.rb +1 -1
- data/tracks/go/config.json +10 -4
- data/tracks/java/config.json +13 -1
- data/tracks/java/exercises/diamond/build.gradle +17 -0
- data/tracks/java/exercises/diamond/src/example/java/DiamondPrinter.java +41 -0
- data/tracks/java/exercises/diamond/src/main/java/DiamondPrinter.java +5 -0
- data/tracks/java/exercises/diamond/src/test/java/DiamondPrinterTest.java +111 -0
- data/tracks/java/exercises/grade-school/src/example/java/School.java +20 -19
- data/tracks/java/exercises/grade-school/src/test/java/SchoolTest.java +53 -20
- data/tracks/java/exercises/secret-handshake/build.gradle +17 -0
- data/tracks/java/exercises/secret-handshake/src/example/java/HandshakeCalculator.java +29 -0
- data/tracks/java/exercises/secret-handshake/src/example/java/Signal.java +1 -0
- data/tracks/java/exercises/secret-handshake/src/main/java/HandshakeCalculator.java +5 -0
- data/tracks/java/exercises/secret-handshake/src/main/java/Signal.java +5 -0
- data/tracks/java/exercises/secret-handshake/src/test/java/HandshakeCalculatorTest.java +106 -0
- data/tracks/java/exercises/settings.gradle +2 -0
- data/tracks/julia/config.json +42 -0
- data/tracks/julia/exercises/bob/bob.jl +3 -0
- data/tracks/julia/exercises/bob/example.jl +30 -0
- data/tracks/julia/exercises/bob/runtests.jl +70 -0
- data/tracks/julia/exercises/difference-of-squares/difference-of-squares.jl +14 -0
- data/tracks/julia/exercises/difference-of-squares/example.jl +9 -0
- data/tracks/julia/exercises/difference-of-squares/runtests.jl +22 -0
- data/tracks/julia/exercises/hamming/example.jl +5 -0
- data/tracks/julia/exercises/hamming/hamming.jl +3 -0
- data/tracks/julia/exercises/hamming/runtests.jl +42 -0
- data/tracks/julia/exercises/hello-world/example.jl +3 -0
- data/tracks/julia/exercises/hello-world/hello-world.jl +3 -0
- data/tracks/julia/exercises/hello-world/runtests.jl +12 -0
- data/tracks/julia/exercises/word-count/example.jl +9 -0
- data/tracks/julia/exercises/word-count/runtests.jl +47 -0
- data/tracks/julia/exercises/word-count/word-count.jl +3 -0
- data/tracks/objective-c/config.json +10 -0
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.h +6 -0
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.m +48 -0
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayTest.m +110 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +33 -0
- data/tracks/ocaml/config.json +5 -0
- data/tracks/ocaml/exercises/pangram/.merlin +3 -0
- data/tracks/ocaml/exercises/pangram/Makefile +11 -0
- data/tracks/ocaml/exercises/pangram/example.ml +9 -0
- data/tracks/ocaml/exercises/pangram/pangram.mli +1 -0
- data/tracks/ocaml/exercises/pangram/test.ml +29 -0
- data/tracks/ocaml/tools/test-generator/templates/pangram/template.ml +15 -0
- data/tracks/pascal/config.json +8 -0
- data/tracks/pascal/docs/INSTALLATION.md +3 -3
- data/tracks/pascal/docs/img/07delphiclicklibrarypathbuttonLogo.png +0 -0
- data/tracks/pascal/exercises/grains/GrainsTests.dpr +60 -0
- data/tracks/pascal/exercises/grains/uGrainsExample.pas +33 -0
- data/tracks/pascal/exercises/grains/uGrainsTests.pas +149 -0
- data/tracks/perl6/SETUP.md +8 -2
- metadata +41 -2
@@ -1,38 +1,39 @@
|
|
1
|
-
import java.util
|
2
|
-
import java.util.HashMap;
|
3
|
-
import java.util.List;
|
4
|
-
import java.util.Map;
|
5
|
-
import java.util.Set;
|
6
|
-
import java.util.TreeSet;
|
1
|
+
import java.util.*;
|
7
2
|
|
8
3
|
public class School {
|
9
4
|
|
10
|
-
private final Map<Integer,
|
5
|
+
private final Map<Integer, List<String>> database = new HashMap<>();
|
11
6
|
|
12
|
-
public
|
13
|
-
|
14
|
-
|
7
|
+
public int numberOfStudents() {
|
8
|
+
int result = 0;
|
9
|
+
for (List<String> studentsInGrade: database.values()) {
|
10
|
+
result += studentsInGrade.size();
|
11
|
+
}
|
12
|
+
return result;
|
15
13
|
}
|
16
14
|
|
17
15
|
public void add(String student, int grade) {
|
18
|
-
|
16
|
+
List<String> students = fetchGradeFromDatabase(grade);
|
19
17
|
students.add(student);
|
20
18
|
}
|
21
19
|
|
22
|
-
public
|
23
|
-
|
20
|
+
public List<String> grade(int grade) {
|
21
|
+
return new ArrayList<>(fetchGradeFromDatabase(grade));
|
22
|
+
}
|
23
|
+
|
24
|
+
private List<String> fetchGradeFromDatabase(int grade) {
|
24
25
|
if (!database.containsKey(grade)) {
|
25
|
-
database.put(grade, new
|
26
|
+
database.put(grade, new LinkedList<>());
|
26
27
|
}
|
27
28
|
return database.get(grade);
|
28
29
|
}
|
29
30
|
|
30
|
-
public Map<Integer, List<String>>
|
31
|
-
Map<Integer, List<String>> sortedStudents = new HashMap
|
31
|
+
public Map<Integer, List<String>> studentsByGradeAlphabetical() {
|
32
|
+
Map<Integer, List<String>> sortedStudents = new HashMap<>();
|
32
33
|
for (Integer grade : database.keySet()) {
|
33
|
-
|
34
|
-
|
35
|
-
sortedStudents.put(grade,
|
34
|
+
List<String> studentsInGrade = database.get(grade);
|
35
|
+
Collections.sort(studentsInGrade);
|
36
|
+
sortedStudents.put(grade, studentsInGrade);
|
36
37
|
}
|
37
38
|
return sortedStudents;
|
38
39
|
}
|
@@ -1,28 +1,32 @@
|
|
1
1
|
import org.junit.Ignore;
|
2
2
|
import org.junit.Test;
|
3
3
|
|
4
|
+
import java.lang.Integer;
|
5
|
+
import java.util.*;
|
6
|
+
import java.util.ArrayList;
|
4
7
|
import java.util.Arrays;
|
5
8
|
import java.util.HashMap;
|
6
9
|
import java.util.List;
|
7
10
|
import java.util.Map;
|
8
11
|
|
9
12
|
import static org.hamcrest.CoreMatchers.*;
|
10
|
-
import static org.junit.Assert
|
13
|
+
import static org.junit.Assert.assertThat;
|
14
|
+
import static org.junit.Assert.assertTrue;
|
15
|
+
import static org.junit.Assert.assertEquals;
|
11
16
|
|
12
17
|
public class SchoolTest {
|
13
18
|
private final School school = new School();
|
14
19
|
|
15
|
-
|
16
20
|
@Test
|
17
21
|
public void startsWithNoStudents() {
|
18
|
-
|
22
|
+
assertThat(school.numberOfStudents(), is(0));
|
19
23
|
}
|
20
24
|
|
21
25
|
@Ignore
|
22
26
|
@Test
|
23
27
|
public void addsStudents() {
|
24
28
|
school.add("Aimee", 2);
|
25
|
-
assertThat(school.
|
29
|
+
assertThat(school.grade(2), hasItem("Aimee"));
|
26
30
|
}
|
27
31
|
|
28
32
|
@Ignore
|
@@ -33,8 +37,8 @@ public class SchoolTest {
|
|
33
37
|
school.add("Blair", grade);
|
34
38
|
school.add("Paul", grade);
|
35
39
|
|
36
|
-
assertThat(school.
|
37
|
-
assertThat(school.
|
40
|
+
assertThat(school.grade(grade).size(), is(3));
|
41
|
+
assertThat(school.grade(grade), allOf(hasItem("James"), hasItem("Blair"), hasItem("Paul")));
|
38
42
|
}
|
39
43
|
|
40
44
|
@Ignore
|
@@ -43,27 +47,30 @@ public class SchoolTest {
|
|
43
47
|
school.add("Chelsea", 3);
|
44
48
|
school.add("Logan", 7);
|
45
49
|
|
46
|
-
assertThat(school.
|
47
|
-
assertThat(school.
|
48
|
-
assertThat(school.
|
49
|
-
assertThat(school.
|
50
|
-
assertThat(school.
|
50
|
+
assertThat(school.numberOfStudents(), is(2));
|
51
|
+
assertThat(school.grade(3).size(), is(1));
|
52
|
+
assertThat(school.grade(3), hasItem("Chelsea"));
|
53
|
+
assertThat(school.grade(7).size(), is(1));
|
54
|
+
assertThat(school.grade(7), hasItem("Logan"));
|
51
55
|
}
|
52
56
|
|
53
57
|
@Ignore
|
54
58
|
@Test
|
55
|
-
public void
|
56
|
-
school.
|
57
|
-
school.add("Bradley", 5);
|
58
|
-
school.add("Jeff", 1);
|
59
|
-
assertThat(school.grade(5).size(), is(2));
|
60
|
-
assertThat(school.grade(5), allOf(hasItem("Franklin"), hasItem("Bradley")));
|
59
|
+
public void getsStudentsInEmptyGrade() {
|
60
|
+
assertTrue(school.grade(1).isEmpty());
|
61
61
|
}
|
62
62
|
|
63
63
|
@Ignore
|
64
64
|
@Test
|
65
|
-
public void
|
66
|
-
|
65
|
+
public void gradeReturnsStudentsInTheOrderTheyWereInserted() {
|
66
|
+
int grade = 4;
|
67
|
+
school.add("Bartimaeus", grade);
|
68
|
+
school.add("Nathaniel", grade);
|
69
|
+
school.add("Faquarl", grade);
|
70
|
+
List<String> studentsInGrade = school.grade(grade);
|
71
|
+
assertThat(studentsInGrade.get(0), is("Bartimaeus"));
|
72
|
+
assertThat(studentsInGrade.get(1), is("Nathaniel"));
|
73
|
+
assertThat(studentsInGrade.get(2), is("Faquarl"));
|
67
74
|
}
|
68
75
|
|
69
76
|
@Ignore
|
@@ -77,6 +84,32 @@ public class SchoolTest {
|
|
77
84
|
sortedStudents.put(6, Arrays.asList("Kareem"));
|
78
85
|
sortedStudents.put(4, Arrays.asList("Christopher", "Jennifer"));
|
79
86
|
sortedStudents.put(3, Arrays.asList("Kyle"));
|
80
|
-
assertEquals(school.
|
87
|
+
assertEquals(school.studentsByGradeAlphabetical(), sortedStudents);
|
88
|
+
}
|
89
|
+
|
90
|
+
@Ignore
|
91
|
+
@Test
|
92
|
+
public void modifyingFetchedGradeShouldNotModifyInternalDatabase() {
|
93
|
+
String shouldNotBeAdded = "Should not be added to school";
|
94
|
+
int grade = 1;
|
95
|
+
|
96
|
+
List<String> students = school.grade(grade);
|
97
|
+
students.add(shouldNotBeAdded);
|
98
|
+
|
99
|
+
assertThat(school.grade(grade), not(hasItem(shouldNotBeAdded)));
|
100
|
+
}
|
101
|
+
|
102
|
+
@Ignore
|
103
|
+
@Test
|
104
|
+
public void modifyingSortedStudentsShouldNotModifyInternalDatabase() {
|
105
|
+
int grade = 2;
|
106
|
+
String studentWhichShouldNotBeAdded = "Should not be added";
|
107
|
+
List<String> listWhichShouldNotBeAdded = new ArrayList<>();
|
108
|
+
listWhichShouldNotBeAdded.add(studentWhichShouldNotBeAdded);
|
109
|
+
|
110
|
+
Map<Integer, List<String>> sortedStudents = school.studentsByGradeAlphabetical();
|
111
|
+
sortedStudents.put(grade,listWhichShouldNotBeAdded);
|
112
|
+
|
113
|
+
assertThat(school.studentsByGradeAlphabetical().get(grade), not(hasItem(studentWhichShouldNotBeAdded)));
|
81
114
|
}
|
82
115
|
}
|
@@ -0,0 +1,17 @@
|
|
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
|
+
test {
|
13
|
+
testLogging {
|
14
|
+
exceptionFormat = 'full'
|
15
|
+
events = ["passed", "failed", "skipped"]
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import java.util.ArrayList;
|
2
|
+
import java.util.Collections;
|
3
|
+
import java.util.List;
|
4
|
+
|
5
|
+
final class HandshakeCalculator {
|
6
|
+
|
7
|
+
private static final int REVERSE_SIGNALS_BIT_POSITION = 4;
|
8
|
+
|
9
|
+
List<Signal> calculateHandshake(final int number) {
|
10
|
+
final List<Signal> result = new ArrayList<>();
|
11
|
+
|
12
|
+
for (final Signal signal : Signal.values()) {
|
13
|
+
if (isBitSet(signal.ordinal(), number)) {
|
14
|
+
result.add(signal);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
if (isBitSet(REVERSE_SIGNALS_BIT_POSITION, number)) {
|
19
|
+
Collections.reverse(result);
|
20
|
+
}
|
21
|
+
|
22
|
+
return result;
|
23
|
+
}
|
24
|
+
|
25
|
+
private boolean isBitSet(final int position, final int number) {
|
26
|
+
return ((number >> position) & 1) == 1;
|
27
|
+
}
|
28
|
+
|
29
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
tracks/java/exercises/secret-handshake/src/example/java/../../main/java/Signal.java
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import org.junit.Ignore;
|
2
|
+
import org.junit.Test;
|
3
|
+
|
4
|
+
import static java.util.Arrays.asList;
|
5
|
+
import static java.util.Collections.emptyList;
|
6
|
+
import static java.util.Collections.singletonList;
|
7
|
+
import static org.junit.Assert.assertEquals;
|
8
|
+
|
9
|
+
public final class HandshakeCalculatorTest {
|
10
|
+
|
11
|
+
@Test
|
12
|
+
public void testThatInput1YieldsAWink() {
|
13
|
+
assertEquals(
|
14
|
+
singletonList(Signal.WINK),
|
15
|
+
new HandshakeCalculator().calculateHandshake(1));
|
16
|
+
}
|
17
|
+
|
18
|
+
@Ignore
|
19
|
+
@Test
|
20
|
+
public void testThatInput2YieldsADoubleBlink() {
|
21
|
+
assertEquals(
|
22
|
+
singletonList(Signal.DOUBLE_BLINK),
|
23
|
+
new HandshakeCalculator().calculateHandshake(2));
|
24
|
+
}
|
25
|
+
|
26
|
+
@Ignore
|
27
|
+
@Test
|
28
|
+
public void testThatInput4YieldsACloseYourEyes() {
|
29
|
+
assertEquals(
|
30
|
+
singletonList(Signal.CLOSE_YOUR_EYES),
|
31
|
+
new HandshakeCalculator().calculateHandshake(4));
|
32
|
+
}
|
33
|
+
|
34
|
+
@Ignore
|
35
|
+
@Test
|
36
|
+
public void testThatInput8YieldsAJump() {
|
37
|
+
assertEquals(
|
38
|
+
singletonList(Signal.JUMP),
|
39
|
+
new HandshakeCalculator().calculateHandshake(8));
|
40
|
+
}
|
41
|
+
|
42
|
+
@Ignore
|
43
|
+
@Test
|
44
|
+
public void testAnInputThatYieldsTwoActions() {
|
45
|
+
assertEquals(
|
46
|
+
asList(Signal.WINK, Signal.DOUBLE_BLINK),
|
47
|
+
new HandshakeCalculator().calculateHandshake(3));
|
48
|
+
}
|
49
|
+
|
50
|
+
@Ignore
|
51
|
+
@Test
|
52
|
+
public void testAnInputThatYieldsTwoReversedActions() {
|
53
|
+
assertEquals(
|
54
|
+
asList(Signal.DOUBLE_BLINK, Signal.WINK),
|
55
|
+
new HandshakeCalculator().calculateHandshake(19));
|
56
|
+
}
|
57
|
+
|
58
|
+
@Ignore
|
59
|
+
@Test
|
60
|
+
public void testReversingASingleActionYieldsTheSameAction() {
|
61
|
+
assertEquals(
|
62
|
+
singletonList(Signal.JUMP),
|
63
|
+
new HandshakeCalculator().calculateHandshake(24));
|
64
|
+
}
|
65
|
+
|
66
|
+
@Ignore
|
67
|
+
@Test
|
68
|
+
public void testReversingNoActionsYieldsNoActions() {
|
69
|
+
assertEquals(
|
70
|
+
emptyList(),
|
71
|
+
new HandshakeCalculator().calculateHandshake(16));
|
72
|
+
}
|
73
|
+
|
74
|
+
@Ignore
|
75
|
+
@Test
|
76
|
+
public void testInputThatYieldsAllActions() {
|
77
|
+
assertEquals(
|
78
|
+
asList(Signal.WINK, Signal.DOUBLE_BLINK, Signal.CLOSE_YOUR_EYES, Signal.JUMP),
|
79
|
+
new HandshakeCalculator().calculateHandshake(15));
|
80
|
+
}
|
81
|
+
|
82
|
+
@Ignore
|
83
|
+
@Test
|
84
|
+
public void testInputThatYieldsAllActionsReversed() {
|
85
|
+
assertEquals(
|
86
|
+
asList(Signal.JUMP, Signal.CLOSE_YOUR_EYES, Signal.DOUBLE_BLINK, Signal.WINK),
|
87
|
+
new HandshakeCalculator().calculateHandshake(31));
|
88
|
+
}
|
89
|
+
|
90
|
+
@Ignore
|
91
|
+
@Test
|
92
|
+
public void testThatInput0YieldsNoActions() {
|
93
|
+
assertEquals(
|
94
|
+
emptyList(),
|
95
|
+
new HandshakeCalculator().calculateHandshake(0));
|
96
|
+
}
|
97
|
+
|
98
|
+
@Ignore
|
99
|
+
@Test
|
100
|
+
public void testThatInputWithLower5BitsNotSetYieldsNoActions() {
|
101
|
+
assertEquals(
|
102
|
+
emptyList(),
|
103
|
+
new HandshakeCalculator().calculateHandshake(32));
|
104
|
+
}
|
105
|
+
|
106
|
+
}
|
@@ -12,6 +12,7 @@ include 'bob'
|
|
12
12
|
include 'bracket-push'
|
13
13
|
include 'crypto-square'
|
14
14
|
include 'custom-set'
|
15
|
+
include 'diamond'
|
15
16
|
include 'difference-of-squares'
|
16
17
|
include 'etl'
|
17
18
|
include 'gigasecond'
|
@@ -43,6 +44,7 @@ include 'robot-name'
|
|
43
44
|
include 'robot-simulator'
|
44
45
|
include 'roman-numerals'
|
45
46
|
include 'scrabble-score'
|
47
|
+
include 'secret-handshake'
|
46
48
|
include 'series'
|
47
49
|
include 'sieve'
|
48
50
|
include 'simple-cipher'
|
data/tracks/julia/config.json
CHANGED
@@ -5,6 +5,39 @@
|
|
5
5
|
"active": false,
|
6
6
|
"test_pattern": "TODO",
|
7
7
|
"exercises": [
|
8
|
+
{
|
9
|
+
"slug": "hello-world",
|
10
|
+
"difficulty": 1,
|
11
|
+
"topics": [
|
12
|
+
"strings",
|
13
|
+
"string interpolation"
|
14
|
+
]
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"slug": "hamming",
|
18
|
+
"difficulty": 1,
|
19
|
+
"topics": [
|
20
|
+
"generators",
|
21
|
+
"strings",
|
22
|
+
"exceptions"
|
23
|
+
]
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"slug": "difference-of-squares",
|
27
|
+
"difficulty": 1,
|
28
|
+
"topics": [
|
29
|
+
"generators"
|
30
|
+
]
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"slug": "word-count",
|
34
|
+
"difficulty": 1,
|
35
|
+
"topics": [
|
36
|
+
"control-flow (loops)",
|
37
|
+
"arrays",
|
38
|
+
"strings"
|
39
|
+
]
|
40
|
+
},
|
8
41
|
{
|
9
42
|
"slug": "rna-transcription",
|
10
43
|
"difficulty": 1,
|
@@ -34,6 +67,15 @@
|
|
34
67
|
"sorting",
|
35
68
|
"filtering"
|
36
69
|
]
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"slug": "bob",
|
73
|
+
"difficulty": 2,
|
74
|
+
"topics": [
|
75
|
+
"strings",
|
76
|
+
"unicode",
|
77
|
+
"control-flow (if-else statements)"
|
78
|
+
]
|
37
79
|
}
|
38
80
|
],
|
39
81
|
"deprecated": [
|
@@ -0,0 +1,30 @@
|
|
1
|
+
function bob(stimulus::AbstractString)
|
2
|
+
stimulus = strip(stimulus)
|
3
|
+
|
4
|
+
if issilence(stimulus)
|
5
|
+
return "Fine. Be that way!"
|
6
|
+
elseif isshouting(stimulus)
|
7
|
+
return "Whoa, chill out!"
|
8
|
+
elseif isquestion(stimulus)
|
9
|
+
return "Sure."
|
10
|
+
else
|
11
|
+
return "Whatever."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
issilence(stimulus::AbstractString) = isempty(stimulus)
|
16
|
+
isquestion(stimulus::AbstractString) = endswith(stimulus, '?')
|
17
|
+
|
18
|
+
function isshouting(stimulus::AbstractString)
|
19
|
+
isupper(stimulus) && return true
|
20
|
+
!any(isalpha, stimulus) && return false
|
21
|
+
|
22
|
+
for c in stimulus
|
23
|
+
# ignore all non-letter chars
|
24
|
+
if isalpha(c) && !isupper(c)
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
return true
|
30
|
+
end
|