trackler 2.0.6.34 → 2.0.6.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/change/canonical-data.json +6 -0
  3. data/common/exercises/luhn/canonical-data.json +35 -0
  4. data/common/exercises/rotational-cipher/cannonical-data.json +70 -0
  5. data/common/exercises/rotational-cipher/description.md +30 -0
  6. data/common/exercises/rotational-cipher/metadata.yml +4 -0
  7. data/common/exercises/run-length-encoding/description.md +7 -1
  8. data/lib/trackler/version.rb +1 -1
  9. data/tracks/elixir/exercises/run-length-encoding/example.exs +15 -4
  10. data/tracks/elixir/exercises/run-length-encoding/rle.exs +2 -2
  11. data/tracks/elixir/exercises/run-length-encoding/rle_test.exs +28 -11
  12. data/tracks/go/exercises/bob/bob_test.go +4 -1
  13. data/tracks/go/exercises/bracket-push/bracket_push_test.go +5 -2
  14. data/tracks/go/exercises/circular-buffer/circular_buffer_test.go +6 -6
  15. data/tracks/go/exercises/clock/clock_test.go +4 -1
  16. data/tracks/go/exercises/connect/connect_test.go +4 -1
  17. data/tracks/go/exercises/crypto-square/crypto_square_test.go +5 -2
  18. data/tracks/go/exercises/luhn/luhn_test.go +1 -1
  19. data/tracks/javascript/exercises/leap/leap.js +1 -1
  20. data/tracks/julia/.travis.yml +0 -2
  21. data/tracks/julia/config.json +41 -0
  22. data/tracks/julia/exercises/custom-set/HINTS.md +1 -0
  23. data/tracks/julia/exercises/custom-set/custom-set.jl +0 -0
  24. data/tracks/julia/exercises/custom-set/example.jl +51 -0
  25. data/tracks/julia/exercises/custom-set/runtests.jl +200 -0
  26. data/tracks/julia/exercises/isogram/example.jl +11 -0
  27. data/tracks/julia/exercises/isogram/isogram.jl +3 -0
  28. data/tracks/julia/exercises/isogram/runtests.jl +35 -0
  29. data/tracks/julia/exercises/luhn/example.jl +16 -0
  30. data/tracks/julia/exercises/luhn/luhn.jl +0 -0
  31. data/tracks/julia/exercises/luhn/runtests.jl +31 -0
  32. data/tracks/julia/exercises/nucleotide-count/example.jl +8 -0
  33. data/tracks/julia/exercises/nucleotide-count/nucleotide-count.jl +3 -0
  34. data/tracks/julia/exercises/nucleotide-count/runtests.jl +19 -0
  35. data/tracks/kotlin/.travis.yml +9 -1
  36. data/tracks/kotlin/README.md +117 -11
  37. data/tracks/kotlin/bin/journey-test.sh +279 -0
  38. data/tracks/kotlin/docs/INSTALLATION.md +193 -97
  39. data/tracks/kotlin/docs/TESTS.md +72 -137
  40. data/tracks/kotlin/exercises/hello-world/GETTING_STARTED.md +50 -0
  41. data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +693 -0
  42. data/tracks/kotlin/exercises/hello-world/src/example/kotlin/HelloWorld.kt +2 -30
  43. data/tracks/kotlin/exercises/hello-world/src/main/kotlin/HelloWorld.kt +2 -30
  44. data/tracks/kotlin/exercises/hello-world/src/test/kotlin/HelloWorldTest.kt +11 -19
  45. data/tracks/objective-c/circle.yml +1 -1
  46. data/tracks/perl6/exercises/atbash-cipher/{cipher.t → atbash-cipher.t} +0 -0
  47. data/tracks/perl6/exercises/linked-list/linked-list.t +0 -0
  48. data/tracks/perl6/exercises/phone-number/{phone.t → phone-number.t} +0 -0
  49. data/tracks/perl6/exercises/rna-transcription/{rna_transcription.t → rna-transcription.t} +0 -0
  50. data/tracks/perl6/exercises/robot-name/{robot.t → robot-name.t} +0 -0
  51. data/tracks/perl6/exercises/scrabble-score/{scrabble_score.t → scrabble-score.t} +0 -0
  52. data/tracks/perl6/exercises/word-count/{word_count.t → word-count.t} +0 -0
  53. data/tracks/pony/config.json +9 -0
  54. data/tracks/pony/exercises/pascals-triangle/example.pony +18 -0
  55. data/tracks/pony/exercises/pascals-triangle/test.pony +31 -0
  56. data/tracks/r/config.json +20 -0
  57. data/tracks/r/exercises/grains/example.R +16 -0
  58. data/tracks/r/exercises/grains/grains.R +7 -0
  59. data/tracks/r/exercises/grains/test_grains.R +49 -0
  60. data/tracks/r/exercises/phone-number/example.R +30 -0
  61. data/tracks/r/exercises/phone-number/phone-number.R +3 -0
  62. data/tracks/r/exercises/phone-number/test_phone-number.R +44 -0
  63. data/tracks/r/exercises/secret-handshake/example.R +26 -0
  64. data/tracks/r/exercises/secret-handshake/secret-handshake.R +3 -0
  65. data/tracks/r/exercises/secret-handshake/test_secret-handshake.R +52 -0
  66. data/tracks/r/exercises/sieve/example.R +16 -0
  67. data/tracks/r/exercises/sieve/sieve.R +3 -0
  68. data/tracks/r/exercises/sieve/test_sieve.R +37 -0
  69. data/tracks/rust/config.json +11 -0
  70. data/tracks/rust/exercises/rotational-cipher/Cargo.lock +4 -0
  71. data/tracks/rust/exercises/rotational-cipher/Cargo.toml +4 -0
  72. data/tracks/rust/exercises/rotational-cipher/example.rs +16 -0
  73. data/tracks/rust/exercises/rotational-cipher/tests/rotational-cipher.rs +61 -0
  74. data/tracks/swift/circle.yml +6 -0
  75. metadata +46 -8
