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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/perfect-numbers/description.md +2 -2
  3. data/lib/trackler/version.rb +1 -1
  4. data/tracks/c/exercises/allergies/src/allergies.h +2 -2
  5. data/tracks/c/exercises/allergies/src/example.h +2 -2
  6. data/tracks/c/exercises/anagram/src/anagram.h +2 -2
  7. data/tracks/c/exercises/anagram/test/test_anagram.c +66 -79
  8. data/tracks/c/exercises/atbash-cipher/src/example.h +2 -2
  9. data/tracks/c/exercises/beer-song/src/example.h +2 -2
  10. data/tracks/c/exercises/binary-search/src/example.h +2 -2
  11. data/tracks/c/exercises/bob/src/example.h +2 -2
  12. data/tracks/c/exercises/clock/src/clock.h +2 -2
  13. data/tracks/c/exercises/difference-of-squares/src/example.h +2 -2
  14. data/tracks/c/exercises/gigasecond/src/example.h +2 -2
  15. data/tracks/c/exercises/grains/src/example.h +2 -2
  16. data/tracks/c/exercises/hamming/src/example.h +2 -2
  17. data/tracks/c/exercises/hello-world/src/hello_world.h +2 -2
  18. data/tracks/c/exercises/largest-series-product/src/example.h +2 -2
  19. data/tracks/c/exercises/leap/src/example.h +2 -2
  20. data/tracks/c/exercises/meetup/src/example.h +2 -2
  21. data/tracks/c/exercises/nth-prime/src/example.h +2 -2
  22. data/tracks/c/exercises/pangram/src/example.h +2 -2
  23. data/tracks/c/exercises/phone-number/src/example.h +2 -2
  24. data/tracks/c/exercises/raindrops/src/example.h +2 -2
  25. data/tracks/c/exercises/rna-transcription/src/example.h +2 -2
  26. data/tracks/c/exercises/robot-simulator/src/robot_simulator.h +2 -2
  27. data/tracks/c/exercises/roman-numerals/src/example.h +2 -2
  28. data/tracks/c/exercises/series/src/series.h +2 -2
  29. data/tracks/c/exercises/sieve/src/sieve.h +2 -2
  30. data/tracks/c/exercises/sum-of-multiples/src/example.h +2 -2
  31. data/tracks/c/exercises/word-count/src/word_count.h +2 -2
  32. data/tracks/erlang/config.json +5 -0
  33. data/tracks/erlang/exercises/roman-numerals/example.erl +19 -0
  34. data/tracks/erlang/exercises/roman-numerals/roman_numerals.erl +6 -0
  35. data/tracks/erlang/exercises/roman-numerals/roman_numerals_tests.erl +46 -0
  36. data/tracks/haskell/exercises/allergies/src/Allergies.hs +9 -1
  37. data/tracks/haskell/exercises/grade-school/HINTS.md +3 -3
  38. data/tracks/haskell/exercises/grade-school/src/School.hs +7 -3
  39. data/tracks/haskell/exercises/meetup/HINTS.md +3 -5
  40. data/tracks/haskell/exercises/meetup/src/Meetup.hs +14 -2
  41. data/tracks/haskell/exercises/space-age/HINTS.md +3 -5
  42. data/tracks/haskell/exercises/space-age/src/SpaceAge.hs +8 -1
  43. data/tracks/java/config.json +7 -1
  44. data/tracks/java/exercises/settings.gradle +1 -0
  45. data/tracks/java/exercises/sublist/build.gradle +17 -0
  46. data/tracks/java/exercises/sublist/src/example/java/Relationship.java +1 -0
  47. data/tracks/java/exercises/sublist/src/example/java/RelationshipComputer.java +29 -0
  48. data/tracks/java/exercises/sublist/src/main/java/Relationship.java +5 -0
  49. data/tracks/java/exercises/sublist/src/main/java/RelationshipComputer.java +5 -0
  50. data/tracks/java/exercises/sublist/src/test/java/RelationshipComputerTest.java +183 -0
  51. data/tracks/lua/exercises/run-length-encoding/example.lua +1 -1
  52. data/tracks/lua/exercises/run-length-encoding/run-length-encoding_spec.lua +8 -0
  53. data/tracks/lua/exercises/sublist/sublist_spec.lua +4 -0
  54. data/tracks/ruby/{SETUP.md → exercises/TRACK_HINTS.md} +0 -0
  55. data/tracks/rust/{SETUP.md → exercises/TRACK_HINTS.md} +0 -0
  56. data/tracks/rust/problem_ordering.md +41 -0
  57. data/tracks/scala/config.json +14 -0
  58. data/tracks/scala/exercises/saddle-points/build.sbt +2 -2
  59. data/tracks/scala/exercises/say/build.sbt +2 -2
  60. data/tracks/scala/exercises/secret-handshake/build.sbt +2 -2
  61. data/tracks/scala/exercises/series/build.sbt +3 -2
  62. data/tracks/scheme/config.json +67 -14
  63. metadata +14 -10
  64. data/tracks/haskell/SETUP.md +0 -52
  65. data/tracks/haskell/exercises/allergies/.meta/DONT-TEST-STUB +0 -1
  66. data/tracks/haskell/exercises/grade-school/.meta/DONT-TEST-STUB +0 -2
  67. data/tracks/haskell/exercises/meetup/.meta/DONT-TEST-STUB +0 -2
  68. data/tracks/haskell/exercises/space-age/.meta/DONT-TEST-STUB +0 -1
  69. data/tracks/rust/problems.md +0 -88
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a21f979fb3f1492834008a98a524077cff2d0b2
4
- data.tar.gz: 10ff768afd6613b122020ff2a9054101f3886244
3
+ metadata.gz: 6cc0a77186d7fa2d5ea7277f76bbd16c0e610a52
4
+ data.tar.gz: bd56a7bb8a6d1a0d68cf50e13e3a0b8c555f2159
5
5
  SHA512:
