trackler 2.0.6.6 → 2.0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/exercises/perfect-numbers/description.md +2 -2
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/exercises/allergies/src/allergies.h +2 -2
- data/tracks/c/exercises/allergies/src/example.h +2 -2
- data/tracks/c/exercises/anagram/src/anagram.h +2 -2
- data/tracks/c/exercises/anagram/test/test_anagram.c +66 -79
- data/tracks/c/exercises/atbash-cipher/src/example.h +2 -2
- data/tracks/c/exercises/beer-song/src/example.h +2 -2
- data/tracks/c/exercises/binary-search/src/example.h +2 -2
- data/tracks/c/exercises/bob/src/example.h +2 -2
- data/tracks/c/exercises/clock/src/clock.h +2 -2
- data/tracks/c/exercises/difference-of-squares/src/example.h +2 -2
- data/tracks/c/exercises/gigasecond/src/example.h +2 -2
- data/tracks/c/exercises/grains/src/example.h +2 -2
- data/tracks/c/exercises/hamming/src/example.h +2 -2
- data/tracks/c/exercises/hello-world/src/hello_world.h +2 -2
- data/tracks/c/exercises/largest-series-product/src/example.h +2 -2
- data/tracks/c/exercises/leap/src/example.h +2 -2
- data/tracks/c/exercises/meetup/src/example.h +2 -2
- data/tracks/c/exercises/nth-prime/src/example.h +2 -2
- data/tracks/c/exercises/pangram/src/example.h +2 -2
- data/tracks/c/exercises/phone-number/src/example.h +2 -2
- data/tracks/c/exercises/raindrops/src/example.h +2 -2
- data/tracks/c/exercises/rna-transcription/src/example.h +2 -2
- data/tracks/c/exercises/robot-simulator/src/robot_simulator.h +2 -2
- data/tracks/c/exercises/roman-numerals/src/example.h +2 -2
- data/tracks/c/exercises/series/src/series.h +2 -2
- data/tracks/c/exercises/sieve/src/sieve.h +2 -2
- data/tracks/c/exercises/sum-of-multiples/src/example.h +2 -2
- data/tracks/c/exercises/word-count/src/word_count.h +2 -2
- data/tracks/erlang/config.json +5 -0
- data/tracks/erlang/exercises/roman-numerals/example.erl +19 -0
- data/tracks/erlang/exercises/roman-numerals/roman_numerals.erl +6 -0
- data/tracks/erlang/exercises/roman-numerals/roman_numerals_tests.erl +46 -0
- data/tracks/haskell/exercises/allergies/src/Allergies.hs +9 -1
- data/tracks/haskell/exercises/grade-school/HINTS.md +3 -3
- data/tracks/haskell/exercises/grade-school/src/School.hs +7 -3
- data/tracks/haskell/exercises/meetup/HINTS.md +3 -5
- data/tracks/haskell/exercises/meetup/src/Meetup.hs +14 -2
- data/tracks/haskell/exercises/space-age/HINTS.md +3 -5
- data/tracks/haskell/exercises/space-age/src/SpaceAge.hs +8 -1
- data/tracks/java/config.json +7 -1
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/sublist/build.gradle +17 -0
- data/tracks/java/exercises/sublist/src/example/java/Relationship.java +1 -0
- data/tracks/java/exercises/sublist/src/example/java/RelationshipComputer.java +29 -0
- data/tracks/java/exercises/sublist/src/main/java/Relationship.java +5 -0
- data/tracks/java/exercises/sublist/src/main/java/RelationshipComputer.java +5 -0
- data/tracks/java/exercises/sublist/src/test/java/RelationshipComputerTest.java +183 -0
- data/tracks/lua/exercises/run-length-encoding/example.lua +1 -1
- data/tracks/lua/exercises/run-length-encoding/run-length-encoding_spec.lua +8 -0
- data/tracks/lua/exercises/sublist/sublist_spec.lua +4 -0
- data/tracks/ruby/{SETUP.md → exercises/TRACK_HINTS.md} +0 -0
- data/tracks/rust/{SETUP.md → exercises/TRACK_HINTS.md} +0 -0
- data/tracks/rust/problem_ordering.md +41 -0
- data/tracks/scala/config.json +14 -0
- data/tracks/scala/exercises/saddle-points/build.sbt +2 -2
- data/tracks/scala/exercises/say/build.sbt +2 -2
- data/tracks/scala/exercises/secret-handshake/build.sbt +2 -2
- data/tracks/scala/exercises/series/build.sbt +3 -2
- data/tracks/scheme/config.json +67 -14
- metadata +14 -10
- data/tracks/haskell/SETUP.md +0 -52
- data/tracks/haskell/exercises/allergies/.meta/DONT-TEST-STUB +0 -1
- data/tracks/haskell/exercises/grade-school/.meta/DONT-TEST-STUB +0 -2
- data/tracks/haskell/exercises/meetup/.meta/DONT-TEST-STUB +0 -2
- data/tracks/haskell/exercises/space-age/.meta/DONT-TEST-STUB +0 -1
- data/tracks/rust/problems.md +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cc0a77186d7fa2d5ea7277f76bbd16c0e610a52
|
4
|
+
data.tar.gz: bd56a7bb8a6d1a0d68cf50e13e3a0b8c555f2159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ceea973ff044d16bb0976de1ce9ba06c91c6deec0abb8a09f2878e1f88e811f86bed65a4eeb36626b4146432220c451b3126b3bf8f05867ef62669ef9cda1e
|
7
|
+
data.tar.gz: 92c97e22e97b13a145ebaa8e4a61aa690907bb017bcfe7c2317199fd1eced5be3a45b1fcb5fc9b9cac1d31b7a60f1d620a36bce790555181fb30ac8a01a99a7c
|
@@ -15,6 +15,6 @@ including the number itself.
|
|
15
15
|
|
16
16
|
- 6 is a perfect number because its divisors are 1, 2, 3 and 6 = 1 + 2 +
|
17
17
|
3.
|
18
|
-
- 28 is perfect number because 28 = 1 + 2 + 4 + 7 + 14.
|
19
|
-
- Prime numbers 7, 13, etc are
|
18
|
+
- 28 is a perfect number because 28 = 1 + 2 + 4 + 7 + 14.
|
19
|
+
- Prime numbers 7, 13, etc are considered deficient in the Nicomachus
|
20
20
|
classification.
|
data/lib/trackler/version.rb
CHANGED
@@ -4,11 +4,32 @@
|
|
4
4
|
#include "vendor/unity.h"
|
5
5
|
#include "../src/anagram.h"
|
6
6
|
|
7
|
-
|
7
|
+
// Empty vector for when expected output is nothing
|
8
|
+
static struct Vector empty = {
|
9
|
+
NULL,
|
10
|
+
0
|
11
|
+
};
|
12
|
+
|
13
|
+
static int stringcmp(const void *a, const void *b)
|
8
14
|
{
|
9
15
|
return strcmp(a, b);
|
10
16
|
}
|
11
17
|
|
18
|
+
// Asserts that the two input vectors are equal
|
19
|
+
static void assert_equal_vector(struct Vector vout, struct Vector expected)
|
20
|
+
{
|
21
|
+
// Sort actual and expected outputs for consistency
|
22
|
+
qsort(expected.vec, expected.size, sizeof(char) * MAX_STR_LEN, stringcmp);
|
23
|
+
qsort(vout.vec, vout.size, sizeof(char) * MAX_STR_LEN, stringcmp);
|
24
|
+
|
25
|
+
TEST_ASSERT_EQUAL(expected.size, vout.size);
|
26
|
+
for (int x = 0; x < vout.size; x++) {
|
27
|
+
TEST_ASSERT_EQUAL(strlen(expected.vec[x]), strlen(vout.vec[x]));
|
28
|
+
TEST_ASSERT_EQUAL_MEMORY(expected.vec[x], vout.vec[x],
|
29
|
+
strlen(expected.vec[x]));
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
12
33
|
void test_no_matches(void)
|
13
34
|
{
|
14
35
|
char inputs[][MAX_STR_LEN] = {
|
@@ -24,15 +45,12 @@ void test_no_matches(void)
|
|
24
45
|
};
|
25
46
|
|
26
47
|
struct Vector vout = anagrams_for("diaper", vin);
|
27
|
-
|
28
|
-
TEST_ASSERT_EQUAL(0, vout.size);
|
29
|
-
|
48
|
+
assert_equal_vector(vout, empty);
|
30
49
|
free(vout.vec);
|
31
50
|
}
|
32
51
|
|
33
52
|
void test_detect_simple_anagram(void)
|
34
53
|
{
|
35
|
-
int x;
|
36
54
|
char inputs[][MAX_STR_LEN] = {
|
37
55
|
"tan",
|
38
56
|
"stand",
|
@@ -42,21 +60,19 @@ void test_detect_simple_anagram(void)
|
|
42
60
|
char outputs[][MAX_STR_LEN] = {
|
43
61
|
"tan"
|
44
62
|
};
|
45
|
-
int outputs_len = sizeof(outputs) / MAX_STR_LEN;
|
46
63
|
|
47
64
|
struct Vector vin = {
|
48
65
|
inputs,
|
49
66
|
sizeof(inputs) / MAX_STR_LEN
|
50
67
|
};
|
51
68
|
|
52
|
-
struct Vector
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
TEST_ASSERT_EQUAL(strlen(outputs[x]), strlen(vout.vec[x]));
|
57
|
-
TEST_ASSERT_EQUAL_MEMORY(outputs[x], vout.vec[x], strlen(outputs[x]));
|
58
|
-
}
|
69
|
+
struct Vector expected = {
|
70
|
+
outputs,
|
71
|
+
sizeof(outputs) / MAX_STR_LEN
|
72
|
+
};
|
59
73
|
|
74
|
+
struct Vector vout = anagrams_for("ant", vin);
|
75
|
+
assert_equal_vector(vout, expected);
|
60
76
|
free(vout.vec);
|
61
77
|
}
|
62
78
|
|
@@ -72,9 +88,7 @@ void test_does_not_confuse_different_duplicates(void)
|
|
72
88
|
};
|
73
89
|
|
74
90
|
struct Vector vout = anagrams_for("galea", vin);
|
75
|
-
|
76
|
-
TEST_ASSERT_EQUAL(0, vout.size);
|
77
|
-
|
91
|
+
assert_equal_vector(vout, empty);
|
78
92
|
free(vout.vec);
|
79
93
|
}
|
80
94
|
|
@@ -91,15 +105,12 @@ void test_eliminate_anagram_subsets(void)
|
|
91
105
|
};
|
92
106
|
|
93
107
|
struct Vector vout = anagrams_for("good", vin);
|
94
|
-
|
95
|
-
TEST_ASSERT_EQUAL(0, vout.size);
|
96
|
-
|
108
|
+
assert_equal_vector(vout, empty);
|
97
109
|
free(vout.vec);
|
98
110
|
}
|
99
111
|
|
100
112
|
void test_detect_anagram(void)
|
101
113
|
{
|
102
|
-
int x;
|
103
114
|
char inputs[][MAX_STR_LEN] = {
|
104
115
|
"enlists",
|
105
116
|
"google",
|
@@ -110,27 +121,24 @@ void test_detect_anagram(void)
|
|
110
121
|
char outputs[][MAX_STR_LEN] = {
|
111
122
|
"inlets"
|
112
123
|
};
|
113
|
-
int outputs_len = sizeof(outputs) / MAX_STR_LEN;
|
114
124
|
|
115
125
|
struct Vector vin = {
|
116
126
|
inputs,
|
117
127
|
sizeof(inputs) / MAX_STR_LEN
|
118
128
|
};
|
119
129
|
|
120
|
-
struct Vector
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
TEST_ASSERT_EQUAL(strlen(outputs[x]), strlen(vout.vec[x]));
|
125
|
-
TEST_ASSERT_EQUAL_MEMORY(outputs[x], vout.vec[x], strlen(outputs[x]));
|
126
|
-
}
|
130
|
+
struct Vector expected = {
|
131
|
+
outputs,
|
132
|
+
sizeof(outputs) / MAX_STR_LEN
|
133
|
+
};
|
127
134
|
|
135
|
+
struct Vector vout = anagrams_for("listen", vin);
|
136
|
+
assert_equal_vector(vout, expected);
|
128
137
|
free(vout.vec);
|
129
138
|
}
|
130
139
|
|
131
140
|
void test_multiple_anagrams(void)
|
132
141
|
{
|
133
|
-
int x;
|
134
142
|
char inputs[][MAX_STR_LEN] = {
|
135
143
|
"gallery",
|
136
144
|
"ballerina",
|
@@ -140,28 +148,24 @@ void test_multiple_anagrams(void)
|
|
140
148
|
"leading"
|
141
149
|
};
|
142
150
|
|
143
|
-
struct Vector vin = {
|
144
|
-
inputs,
|
145
|
-
sizeof(inputs) / MAX_STR_LEN
|
146
|
-
};
|
147
|
-
|
148
151
|
char outputs[][MAX_STR_LEN] = {
|
149
152
|
"gallery",
|
150
153
|
"regally",
|
151
154
|
"largely"
|
152
155
|
};
|
153
|
-
int outputs_len = sizeof(outputs) / MAX_STR_LEN;
|
154
|
-
qsort(outputs, outputs_len, sizeof(char) * MAX_STR_LEN, stringcmp);
|
155
156
|
|
156
|
-
struct Vector
|
157
|
-
|
157
|
+
struct Vector vin = {
|
158
|
+
inputs,
|
159
|
+
sizeof(inputs) / MAX_STR_LEN
|
160
|
+
};
|
158
161
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
}
|
162
|
+
struct Vector expected = {
|
163
|
+
outputs,
|
164
|
+
sizeof(outputs) / MAX_STR_LEN
|
165
|
+
};
|
164
166
|
|
167
|
+
struct Vector vout = anagrams_for("allergy", vin);
|
168
|
+
assert_equal_vector(vout, expected);
|
165
169
|
free(vout.vec);
|
166
170
|
}
|
167
171
|
|
@@ -173,33 +177,27 @@ void test_case_insensitive_anagrams(void)
|
|
173
177
|
"radishes"
|
174
178
|
};
|
175
179
|
|
180
|
+
char outputs[][MAX_STR_LEN] = {
|
181
|
+
"Carthorse"
|
182
|
+
};
|
183
|
+
|
176
184
|
struct Vector vin = {
|
177
185
|
inputs,
|
178
186
|
sizeof(inputs) / MAX_STR_LEN
|
179
187
|
};
|
180
188
|
|
181
|
-
|
182
|
-
|
189
|
+
struct Vector expected = {
|
190
|
+
outputs,
|
191
|
+
sizeof(outputs) / MAX_STR_LEN
|
183
192
|
};
|
184
|
-
int outputs_len = sizeof(outputs) / MAX_STR_LEN;
|
185
|
-
qsort(outputs, outputs_len, sizeof(char) * MAX_STR_LEN, stringcmp);
|
186
193
|
|
187
194
|
struct Vector vout = anagrams_for("Orchestra", vin);
|
188
|
-
|
189
|
-
|
190
|
-
TEST_ASSERT_EQUAL(outputs_len, vout.size);
|
191
|
-
int x;
|
192
|
-
for (x = 0; x < vout.size; x++) {
|
193
|
-
TEST_ASSERT_EQUAL(strlen(outputs[x]), strlen(vout.vec[x]));
|
194
|
-
TEST_ASSERT_EQUAL_MEMORY(outputs[x], vout.vec[x], strlen(outputs[x]));
|
195
|
-
}
|
196
|
-
|
195
|
+
assert_equal_vector(vout, expected);
|
197
196
|
free(vout.vec);
|
198
197
|
}
|
199
198
|
|
200
199
|
void test_unicode_anagrams(void)
|
201
200
|
{
|
202
|
-
int x;
|
203
201
|
// These words don't make sense, they're just greek letters cobbled together.
|
204
202
|
char inputs[][MAX_STR_LEN] = {
|
205
203
|
"ΒΓΑ",
|
@@ -207,27 +205,22 @@ void test_unicode_anagrams(void)
|
|
207
205
|
"γβα"
|
208
206
|
};
|
209
207
|
|
208
|
+
char outputs[][MAX_STR_LEN] = {
|
209
|
+
"ΒΓΑ"
|
210
|
+
};
|
211
|
+
|
210
212
|
struct Vector vin = {
|
211
213
|
inputs,
|
212
214
|
sizeof(inputs) / MAX_STR_LEN
|
213
215
|
};
|
214
216
|
|
215
|
-
|
216
|
-
|
217
|
-
|
217
|
+
struct Vector expected = {
|
218
|
+
outputs,
|
219
|
+
sizeof(outputs) / MAX_STR_LEN
|
218
220
|
};
|
219
|
-
int outputs_len = sizeof(outputs) / MAX_STR_LEN;
|
220
|
-
qsort(outputs, outputs_len, sizeof(char) * MAX_STR_LEN, stringcmp);
|
221
221
|
|
222
222
|
struct Vector vout = anagrams_for("ΑΒΓ", vin);
|
223
|
-
|
224
|
-
|
225
|
-
TEST_ASSERT_EQUAL(outputs_len, vout.size);
|
226
|
-
for (x = 0; x < vout.size; x++) {
|
227
|
-
TEST_ASSERT_EQUAL(strlen(outputs[x]), strlen(vout.vec[x]));
|
228
|
-
TEST_ASSERT_EQUAL_MEMORY(outputs[x], vout.vec[x], strlen(outputs[x]));
|
229
|
-
}
|
230
|
-
|
223
|
+
assert_equal_vector(vout, expected);
|
231
224
|
free(vout.vec);
|
232
225
|
}
|
233
226
|
|
@@ -245,9 +238,7 @@ void test_misleading_unicode_anagrams(void)
|
|
245
238
|
};
|
246
239
|
|
247
240
|
struct Vector vout = anagrams_for("ΑΒΓ", vin);
|
248
|
-
|
249
|
-
TEST_ASSERT_EQUAL(0, vout.size);
|
250
|
-
|
241
|
+
assert_equal_vector(vout, empty);
|
251
242
|
free(vout.vec);
|
252
243
|
}
|
253
244
|
|
@@ -263,9 +254,7 @@ void test_does_not_detect_a_word_as_its_own_anagram(void)
|
|
263
254
|
};
|
264
255
|
|
265
256
|
struct Vector vout = anagrams_for("banana", vin);
|
266
|
-
|
267
|
-
TEST_ASSERT_EQUAL(0, vout.size);
|
268
|
-
|
257
|
+
assert_equal_vector(vout, empty);
|
269
258
|
free(vout.vec);
|
270
259
|
}
|
271
260
|
|
@@ -281,9 +270,7 @@ void test_does_not_detect_a_differently_cased_word_as_its_own_anagram(void)
|
|
281
270
|
};
|
282
271
|
|
283
272
|
struct Vector vout = anagrams_for("banana", vin);
|
284
|
-
|
285
|
-
TEST_ASSERT_EQUAL(0, vout.size);
|
286
|
-
|
273
|
+
assert_equal_vector(vout, empty);
|
287
274
|
free(vout.vec);
|
288
275
|
}
|
289
276
|
|
data/tracks/erlang/config.json
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
-module(roman_numerals).
|
2
|
+
|
3
|
+
-export([numerals/1]).
|
4
|
+
|
5
|
+
-define(DIGITS, [{"M", 1000}, {"CM", 900}, {"D", 500}, {"CD", 400},
|
6
|
+
{"C", 100}, {"XC", 90}, {"L", 50}, {"XL", 40},
|
7
|
+
{"X", 10}, {"IX", 9}, {"V", 5}, {"IV", 4}, {"I", 1}]).
|
8
|
+
|
9
|
+
-spec numerals(non_neg_integer()) -> string().
|
10
|
+
numerals(Number) ->
|
11
|
+
to_roman(Number, "", ?DIGITS).
|
12
|
+
|
13
|
+
to_roman(0, Roman, _) -> Roman;
|
14
|
+
to_roman(N, Roman, Digits) ->
|
15
|
+
{R, D} = hd(Digits),
|
16
|
+
if
|
17
|
+
N >= D -> to_roman(N - D, Roman ++ R, Digits);
|
18
|
+
true -> to_roman(N, Roman, tl(Digits))
|
19
|
+
end.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
-module(roman_numerals_tests).
|
2
|
+
|
3
|
+
-include_lib("eunit/include/eunit.hrl").
|
4
|
+
|
5
|
+
% To run tests:
|
6
|
+
% erlc -make
|
7
|
+
% erl -noshell -eval "eunit:test(etl, [verbose])" -s init stop
|
8
|
+
|
9
|
+
expect_roman(Number, Expected) ->
|
10
|
+
?assertEqual(roman_numerals:numerals(Number), Expected).
|
11
|
+
|
12
|
+
convert_1_test() -> expect_roman(1, "I").
|
13
|
+
|
14
|
+
convert_2_test() -> expect_roman(2, "II").
|
15
|
+
|
16
|
+
convert_3_test() -> expect_roman(3, "III").
|
17
|
+
|
18
|
+
convert_4_test() -> expect_roman(4, "IV").
|
19
|
+
|
20
|
+
convert_5_test() -> expect_roman(5, "V").
|
21
|
+
|
22
|
+
convert_6_test() -> expect_roman(6, "VI").
|
23
|
+
|
24
|
+
convert_9_test() -> expect_roman(9, "IX").
|
25
|
+
|
26
|
+
convert_27_test() -> expect_roman(27, "XXVII").
|
27
|
+
|
28
|
+
convert_48_test() -> expect_roman(48, "XLVIII").
|
29
|
+
|
30
|
+
convert_59_test() -> expect_roman(59, "LIX").
|
31
|
+
|
32
|
+
convert_93_test() -> expect_roman(93, "XCIII").
|
33
|
+
|
34
|
+
convert_141_test() -> expect_roman(141, "CXLI").
|
35
|
+
|
36
|
+
convert_163_test() -> expect_roman(163, "CLXIII").
|
37
|
+
|
38
|
+
convert_402_test() -> expect_roman(402, "CDII").
|
39
|
+
|
40
|
+
convert_575_test() -> expect_roman(575, "DLXXV").
|
41
|
+
|
42
|
+
convert_911_test() -> expect_roman(911, "CMXI").
|
43
|
+
|
44
|
+
convert_1024_test() -> expect_roman(1024, "MXXIV").
|
45
|
+
|
46
|
+
convert_3000_test() -> expect_roman(3000, "MMM").
|
@@ -1,6 +1,14 @@
|
|
1
1
|
module Allergies (Allergen(..), allergies, isAllergicTo) where
|
2
2
|
|
3
|
-
data Allergen =
|
3
|
+
data Allergen = Eggs
|
4
|
+
| Peanuts
|
5
|
+
| Shellfish
|
6
|
+
| Strawberries
|
7
|
+
| Tomatoes
|
8
|
+
| Chocolate
|
9
|
+
| Pollen
|
10
|
+
| Cats
|
11
|
+
deriving (Eq)
|
4
12
|
|
5
13
|
allergies :: Int -> [Allergen]
|
6
14
|
allergies = undefined
|