@@ -35,6 +35,15 @@
35
35
  "generators"
36
36
  ]
37
37
  },
38
+ {
39
+ "slug": "nucleotide-count",
40
+ "difficulty": 1,
41
+ "topics": [
42
+ "chars",
43
+ "strings",
44
+ "control-flow (loops)"
45
+ ]
46
+ },
38
47
  {
39
48
  "slug": "word-count",
40
49
  "difficulty": 1,
@@ -82,6 +91,15 @@
82
91
  "strings"
83
92
  ]
84
93
  },
94
+ {
95
+ "slug": "luhn",
96
+ "difficulty": 1,
97
+ "topics": [
98
+ "strings",
99
+ "arithmetics",
100
+ "control-flow (conditionals)"
101
+ ]
102
+ },
85
103
  {
86
104
  "slug": "roman-numerals",
87
105
  "difficulty": 1,
@@ -91,6 +109,16 @@
91
109
  "mathematics"
92
110
  ]
93
111
  },
112
+ {
113
+ "slug": "isogram",
114
+ "difficulty": 1,
115
+ "topics": [
116
+ "control-flow (loops)",
117
+ "control-flow (conditionals)",
118
+ "arrays",
119
+ "strings"
120
+ ]
121
+ },
94
122
  {
95
123
  "slug": "anagram",
96
124
  "difficulty": 2,
@@ -150,6 +178,19 @@
150
178
  "filtering",
151
179
  "mathematics"
152
180
  ]
181
+ },
182
+ {
183
+ "slug": "custom-set",
184
+ "difficulty": 5,
185
+ "topics": [
186
+ "types",
187
+ "parametric types",
188
+ "methods",
189
+ "multiple dispatch",
190
+ "function extension",
191
+ "mathematics",
192
+ "iterators"
193
+ ]
153
194
  }
154
195
  ],