6
- metadata.gz: 4626e4391ae111a17500f5eadd483a10a95a4436c9d2c9e687729821a2d80d3a3adb4de1532acb9d4227f30f880479c406b6ab85fd48e59ddc3e90b80f1bdfab
7
- data.tar.gz: 784fc5dc94f2fefe34ce60955ff9182ed2d3599c735097b2ff3d35305c572e8ac834f659912afde3031249197172cfac7e322754cb01acb8a33be08416175e62
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 Deficient by the Nicomachus
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.
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.6.6"
2
+ VERSION = "2.0.6.7"
3
3
  end
@@ -1,5 +1,5 @@
1
- #ifndef _ALLERGIES_H
2
- #define _ALLERGIES_H
1
+ #ifndef ALLERGIES_H
2
+ #define ALLERGIES_H
3
3
 
4
4
  typedef enum {
5
5
  Allergen_Eggs = 0,
@@ -1,5 +1,5 @@
1
- #ifndef _ALLERGIES_H
2
- #define _ALLERGIES_H
1
+ #ifndef ALLERGIES_H
2
+ #define ALLERGIES_H
3
3
 
4
4
  #include <stdbool.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _ANAGRAM_H
2
- #define _ANAGRAM_H
1
+ #ifndef ANAGRAM_H
2
+ #define ANAGRAM_H
3
3
 
4
4
  #define MAX_STR_LEN 20
5
5
 
@@ -4,11 +4,32 @@
4
4
  #include "vendor/unity.h"
5
5
  #include "../src/anagram.h"
6
6
 
7
- int stringcmp(const void *a, const void *b)
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 vout = anagrams_for("ant", vin);
53
-
54
- TEST_ASSERT_EQUAL(outputs_len, vout.size);
55
- for (x = 0; x < vout.size; x++) {
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 vout = anagrams_for("listen", vin);
121
-
122
- TEST_ASSERT_EQUAL(outputs_len, vout.size);
123
- for (x = 0; x < vout.size; x++) {
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 vout = anagrams_for("allergy", vin);
157
- qsort(vout.vec, vout.size, sizeof(char) * MAX_STR_LEN, stringcmp);
157
+ struct Vector vin = {
158
+ inputs,
159
+ sizeof(inputs) / MAX_STR_LEN
160
+ };
158
161
 
159
- TEST_ASSERT_EQUAL(outputs_len, vout.size);
160
- for (x = 0; x < vout.size; x++) {
161
- TEST_ASSERT_EQUAL(strlen(outputs[x]), strlen(vout.vec[x]));
162
- TEST_ASSERT_EQUAL_MEMORY(outputs[x], vout.vec[x], strlen(outputs[x]));
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
- char outputs[][MAX_STR_LEN] = {
182
- "Carthorse"
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
- qsort(vout.vec, vout.size, sizeof(char) * MAX_STR_LEN, stringcmp);
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
- char outputs[][MAX_STR_LEN] = {
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
- qsort(vout.vec, vout.size, sizeof(char) * MAX_STR_LEN, stringcmp);
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
 
@@ -1,5 +1,5 @@
1
- #ifndef _ATBASH_CIPHER_H
2
- #define _ATBASH_CIPHER_H
1
+ #ifndef ATBASH_CIPHER_H
2
+ #define ATBASH_CIPHER_H
3
3
 
4
4
  char *atbash_encode(const char *input);
5
5
  char *atbash_decode(const char *input);
@@ -1,5 +1,5 @@
1
- #ifndef _BEER_SONG_H
2
- #define _BEER_SONG_H
1
+ #ifndef BEER_SONG_H
2
+ #define BEER_SONG_H
3
3
 
4
4
  void verse(char *buffer, unsigned int verseNumber);
5
5
  void sing(char *buffer, unsigned int startingVerseNumber,
@@ -1,5 +1,5 @@
1
- #ifndef _BINARY_SEARCH_H
2
- #define _BINARY_SEARCH_H
1
+ #ifndef BINARY_SEARCH_H
2
+ #define BINARY_SEARCH_H
3
3
 
4
4
  #include <stddef.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _BOB_H
2
- #define _BOB_H
1
+ #ifndef BOB_H
2
+ #define BOB_H
3
3
 
4
4
  #include <stdbool.h>
5
5
  char *hey_bob(char *greeting);
@@ -1,5 +1,5 @@
1
- #ifndef _CLOCK_H
2
- #define _CLOCK_H
1
+ #ifndef CLOCK_H
2
+ #define CLOCK_H
3
3
 
4
4
  #define MAX_STR_LEN (5 + 1) // "##:##\0"
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _DIFFERENCE_OF_SQUARES_H
2
- #define _DIFFERENCE_OF_SQUARES_H
1
+ #ifndef DIFFERENCE_OF_SQUARES_H
2
+ #define DIFFERENCE_OF_SQUARES_H
3
3
 
4
4
  unsigned int sum_of_squares(unsigned int number);
5
5
  unsigned int square_of_sum(unsigned int number);
@@ -1,5 +1,5 @@
1
- #ifndef _GIGASECOND_H
2
- #define _GIGASECOND_H
1
+ #ifndef GIGASECOND_H
2
+ #define GIGASECOND_H
3
3
 
4
4
  #include <time.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _GRAINS_H
2
- #define _GRAINS_H
1
+ #ifndef GRAINS_H
2
+ #define GRAINS_H
3
3
 
4
4
  #include <stdint.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _HAMMING_H
2
- #define _HAMMING_H
1
+ #ifndef HAMMING_H
2
+ #define HAMMING_H
3
3
 
4
4
  size_t compute(const char *lhs, const char *rhs);
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _HELLO_WORLD_H
2
- #define _HELLO_WORLD_H
1
+ #ifndef HELLO_WORLD_H
2
+ #define HELLO_WORLD_H
3
3
 
4
4
  void hello(char *buffer, const char *name);
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _LARGEST_SERIES_PRODUCT_H
2
- #define _LARGEST_SERIES_PRODUCT_H
1
+ #ifndef LARGEST_SERIES_PRODUCT_H
2
+ #define LARGEST_SERIES_PRODUCT_H
3
3
 
4
4
  #include <stddef.h>
5
5
  #include <stdint.h>
@@ -1,5 +1,5 @@
1
- #ifndef _LEAP_H
2
- #define _LEAP_H
1
+ #ifndef LEAP_H
2
+ #define LEAP_H
3
3
 
4
4
  #include <stdbool.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _MEETUP_H
2
- #define _MEETUP_H
1
+ #ifndef MEETUP_H
2
+ #define MEETUP_H
3
3
 
4
4
  int meetupDayOfMonth(unsigned int year, unsigned int month, const char *week,
5
5
  const char *dayOfWeek);
@@ -1,5 +1,5 @@
1
- #ifndef _NTH_PRIME_H
2
- #define _NTH_PRIME_H
1
+ #ifndef NTH_PRIME_H
2
+ #define NTH_PRIME_H
3
3
 
4
4
  #include <stdint.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _PANGRAM_H
2
- #define _PANGRAM_H
1
+ #ifndef PANGRAM_H
2
+ #define PANGRAM_H
3
3
 
4
4
  #include <stdbool.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _PHONE_NUMBER_H
2
- #define _PHONE_NUMBER_H
1
+ #ifndef PHONE_NUMBER_H
2
+ #define PHONE_NUMBER_H
3
3
 
4
4
  char *phone_number_clean(const char *input);
5
5
  char *phone_number_get_area_code(const char *input);
@@ -1,5 +1,5 @@
1
- #ifndef _RAINDROPS_H
2
- #define _RAINDROPS_H
1
+ #ifndef RAINDROPS_H
2
+ #define RAINDROPS_H
3
3
 
4
4
  char *convert(char *buffer, int buffer_length, int drops);
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _RNA_TRANSCRIPTION_H
2
- #define _RNA_TRANSCRIPTION_H
1
+ #ifndef RNA_TRANSCRIPTION_H
2
+ #define RNA_TRANSCRIPTION_H
3
3
 
4
4
  char *to_rna(const char *dna);
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _ROBOT_SIMULATOR_H
2
- #define _ROBOT_SIMULATOR_H
1
+ #ifndef ROBOT_SIMULATOR_H
2
+ #define ROBOT_SIMULATOR_H
3
3
 
4
4
  typedef enum {
5
5
  Heading_North = 0,
@@ -1,5 +1,5 @@
1
- #ifndef _ROMAN_NUMERALS_H
2
- #define _ROMAN_NUMERALS_H
1
+ #ifndef ROMAN_NUMERALS_H
2
+ #define ROMAN_NUMERALS_H
3
3
 
4
4
  char *to_roman_numeral(unsigned int number);
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _SERIES_H
2
- #define _SERIES_H
1
+ #ifndef SERIES_H
2
+ #define SERIES_H
3
3
 
4
4
  #define MAX_INPUT_TEXT_LENGTH (8)
5
5
  #define MAX_SERIES_RESULTS (MAX_INPUT_TEXT_LENGTH)
@@ -1,5 +1,5 @@
1
- #ifndef _SIEVE_H
2
- #define _SIEVE_H
1
+ #ifndef SIEVE_H
2
+ #define SIEVE_H
3
3
 
4
4
  #define MAX_LIMIT_TESTED (1000)
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _SUM_OF_MULTIPLES_H
2
- #define _SUM_OF_MULTIPLES_H
1
+ #ifndef SUM_OF_MULTIPLES_H
2
+ #define SUM_OF_MULTIPLES_H
3
3
 
4
4
  #include <stddef.h>
5
5
 
@@ -1,5 +1,5 @@
1
- #ifndef _WORD_COUNT_H
2
- #define _WORD_COUNT_H
1
+ #ifndef WORD_COUNT_H
2
+ #define WORD_COUNT_H
3
3
 
4
4
  #define MAX_WORDS 20 // at most MAX_WORDS will be found in the test input string
5
5
  #define MAX_WORD_LENGTH 50 // no individual word will exceed this length
@@ -178,6 +178,11 @@
178
178
  "slug": "zipper",
179
179
  "topics": [],
180
180
  "difficulty": 1
181
+ },
182
+ {
183
+ "slug": "roman-numerals",
184
+ "topics": [],
185
+ "difficulty": 1
181
186
  }
182
187
  ],
183
188
  "deprecated": [
@@ -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,6 @@
1
+ -module(roman_numerals).
2
+
3
+ -export([numerals/1]).
4
+
5
+ -spec numerals(non_neg_integer()) -> string().
6
+ numerals(Number) -> "".
@@ -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 = Dummy
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