155
196
  "deprecated": [
@@ -0,0 +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.
File without changes
@@ -0,0 +1,51 @@
1
+ import Base: AbstractSet, isempty, length, in, issubset, start, next, done,
2
+ push!, ==, copy, intersect!, intersect, union!, union
3
+
4
+ type CustomSet{T} <: AbstractSet
5
+ elements::Array{T, 1}
6
+ end
7
+
8
+ isempty(s::CustomSet) = isempty(s.elements)
9
+ length(s::CustomSet) = length(s.elements)
10
+ in(element, s::CustomSet) = in(element, s.elements) # this also defines issubset(::CustomSet, ::CustomSet)
11
+ ==(s1::CustomSet, s2::CustomSet) = issubset(s1, s2) && issubset(s2, s1)
12
+ copy(s::CustomSet) = CustomSet(copy(s.elements))
13
+ push!(s::CustomSet, element) = push!(s.elements, element)
14
+
15
+ # Iterator protocol
16
+ start(::CustomSet) = 1
17
+ next(s::CustomSet, state) = s.elements[state], state + 1
18
+ done(s::CustomSet, state) = state > length(s)
19
+
20
+ function disjoint(s1::CustomSet, s2::CustomSet)
21
+ for element in s1
22
+ element in s2 && return false
23
+ end
24
+ return true
25
+ end
26
+
27
+ function complement!(s1::CustomSet, s2::CustomSet)
28
+ for (i, element) in enumerate(s1)
29
+ element in s2 && deleteat!(s1.elements, i)
30
+ end
31
+ return s1
32
+ end
33
+ complement(s1::CustomSet, s2::CustomSet) = complement!(copy(s1), s2)
34
+
35
+ function intersect!(s1::CustomSet, s2::CustomSet)
36
+ tbd = Int[]
37
+ for (i, element) in enumerate(s1)
38
+ element in s2 || push!(tbd, i)
39
+ end
40
+ deleteat!(s1.elements, tbd)
41
+ return s1
42
+ end
43
+ intersect(s1::CustomSet, s2::CustomSet) = intersect!(copy(s1), s2)
44
+
45
+ function union!(s1::CustomSet, s2::CustomSet)
46
+ for element in s2
47
+ element in s1 || push!(s1, element)
48
+ end
49
+ return s1
50
+ end
51
+ union(s1::CustomSet, s2::CustomSet) = union!(copy(s1), s2)
@@ -0,0 +1,200 @@
1
+ using Base.Test
2
+
3
+ include("custom-set.jl")
4
+
5
+ # canonical data
6
+ @testset "empty" begin
7
+ @test isempty(CustomSet([]))
8
+ @test !isempty(CustomSet([1]))
9
+ end
10
+
11
+ @testset "in (contains)" begin
12
+ @test !(1 in CustomSet([]))
13
+ @test 1 in CustomSet([1, 2, 3])
14
+ @test !(4 in CustomSet([1, 2, 3]))
15
+ end
16
+
17
+ @testset "subset" begin # TODO ⊆, ⊈
18
+ @test issubset(CustomSet([]), CustomSet([]))
19
+ @test issubset(CustomSet([]), CustomSet([1]))
20
+ @test !issubset(CustomSet([1]), CustomSet([]))
21
+ @test issubset(CustomSet([1, 2, 3]), CustomSet([1, 2, 3]))
22
+ @test issubset(CustomSet([1, 2, 3]), CustomSet([4, 1, 2, 3]))
23
+ @test !issubset(CustomSet([1, 2, 3]), CustomSet([4, 1, 3]))
24
+ end
25
+
26
+ @testset "disjoint" begin
27
+ @test disjoint(CustomSet([]), CustomSet([]))
28
+ @test disjoint(CustomSet([]), CustomSet([1]))
29
+ @test disjoint(CustomSet([1]), CustomSet([]))
30
+ @test !disjoint(CustomSet([1, 2]), CustomSet([2, 3]))
31
+ @test disjoint(CustomSet([1, 2]), CustomSet([3, 4]))
32
+ end
33
+
34
+ @testset "equal" begin
35
+ @test CustomSet([]) == CustomSet([])
36
+ @test CustomSet([]) != CustomSet([1, 2, 3])
37
+ @test CustomSet([1, 2, 3]) != CustomSet([])
38
+ @test CustomSet([1, 2]) == CustomSet([2, 1])
39
+ @test CustomSet([1, 2, 3]) != CustomSet([1, 2, 4])
40
+ end
41
+
42
+ @testset "add" begin
43
+ @test begin
44
+ custom_set = CustomSet([])
45
+ push!(custom_set, 3)
46
+ custom_set == CustomSet([3])
47
+ end
48
+ @test begin
49
+ custom_set = CustomSet([1, 2, 4])
50
+ push!(custom_set, 3)
51
+ custom_set == CustomSet([1, 2, 3, 4])
52
+ end
53
+ @test begin
54
+ custom_set = CustomSet([1, 2, 3])
55
+ push!(custom_set, 3)
56
+ custom_set == CustomSet([1, 2, 3])
57
+ end
58
+ end
59
+
60
+ @testset "intersection" begin
61
+ @testset "in-place" begin
62
+ @test begin
63
+ cs1 = CustomSet([])
64
+ cs2 = CustomSet([])
65
+ intersect!(cs1, cs2)
66
+ isempty(cs1)
67
+ end
68
+ @test begin
69
+ cs1 = CustomSet([])
70
+ cs2 = CustomSet([3, 2, 5])
71
+ intersect!(cs1, cs2)
72
+ isempty(cs1)
73
+ end
74
+ @test begin
75
+ cs1 = CustomSet([1, 2, 3, 4])
76
+ cs2 = CustomSet([])
77
+ intersect!(cs1, cs2)
78
+ isempty(cs1)
79
+ end
80
+ @test begin
81
+ cs1 = CustomSet([1, 2, 3])
82
+ cs2 = CustomSet([4, 5, 6])
83
+ intersect!(cs1, cs2)
84
+ isempty(cs1)
85
+ end
86
+ @test begin
87
+ cs1 = CustomSet([1, 2, 3, 4])
88
+ cs2 = CustomSet([3, 2, 5])
89
+ intersect!(cs1, cs2)
90
+ cs1 == CustomSet([2, 3])
91
+ end
92
+ end
93
+ @testset "not in-place" begin # TODO use operator ∩
94
+ @test isempty(intersect(CustomSet([]), CustomSet([])))
95
+ @test isempty(intersect(CustomSet([]), CustomSet([3, 2, 5])))
96
+ @test isempty(intersect(CustomSet([1, 2, 3, 4]), CustomSet([])))
97
+ @test isempty(intersect(CustomSet([1, 2, 3]), CustomSet([4, 5, 6])))
98
+ @test intersect(CustomSet([1, 2, 3, 4]), CustomSet([3, 2, 5])) == CustomSet([2, 3])
99
+ end
100
+ end
101
+
102
+ @testset "complement (difference)" begin
103
+ @testset "in-place" begin
104
+ @test begin
105
+ cs1 = CustomSet([])
106
+ cs2 = CustomSet([])
107
+ complement!(cs1, cs2)
108
+ isempty(cs1)
109
+ end
110
+ @test begin
111
+ cs1 = CustomSet([])
112
+ cs2 = CustomSet([3, 2, 5])
113
+ complement!(cs1, cs2)
114
+ isempty(cs1)
115
+ end
116
+ @test begin
117
+ cs1 = CustomSet([1, 2, 3, 4])
118
+ cs2 = CustomSet([])
119
+ complement!(cs1, cs2)
120
+ cs1 == CustomSet([1, 2, 3, 4])
121
+ end
122
+ @test begin
123
+ cs1 = CustomSet([3, 2, 1])
124
+ cs2 = CustomSet([2, 4])
125
+ complement!(cs1, cs2)
126
+ cs1 == CustomSet([1, 3])
127
+ end
128
+ end
129
+ @testset "not in-place" begin
130
+ @test isempty(complement(CustomSet([]), CustomSet([])))
131
+ @test isempty(complement(CustomSet([]), CustomSet([3, 2, 5])))
132
+ @test complement(CustomSet([1, 2, 3, 4]), CustomSet([])) == CustomSet([1, 2, 3, 4])
133
+ @test complement(CustomSet([3, 2, 1]), CustomSet([2, 4])) == CustomSet([1, 3])
134
+ end
135
+ end
136
+
137
+ @testset "union" begin
138
+ @testset "in-place" begin
139
+ @test begin
140
+ cs1 = CustomSet([])
141
+ cs2 = CustomSet([])
142
+ union!(cs1, cs2)
143
+ isempty(cs1)
144
+ end
145
+ @test begin
146
+ cs1 = CustomSet([])
147
+ cs2 = CustomSet([2])
148
+ union!(cs1, cs2)
149
+ cs1 == CustomSet([2])
150
+ end
151
+ @test begin
152
+ cs1 = CustomSet([1, 3])
153
+ cs2 = CustomSet([])
154
+ union!(cs1, cs2)
155
+ cs1 == CustomSet([1, 3])
156
+ end
157
+ @test begin
158
+ cs1 = CustomSet([1, 3])
159
+ cs2 = CustomSet([2, 3])
160
+ union!(cs1, cs2)
161
+ cs1 == CustomSet([3, 2, 1])
162
+ end
163
+ end
164
+ @testset "not in-place" begin
165
+ @test isempty(union(CustomSet([]), CustomSet([])))
166
+ @test union(CustomSet([]), CustomSet([2])) == CustomSet([2])
167
+ @test union(CustomSet([1, 3]), CustomSet([])) == CustomSet([1, 3])
168
+ @test union(CustomSet([1, 3]), CustomSet([2, 3])) == CustomSet([3, 2, 1])
169
+ end
170
+ end
171
+
172
+ # language specific tests
173
+ @testset "implements correct abstract type" begin
174
+ @test CustomSet <: Base.AbstractSet
175
+ end
176
+
177
+ @testset "length" begin
178
+ @test length(CustomSet([])) == 0
179
+ @test length(CustomSet([1, 2, 3])) == 3
180
+ end
181
+
182
+ @testset "iterable" begin
183
+ @test begin
184
+ cs1 = CustomSet([1, 2, 3, 4])
185
+ cs2 = CustomSet([])
186
+ for element in cs1
187
+ push!(cs2, element)
188
+ end
189
+ cs1 == cs2
190
+ end
191
+ end
192
+
193
+ @testset "copy" begin
194
+ @test begin
195
+ cs1 = CustomSet([1, 2, 3])
196
+ cs2 = copy(cs1)
197
+ push!(cs1, 4)
198
+ cs2 == CustomSet([1, 2, 3])
199
+ end
200
+ end
@@ -0,0 +1,11 @@
1
+ function isisogram(s::AbstractString)
2
+ s = lowercase(s)
3
+ chars = Char[]
4
+
5
+ for c in s
6
+ isalpha(c) || continue
7
+ c ∉ chars ? push!(chars, c) : return false
8
+ end
9
+
10
+ return true
11
+ end
@@ -0,0 +1,3 @@
1
+ function isisogram(s::AbstractString)
2
+
3
+ end
@@ -0,0 +1,35 @@
1
+ using Base.Test
2
+
3
+ include("isogram.jl")
4
+
5
+ @testset "empty string" begin
6
+ @test isisogram("")
7
+ end
8
+
9
+ @testset "isogram with only lower case characters" begin
10
+ @test isisogram("isogram")
11
+ end
12
+
13
+ @testset "word with one duplicated character" begin
14
+ @test !isisogram("eleven")
15
+ end
16
+
17
+ @testset "longest reported english isogram" begin
18
+ @test isisogram("subdermatoglyphic")
19
+ end
20
+
21
+ @testset "word with duplicated character in mixed case" begin
22
+ @test !isisogram("Alphabet")
23
+ end
24
+
25
+ @testset "hypothetical isogrammic word with hyphen" begin
26
+ @test isisogram("thumbscrew-japingly")
27
+ end
28
+
29
+ @testset "isogram with duplicated non letter character" begin
30
+ @test isisogram("Hjelmqvist-Gryb-Zock-Pfund-Wax")
31
+ end
32
+
33
+ @testset "made-up name that is an isogram" begin
34
+ @test isisogram("Emily Jung Schwartzkopf")
35
+ end
@@ -0,0 +1,16 @@
1
+ function luhn(id::AbstractString)
2
+ id = split(replace(id, ' ', ""), "")
3
+ length(id) < 2 && return false
4
+ all(isdigit, id) || return false
5
+
6
+ numbers = Int[]
7
+ for val in id
8
+ push!(numbers, parse(Int, val))
9
+ end
10
+
11
+ for i in length(numbers) - 1:-2:1
12
+ numbers[i] = (numbers[i] * 2) % 9
13
+ end
14
+
15
+ return sum(numbers) % 10 == 0
16
+ end
File without changes
@@ -0,0 +1,31 @@
1
+ using Base.Test
2
+
3
+ include("luhn.jl")
4
+
5
+ @testset "invalid" begin
6
+ @testset "single digit strings can not be valid" begin
7
+ @test !luhn("1")
8
+ end
9
+
10
+ @testset "A single zero is invalid" begin
11
+ @test !luhn("0")
12
+ end
13
+
14
+ @testset "invalid Canadian SIN" begin
15
+ @test !luhn("046 454 287")
16
+ end
17
+
18
+ @testset "invalid credit card" begin
19
+ @test !luhn("8273 1232 7352 0569")
20
+ end
21
+
22
+ @testset "valid strings with a non-digit added become invalid" begin
23
+ @test !luhn("046a 454 286")
24
+ end
25
+ end
26
+
27
+ @testset "valid" begin
28
+ @testset "valid Canadian SIN" begin
29
+ @test luhn("046 454 286")
30
+ end
31
+ end
@@ -0,0 +1,8 @@
1
+ function count_nucleotides(strand::AbstractString)
2
+ counter = Dict('A' => 0, 'C' => 0, 'G' => 0, 'T' => 0)
3
+ for sym in strand
4
+ sym in keys(counter) || error("Invalid nucleotide in strand")
5
+ counter[sym] += 1
6
+ end
7
+ return counter
8
+ end
@@ -0,0 +1,3 @@
1
+ function count_nucleotides(strand::AbstractString)
2
+
3
+ end