trackler 2.0.0.1 → 2.0.0.2

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.
Files changed (226) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bump-content +3 -1
  3. data/bin/verify-metadata +2 -2
  4. data/common/exercises/alphametics/canonical-data.json +19 -9
  5. data/common/exercises/food-chain/canonical-data.json +7 -1
  6. data/common/exercises/grains/canonical-data.json +66 -0
  7. data/common/exercises/raindrops/description.md +4 -5
  8. data/common/exercises/triangle/canonical-data.json +81 -54
  9. data/lib/trackler/version.rb +1 -1
  10. data/tracks/c/config.json +26 -19
  11. data/tracks/c/exercises/allergies/makefile +15 -0
  12. data/tracks/c/exercises/allergies/src/allergies.h +21 -0
  13. data/tracks/c/exercises/allergies/src/example.c +32 -0
  14. data/tracks/c/exercises/allergies/src/example.h +26 -0
  15. data/tracks/c/exercises/allergies/test/test_allergies.c +203 -0
  16. data/tracks/c/exercises/allergies/test/vendor/unity.c +1300 -0
  17. data/tracks/c/exercises/allergies/test/vendor/unity.h +274 -0
  18. data/tracks/c/exercises/allergies/test/vendor/unity_internals.h +701 -0
  19. data/tracks/c/exercises/atbash-cipher/makefile +16 -0
  20. data/tracks/c/exercises/atbash-cipher/src/example.c +71 -0
  21. data/tracks/c/exercises/atbash-cipher/src/example.h +7 -0
  22. data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +113 -0
  23. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.c +1300 -0
  24. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.h +274 -0
  25. data/tracks/c/exercises/atbash-cipher/test/vendor/unity_internals.h +701 -0
  26. data/tracks/c/exercises/phone-number/makefile +16 -0
  27. data/tracks/c/exercises/phone-number/src/example.c +66 -0
  28. data/tracks/c/exercises/phone-number/src/example.h +8 -0
  29. data/tracks/c/exercises/phone-number/test/test_phone_number.c +108 -0
  30. data/tracks/c/exercises/phone-number/test/vendor/unity.c +1300 -0
  31. data/tracks/c/exercises/phone-number/test/vendor/unity.h +274 -0
  32. data/tracks/c/exercises/phone-number/test/vendor/unity_internals.h +701 -0
  33. data/tracks/csharp/config.json +8 -0
  34. data/tracks/csharp/exercises/bowling/BowlingTest.cs +188 -33
  35. data/tracks/csharp/exercises/bowling/Example.cs +38 -9
  36. data/tracks/csharp/exercises/rectangles/Example.cs +91 -0
  37. data/tracks/csharp/exercises/rectangles/RectanglesTest.cs +133 -0
  38. data/tracks/elisp/docs/INSTALLATION.org +1 -1
  39. data/tracks/elixir/config.json +8 -66
  40. data/tracks/elixir/docs/LEARNING.md +1 -1
  41. data/tracks/elixir/exercises/diamond/diamond_test.exs +12 -12
  42. data/tracks/elixir/exercises/grep/example.exs +92 -0
  43. data/tracks/elixir/exercises/grep/grep.exs +6 -0
  44. data/tracks/elixir/exercises/grep/grep_test.exs +259 -0
  45. data/tracks/elixir/exercises/markdown/markdown.exs +59 -2
  46. data/tracks/elixir/exercises/nucleotide-count/nucleotide_count_test.exs +4 -4
  47. data/tracks/elixir/exercises/phone-number/phone_number_test.exs +5 -0
  48. data/tracks/fsharp/exercises/bowling/BowlingTest.fs +158 -43
  49. data/tracks/fsharp/exercises/bowling/Example.fs +53 -24
  50. data/tracks/go/config.json +5 -0
  51. data/tracks/go/exercises/diamond/diamond_test.go +227 -0
  52. data/tracks/go/exercises/diamond/example.go +47 -0
  53. data/tracks/go/exercises/food-chain/example.go +1 -1
  54. data/tracks/go/exercises/food-chain/food_chain_test.go +30 -6
  55. data/tracks/go/exercises/nucleotide-count/example.go +21 -8
  56. data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +45 -37
  57. data/tracks/haskell/exercises/anagram/test/Tests.hs +1 -11
  58. data/tracks/java/bin/journey-test.sh +165 -128
  59. data/tracks/java/docs/ABOUT.md +5 -8
  60. data/tracks/java/exercises/hello-world/build.gradle +0 -6
  61. data/tracks/java/exercises/hello-world/src/test/java/HelloWorldTest.java +0 -1
  62. data/tracks/java/exercises/meetup/build.gradle +0 -1
  63. data/tracks/java/exercises/meetup/src/example/java/Meetup.java +9 -7
  64. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +185 -188
  65. data/tracks/lua/config.json +0 -73
  66. data/tracks/lua/exercises/bowling/bowling_spec.lua +92 -48
  67. data/tracks/lua/exercises/bowling/example.lua +4 -1
  68. data/tracks/objective-c/config.json +9 -30
  69. data/tracks/objective-c/exercises/pangram/PangramExample.h +7 -0
  70. data/tracks/objective-c/exercises/pangram/PangramExample.m +21 -0
  71. data/tracks/objective-c/exercises/pangram/PangramTest.m +51 -0
  72. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  73. data/tracks/ocaml/README.md +46 -1
  74. data/tracks/ocaml/SETUP.md +21 -2
  75. data/tracks/ocaml/config.json +48 -78
  76. data/tracks/perl5/README.md +15 -8
  77. data/tracks/perl5/testall.pl +5 -5
  78. data/tracks/php/config.json +26 -34
  79. data/tracks/php/docs/ABOUT.md +15 -0
  80. data/tracks/php/exercises/allergies/allergies_test.php +121 -0
  81. data/tracks/php/exercises/allergies/example.php +64 -0
  82. data/tracks/php/exercises/etl/etl_test.php +52 -0
  83. data/tracks/php/exercises/etl/example.php +12 -0
  84. data/tracks/php/exercises/nucleotide-count/example.php +25 -0
  85. data/tracks/php/exercises/nucleotide-count/nucleotide-count_test.php +36 -0
  86. data/tracks/php/exercises/pig-latin/example.php +25 -29
  87. data/tracks/php/exercises/pig-latin/pig-latin_test.php +26 -19
  88. data/tracks/php/exercises/space-age/example.php +65 -0
  89. data/tracks/php/exercises/space-age/space-age_test.php +70 -0
  90. data/tracks/php/exercises/triangle/example.php +43 -0
  91. data/tracks/php/exercises/triangle/triangle_test.php +140 -0
  92. data/tracks/pony/exercises/anagram/example.pony +6 -6
  93. data/tracks/pony/exercises/anagram/test.pony +3 -4
  94. data/tracks/pony/exercises/bob/test.pony +23 -23
  95. data/tracks/pony/exercises/difference-of-squares/test.pony +11 -11
  96. data/tracks/pony/exercises/hamming/example.pony +3 -3
  97. data/tracks/pony/exercises/hamming/test.pony +16 -16
  98. data/tracks/pony/exercises/hello-world/test.pony +5 -4
  99. data/tracks/pony/exercises/leap/test.pony +8 -8
  100. data/tracks/python/config.json +18 -0
  101. data/tracks/python/exercises/diamond/diamond_test.py +33 -0
  102. data/tracks/python/exercises/diamond/example.py +15 -0
  103. data/tracks/python/exercises/linked-list/example.py +47 -0
  104. data/tracks/python/exercises/linked-list/linked_list.py +13 -0
  105. data/tracks/python/exercises/linked-list/linked_list_test.py +49 -0
  106. data/tracks/python/exercises/list-ops/example.py +55 -0
  107. data/tracks/python/exercises/list-ops/list_ops.py +38 -0
  108. data/tracks/python/exercises/list-ops/list_ops_test.py +136 -0
  109. data/tracks/ruby/bin/generate +22 -2
  110. data/tracks/ruby/config.json +12 -83
  111. data/tracks/ruby/exercises/allergies/allergies_test.rb +0 -1
  112. data/tracks/ruby/exercises/atbash-cipher/atbash_cipher_test.rb +0 -1
  113. data/tracks/ruby/exercises/beer-song/beer_song_test.rb +1 -2
  114. data/tracks/ruby/exercises/binary/example.rb +0 -1
  115. data/tracks/ruby/exercises/binary-search-tree/binary_search_tree_test.rb +1 -1
  116. data/tracks/ruby/exercises/bowling/.version +1 -0
  117. data/tracks/ruby/exercises/bowling/bowling_test.rb +109 -133
  118. data/tracks/ruby/exercises/bowling/example.rb +7 -7
  119. data/tracks/ruby/exercises/bowling/example.tt +27 -0
  120. data/tracks/ruby/exercises/circular-buffer/circular_buffer_test.rb +0 -2
  121. data/tracks/ruby/exercises/clock/example.rb +0 -2
  122. data/tracks/ruby/exercises/connect/connect_test.rb +0 -1
  123. data/tracks/ruby/exercises/custom-set/custom_set_test.rb +0 -1
  124. data/tracks/ruby/exercises/diamond/diamond_test.rb +0 -1
  125. data/tracks/ruby/exercises/etl/etl_test.rb +1 -1
  126. data/tracks/ruby/exercises/house/house_test.rb +0 -1
  127. data/tracks/ruby/exercises/isogram/isogram_test.rb +2 -2
  128. data/tracks/ruby/exercises/largest-series-product/example.tt +0 -3
  129. data/tracks/ruby/exercises/largest-series-product/largest_series_product_test.rb +0 -4
  130. data/tracks/ruby/exercises/linked-list/linked_list_test.rb +1 -1
  131. data/tracks/ruby/exercises/meetup/meetup_test.rb +0 -1
  132. data/tracks/ruby/exercises/nth-prime/example.tt +0 -2
  133. data/tracks/ruby/exercises/nth-prime/nth_prime_test.rb +0 -2
  134. data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +1 -2
  135. data/tracks/ruby/exercises/protein-translation/protein_translation_test.rb +0 -1
  136. data/tracks/ruby/exercises/proverb/proverb_test.rb +1 -3
  137. data/tracks/ruby/exercises/queen-attack/example.rb +3 -1
  138. data/tracks/ruby/exercises/queen-attack/queen_attack_test.rb +34 -8
  139. data/tracks/ruby/exercises/robot-simulator/robot_simulator_test.rb +1 -1
  140. data/tracks/ruby/exercises/strain/strain_test.rb +2 -2
  141. data/tracks/ruby/exercises/tournament/.version +1 -0
  142. data/tracks/ruby/exercises/tournament/example.rb +54 -0
  143. data/tracks/ruby/exercises/tournament/example.tt +23 -0
  144. data/tracks/ruby/exercises/tournament/tournament_test.rb +92 -0
  145. data/tracks/ruby/exercises/transpose/.version +1 -0
  146. data/tracks/ruby/exercises/transpose/example.rb +14 -0
  147. data/tracks/ruby/exercises/transpose/example.tt +22 -0
  148. data/tracks/ruby/exercises/transpose/transpose_test.rb +303 -0
  149. data/tracks/ruby/lib/bowling_cases.rb +46 -0
  150. data/tracks/ruby/lib/isogram_cases.rb +1 -1
  151. data/tracks/ruby/lib/tournament_cases.rb +45 -0
  152. data/tracks/ruby/lib/transpose_cases.rb +45 -0
  153. data/tracks/rust/config.json +2 -0
  154. data/tracks/rust/exercises/bowling/.gitignore +7 -0
  155. data/tracks/rust/exercises/bowling/Cargo.toml +3 -0
  156. data/tracks/rust/exercises/bowling/example.rs +134 -0
  157. data/tracks/rust/exercises/bowling/tests/bowling.rs +373 -0
  158. data/tracks/rust/exercises/grains/.gitignore +7 -0
  159. data/tracks/rust/exercises/grains/Cargo.toml +3 -0
  160. data/tracks/rust/exercises/grains/example.rs +11 -0
  161. data/tracks/rust/exercises/grains/src/lib.rs +7 -0
  162. data/tracks/rust/exercises/grains/tests/grains.rs +63 -0
  163. data/tracks/rust/problems.md +2 -0
  164. data/tracks/scala/README.md +38 -0
  165. data/tracks/scala/config.json +20 -74
  166. data/tracks/scala/exercises/accumulate/src/test/scala/accumulate_test.scala +4 -0
  167. data/tracks/scala/exercises/allergies/src/test/scala/allergies_test.scala +11 -0
  168. data/tracks/scala/exercises/alphametics/build.sbt +6 -0
  169. data/tracks/scala/exercises/alphametics/example.scala +125 -0
  170. data/tracks/scala/exercises/alphametics/src/main/scala/.keep +0 -0
  171. data/tracks/scala/exercises/alphametics/src/test/scala/AlphameticsTest.scala +62 -0
  172. data/tracks/scala/exercises/atbash-cipher/src/test/scala/atbash_test.scala +8 -0
  173. data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +4 -0
  174. data/tracks/scala/exercises/binary/src/test/scala/binary_test.scala +13 -0
  175. data/tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala +11 -0
  176. data/tracks/scala/exercises/bowling/Example.scala +116 -0
  177. data/tracks/scala/exercises/bowling/build.sbt +3 -0
  178. data/tracks/scala/exercises/bowling/src/main/scala/Bowling.scala +11 -0
  179. data/tracks/scala/exercises/bowling/src/test/scala/BowlingSuite.scala +237 -0
  180. data/tracks/scala/exercises/clock/src/test/scala/ClockTest.scala +50 -0
  181. data/tracks/scala/exercises/connect/README.md +17 -0
  182. data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +7 -0
  183. data/tracks/scala/exercises/crypto-square/src/test/scala/{CrytpoSquareTest.scala → CryptoSquareTest.scala} +9 -0
  184. data/tracks/scala/exercises/custom-set/src/test/scala/CustomSetTest.scala +36 -0
  185. data/tracks/scala/exercises/difference-of-squares/src/test/scala/squares_test.scala +8 -0
  186. data/tracks/scala/exercises/forth/src/test/scala/ForthTest.scala +22 -0
  187. data/tracks/scala/exercises/hexadecimal/src/test/scala/HexadecimalTest.scala +8 -0
  188. data/tracks/scala/exercises/kindergarten-garden/src/test/scala/GardenTest.scala +5 -0
  189. data/tracks/scala/exercises/largest-series-product/src/test/scala/SeriesTest.scala +2 -0
  190. data/tracks/scala/exercises/linked-list/src/test/scala/DequeTest.scala +4 -0
  191. data/tracks/scala/exercises/luhn/src/test/scala/LuhnTest.scala +4 -0
  192. data/tracks/scala/exercises/matrix/src/test/scala/MatrixTest.scala +2 -0
  193. data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +6 -0
  194. data/tracks/scala/exercises/nth-prime/src/test/scala/PrimeTest.scala +5 -0
  195. data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrTest.scala +15 -0
  196. data/tracks/scala/exercises/octal/src/test/scala/OctalTest.scala +7 -0
  197. data/tracks/scala/exercises/parallel-letter-frequency/src/test/scala/FrequencyTest.scala +8 -0
  198. data/tracks/scala/exercises/pascals-triangle/src/test/scala/PascalsTriangleTest.scala +5 -0
  199. data/tracks/scala/exercises/pig-latin/src/test/scala/PigLatinTest.scala +4 -0
  200. data/tracks/scala/exercises/pythagorean-triplet/src/test/scala/PythagoreanTripletTest.scala +3 -0
  201. data/tracks/scala/exercises/queen-attack/src/test/scala/QueensTest.scala +5 -0
  202. data/tracks/scala/exercises/robot-simulator/src/test/scala/RobotTest.scala +16 -8
  203. data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +34 -17
  204. data/tracks/scala/exercises/scrabble-score/src/test/scala/scrabble_score_test.scala +6 -0
  205. data/tracks/scala/exercises/secret-handshake/src/test/scala/SecretHandshakeTest.scala +18 -9
  206. data/tracks/scala/exercises/series/src/test/scala/SeriesTest.scala +4 -2
  207. data/tracks/scala/exercises/sieve/src/test/scala/SieveTest.scala +8 -4
  208. data/tracks/scala/exercises/simple-cipher/src/test/scala/CipherTest.scala +17 -9
  209. data/tracks/scala/exercises/sublist/src/test/scala/sublist_test.scala +17 -0
  210. data/tracks/scala/exercises/trinary/src/test/scala/TrinaryTest.scala +14 -7
  211. data/tracks/scala/exercises/wordy/src/test/scala/WordProblemTest.scala +28 -14
  212. data/tracks/scala/project/Build.scala +3 -3
  213. data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +57 -0
  214. data/tracks/sml/config.json +41 -6
  215. data/tracks/sml/exercises/flatten-array/example.sml +6 -0
  216. data/tracks/sml/exercises/flatten-array/test_flatten_array.sml +10 -0
  217. data/tracks/sml/exercises/nth-prime/example.sml +46 -0
  218. data/tracks/sml/exercises/nth-prime/test_nth_prime.sml +14 -0
  219. data/tracks/sml/exercises/raindrops/example.sml +9 -0
  220. data/tracks/sml/exercises/raindrops/raindrops.sml +2 -0
  221. data/tracks/sml/exercises/raindrops/test_raindrops.sml +95 -0
  222. data/tracks/swift/config.json +269 -328
  223. data/tracks/swift/exercises/pangram/PangramExample.swift +17 -0
  224. data/tracks/swift/exercises/pangram/PangramTest.swift +43 -0
  225. data/tracks/swift/xcodeProject/xSwift.xcodeproj/project.pbxproj +16 -0
  226. metadata +95 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fff91f419bbd95eb001c7301034cbc92258f23a
4
- data.tar.gz: dce4a5c8121cf481fc009dbe4a46724f5c2da472
3
+ metadata.gz: 6ecd79fc11b28fd57fad197537efd30d929a39a2
4
+ data.tar.gz: a260adf3ee20c762dc65638fb762284607c54761
5
5
  SHA512:
6
- metadata.gz: 6e84750de6af3b699e3b2aa498f8dab12820be37e78d5f5898141e42f2d7ab80b14827e006972fc497e1f816b848e45285d45d0a627487d61a289e2ac01bca2e
7
- data.tar.gz: e8d7320afbd63cf0045ee8a92880332e26f1f9e43d2183af992d9cfff5132b0be3a3ef2d8780f2b287fab1e2696e8e1a694b980200a7860552cefcaba427f8a2
6
+ metadata.gz: b74c1f2b78cfed39a431f5bdae4fa8822008aa987087985e9c1508d3f39710aaa32460d5e168c252d745ed579d319047734a533e38766b854e12e67a92ac8ddc
7
+ data.tar.gz: 4d597f2e379ed5010ab9d881051991a20d7afe9b3200e4d8d38d6de3560727b7c096c960aa9762291255e04d45cf6034df034f7e7ff49fb66788ee070d8f215d
data/bin/bump-content CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- system("bin/update")
3
+ unless system("bin/update")
4
+ exit 1
5
+ end
4
6
 
5
7
  file = File.absolute_path("../../lib/trackler/version.rb", __FILE__)
6
8
 
data/bin/verify-metadata CHANGED
@@ -6,8 +6,8 @@ require_relative '../lib/trackler'
6
6
 
7
7
  omissions = []
8
8
  Trackler.tracks.each do |track|
9
- track.problems.each do |slug|
10
- unless Trackler.problems[slug].exists?
9
+ track.problems.each do |problem|
10
+ unless Trackler.problems[problem.slug].exists?
11
11
  omissions << slug
12
12
  end
13
13
  end
@@ -3,15 +3,10 @@
3
3
  "description": "Solve the alphametics puzzle",
4
4
  "cases": [
5
5
  {
6
- "description": "solve short puzzle",
6
+ "description": "puzzle with three letters",
7
7
  "puzzle": "I + BB == ILL",
8
8
  "expected": { "I": 1, "B": 9, "L": 0 }
9
9
  },
10
- {
11
- "description": "solve long puzzle",
12
- "puzzle": "SEND + MORE == MONEY",
13
- "expected": { "S": 9, "E": 5, "N": 6, "D": 7, "M": 1, "O": 0, "R": 8, "Y": 2 }
14
- },
15
10
  {
16
11
  "description": "solution must have unique value for each letter",
17
12
  "puzzle": "A == B",
@@ -23,13 +18,28 @@
23
18
  "expected": null
24
19
  },
25
20
  {
26
- "description": "solve puzzle with four words",
21
+ "description": "puzzle with four letters",
22
+ "puzzle": "AS + A == MOM",
23
+ "expected": { "A": 9, "S": 2, "M": 1, "O": 0 }
24
+ },
25
+ {
26
+ "description": "puzzle with six letters",
27
+ "puzzle": "NO + NO + TOO == LATE",
28
+ "expected": { "N": 7, "O": 4, "T": 9, "L": 1, "A": 0, "E": 2}
29
+ },
30
+ {
31
+ "description": "puzzle with seven letters",
27
32
  "puzzle": "HE + SEES + THE == LIGHT",
28
33
  "expected": { "E": 4, "G": 2, "H": 5, "I": 0, "L": 1, "S": 9, "T": 7 }
29
34
  },
30
35
  {
31
- "description": "solve puzzle with many words",
32
- "puzzle": "AND + A + STRONG + OFFENSE + AS + A + GOOD = DEFENSE",
36
+ "description": "puzzle with eight letters",
37
+ "puzzle": "SEND + MORE == MONEY",
38
+ "expected": { "S": 9, "E": 5, "N": 6, "D": 7, "M": 1, "O": 0, "R": 8, "Y": 2 }
39
+ },
40
+ {
41
+ "description": "puzzle with ten letters",
42
+ "puzzle": "AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE",
33
43
  "expected": { "A": 5, "D": 3, "E": 4, "F": 7, "G": 8, "N": 0, "O": 2, "R": 1, "S": 6, "T": 9 }
34
44
  }
35
45
  ]
@@ -106,7 +106,7 @@
106
106
  {
107
107
  "description": "multiple verses",
108
108
  "start verse": 1,
109
- "end verse": 2,
109
+ "end verse": 3,
110
110
  "expected": [
111
111
  "I know an old lady who swallowed a fly.",
112
112
  "I don't know why she swallowed the fly. Perhaps she'll die.",
@@ -114,6 +114,12 @@
114
114
  "I know an old lady who swallowed a spider.",
115
115
  "It wriggled and jiggled and tickled inside her.",
116
116
  "She swallowed the spider to catch the fly.",
117
+ "I don't know why she swallowed the fly. Perhaps she'll die.",
118
+ "",
119
+ "I know an old lady who swallowed a bird.",
120
+ "How absurd to swallow a bird!",
121
+ "She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.",
122
+ "She swallowed the spider to catch the fly.",
117
123
  "I don't know why she swallowed the fly. Perhaps she'll die."
118
124
  ]
119
125
  },
@@ -0,0 +1,66 @@
1
+ {
2
+ "#": [
3
+ "The final tests of square test error conditions",
4
+ "The expection for these tests is -1, indicating an error",
5
+ "In these cases you should expect an error as is idiomatic for your language"
6
+ ],
7
+ "square": {
8
+ "description": "returns the number of grains on the square",
9
+ "cases": [
10
+ {
11
+ "description": "1",
12
+ "input": 1,
13
+ "expected": 1
14
+ },
15
+ {
16
+ "description": "2",
17
+ "input": 2,
18
+ "expected": 2
19
+ },
20
+ {
21
+ "description": "3",
22
+ "input": 3,
23
+ "expected": 4
24
+ },
25
+ {
26
+ "description": "4",
27
+ "input": 4,
28
+ "expected": 8
29
+ },
30
+ {
31
+ "description": "16",
32
+ "input": 16,
33
+ "expected": 32768
34
+ },
35
+ {
36
+ "description": "32",
37
+ "input": 32,
38
+ "expected": 2147483648
39
+ },
40
+ {
41
+ "description": "64",
42
+ "input": 64,
43
+ "expected": 9223372036854775808
44
+ },
45
+ {
46
+ "description": "square 0 raises an exception",
47
+ "input": 0,
48
+ "expected": -1
49
+ },
50
+ {
51
+ "description": "negative square raises an exception",
52
+ "input": -1,
53
+ "expected": -1
54
+ },
55
+ {
56
+ "description": "square greater than 64 raises an exception",
57
+ "input": 65,
58
+ "expected": -1
59
+ }
60
+ ]
61
+ },
62
+ "total": {
63
+ "description": "returns the total number of grains on the board",
64
+ "expected": 18446744073709551615
65
+ }
66
+ }
@@ -6,10 +6,9 @@
6
6
 
7
7
  ## Examples
8
8
 
9
- - 28's factors are 2, 4, **7**, 14.
9
+ - 28's factors are 1, 2, 4, **7**, 14, 28.
10
10
  - In raindrop-speak, this would be a simple "Plong".
11
- - 30's factors are 2, **3**, **5**, 6, 15.
11
+ - 30's factors are 1, 2, **3**, **5**, 6, 15, 30.
12
12
  - In raindrop-speak, this would be a "PlingPlang".
13
- - 34 only has two factors- 2 and 17.
14
- - Raindrop-speak doesn't know what to make of that,
15
- so it just goes with the straightforward "34".
13
+ - 34 has four factors: 1, 2, 17, and 34.
14
+ - In raindrop-speak, this would be "34".
@@ -8,88 +8,115 @@
8
8
  "They're degenerate triangles with all three vertices collinear.",
9
9
  "(In contrast, we will test (0, 0, 0, Illegal), as it is a point).",
10
10
 
11
- "The expectation are given as strings,",
12
- "but your language may use the appropriate representations.",
13
- "For example, enums, variants, or tagged unions all are viable candidates.",
11
+ "The tests assert properities of the triangle are true or false.",
12
+ "See: https://github.com/exercism/x-common/issues/379 for disscussion of this approach",
14
13
 
15
- "Your track may choose to have the 'illegal' result be another member of the enum/variant/union/etc.,",
16
- "or instead to signal an error/exception/etc. on an illegal triangle.",
17
-
18
- "If appropriate for your track, you'll need to ensure that no pair of expected values are equal.",
19
- "Otherwise, an implementation that always returns a constant value may falsely pass the tests.",
20
- "See https://github.com/exercism/xgo/pull/208"
14
+ "How you handle invalid triangles is up to you. These tests suggest a triangle",
15
+ "is returned, but all of its properties are false. But you could also have the creation",
16
+ "of an invalid triangle return an error or exception. Choose what is idiomatic for",
17
+ "your language."
21
18
  ],
22
- "cases": [
19
+ "equilateral": {
20
+ "description": "returns true if the triangle is equilateral",
21
+ "cases": [
23
22
  {
24
- "description": "equilateral triangle has all sides equal",
25
- "sides": [2, 2, 2],
26
- "expected": "equilateral"
23
+ "description": "true if all sides are equal",
24
+ "sides": [2, 2, 2],
25
+ "expected": true
27
26
  },
28
27
  {
29
- "description": "larger equilateral triangle",
30
- "sides": [10, 10, 10],
31
- "expected": "equilateral"
28
+ "description": "false if any side is unequal",
29
+ "sides": [2, 3, 2],
30
+ "expected": false
32
31
  },
33
32
  {
34
- "description": "isosceles triangle with last two sides equal",
35
- "sides": [3, 4, 4],
36
- "expected": "isosceles"
33
+ "description": "false if no sides are equal",
34
+ "sides": [5, 4, 6],
35
+ "expected": false
37
36
  },
38
37
  {
39
- "description": "isosceles triangle with first two sides equal",
40
- "sides": [4, 4, 3],
41
- "expected": "isosceles"
38
+ "description": "All zero sides are illegal, so the triangle is not equilateral",
39
+ "sides": [0, 0, 0],
40
+ "expected": false
42
41
  },
43
42
  {
44
- "description": "isosceles triangle with first and last sides equal",
45
- "sides": [4, 3, 4],
46
- "expected": "isosceles"
43
+ "#": "Your track may choose to skip this test and deal only with integers if appropriate",
44
+ "description": "sides may be floats",
45
+ "sides": [0.5, 0.5, 0.5],
46
+ "expected": true
47
+ }
48
+ ]
49
+ },
50
+ "isosceles": {
51
+ "description": "returns true if the triangle is isosceles",
52
+ "cases": [
53
+ {
54
+ "description": "true if last two sides are equal",
55
+ "sides": [3, 4, 4],
56
+ "expected": true
47
57
  },
48
58
  {
49
- "description": "isosceles triangle with unequal side larger than equal sides",
50
- "sides": [4, 7, 4],
51
- "expected": "isosceles"
59
+ "description": "true if first two sides are equal",
60
+ "sides": [4, 4, 3],
61
+ "expected": true
52
62
  },
53
63
  {
54
- "description": "scalene triangle has no equal sides",
55
- "sides": [3, 4, 5],
56
- "expected": "scalene"
64
+ "description": "true if first and last sides are equal",
65
+ "sides": [4, 3, 4],
66
+ "expected": true
57
67
  },
58
68
  {
59
- "description": "2a == b+c looks like equilateral, but isn't always",
60
- "sides": [5, 4, 6],
61
- "expected": "scalene"
69
+ "description": "equilateral triangles are also isosceles",
70
+ "sides": [4, 4, 4],
71
+ "expected": true
62
72
  },
63
73
  {
64
- "description": "larger scalene triangle",
65
- "sides": [10, 11, 12],
66
- "expected": "scalene"
74
+ "description": "false if no sides are equal",
75
+ "sides": [2, 3, 4],
76
+ "expected": false
67
77
  },
68
78
  {
69
- "description": "scalene triangle with sides in descending order",
70
- "sides": [5, 4, 2],
71
- "expected": "scalene"
79
+ "description": "Sides that violate triangle inequality are not isosceles, even if two are equal",
80
+ "sides": [1, 1, 3],
81
+ "expected": false
82
+ },
83
+ {
84
+ "#": "Your track may choose to skip this test and deal only with integers if appropriate",
85
+ "description": "sides may be floats",
86
+ "sides": [0.5, 0.4, 0.5],
87
+ "expected": true
88
+ }
89
+ ]
90
+ },
91
+ "scalene": {
92
+ "description": "returns true if the triangle is scalene",
93
+ "cases": [
94
+ {
95
+ "description": "true if no sides are equal",
96
+ "sides": [5, 4, 6],
97
+ "expected": true
72
98
  },
73
99
  {
74
- "#": "Your track may choose to skip this test and deal only with integers if appropriate",
75
- "description": "small scalene triangle with floating point values",
76
- "sides": [0.4, 0.6, 0.3],
77
- "expected": "scalene"
100
+ "description": "false if all sides are equal",
101
+ "sides": [4, 4, 4],
102
+ "expected": false
78
103
  },
79
104
  {
80
- "description": "a triangle violating the triangle inequality is illegal",
81
- "sides": [7, 3, 2],
82
- "expected": "illegal"
105
+ "description": "false if two sides are equal",
106
+ "sides": [4, 4, 3],
107
+ "expected": false
83
108
  },
84
109
  {
85
- "description": "two sides equal, but still violates triangle inequality",
86
- "sides": [1, 1, 3],
87
- "expected": "illegal"
110
+ "description": "Sides that violate triangle inequality are not scalene, even if they are all different",
111
+ "sides": [7, 3, 2],
112
+ "expected": false
88
113
  },
89
114
  {
90
- "description": "triangles with all sides zero are illegal",
91
- "sides": [0, 0, 0],
92
- "expected": "illegal"
115
+ "#": "Your track may choose to skip this test and deal only with integers if appropriate",
116
+ "description": "sides may be floats",
117
+ "sides": [0.5, 0.4, 0.6],
118
+ "expected": true
93
119
  }
94
- ]
120
+ ]
121
+ }
95
122
  }
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.0.1"
2
+ VERSION = "2.0.0.2"
3
3
  end
data/tracks/c/config.json CHANGED
@@ -4,25 +4,6 @@
4
4
  "repository": "https://github.com/exercism/xc",
5
5
  "checklist_issue": 8,
6
6
  "active": false,
7
- "problems": [
8
- "hello-world",
9
- "anagram",
10
- "leap",
11
- "gigasecond",
12
- "hamming",
13
- "raindrops",
14
- "bob",
15
- "grains",
16
- "largest-series-product",
17
- "pangram",
18
- "nth-prime",
19
- "beer-song",
20
- "rna-transcription",
21
- "difference-of-squares",
22
- "sum-of-multiples",
23
- "binary-search",
24
- "roman-numerals"
25
- ],
26
7
  "exercises": [{
27
8
  "slug": "hello-world",
28
9
  "difficulty": 1,
@@ -155,6 +136,32 @@
155
136
  "control-flow (loops)",
156
137
  "strings"
157
138
  ]
139
+ }, {
140
+ "slug": "allergies",
141
+ "difficulty": 4,
142
+ "topics": [
143
+ "control-flow (if-statements)",
144
+ "control-flow (loops)",
145
+ "structs",
146
+ "memory management"
147
+ ]
148
+ }, {
149
+ "difficulty": 5,
150
+ "slug": "atbash-cipher",
151
+ "topics": [
152
+ "control-flow (loops)",
153
+ "control-flow (if-else statements)",
154
+ "strings"
155
+ ]
156
+ }, {
157
+ "difficulty": 4,
158
+ "slug": "phone-number",
159
+ "topics": [
160
+ "strings",
161
+ "memory management",
162
+ "control-flow (loops)",
163
+ "control-flow (if-else statements)"
164
+ ]
158
165
  }],
159
166
  "deprecated": [
160
167
 
@@ -0,0 +1,15 @@
1
+ CFLAGS = -std=c99
2
+ CFLAGS += -Wall
3
+ CFLAGS += -Wextra
4
+ CFLAGS += -pedantic
5
+ CFLAGS += -Werror
6
+
7
+ test: tests.out
8
+ @./tests.out
9
+
10
+ clean:
11
+ rm -f *.o *.out
12
+
13
+ tests.out: test/test_allergies.c src/allergies.c src/allergies.h
14
+ @echo Compiling $@
15
+ @cc $(CFLAGS) src/allergies.c test/vendor/unity.c test/test_allergies.c -o tests.out
@@ -0,0 +1,21 @@
1
+ #ifndef _ALLERGIES_H
2
+ #define _ALLERGIES_H
3
+
4
+ typedef enum {
5
+ Allergen_Eggs = 0,
6
+ Allergen_Peanuts,
7
+ Allergen_Shellfish,
8
+ Allergen_Strawberries,
9
+ Allergen_Tomatoes,
10
+ Allergen_Chocolate,
11
+ Allergen_Pollen,
12
+ Allergen_Cats,
13
+ Allergen_Count
14
+ } Allergen_t;
15
+
16
+ typedef struct {
17
+ int count;
18
+ Allergen_t *allergens;
19
+ } Allergen_List_t;
20
+
21
+ #endif
@@ -0,0 +1,32 @@
1
+ #include "allergies.h"
2
+ #include <stdlib.h>
3
+
4
+ static const unsigned int scores[] = {
5
+ 1,
6
+ 2,
7
+ 4,
8
+ 8,
9
+ 16,
10
+ 32,
11
+ 64,
12
+ 128
13
+ };
14
+
15
+ bool is_allergic_to(Allergen_t allergen, unsigned int score)
16
+ {
17
+ return ((score & scores[allergen]) == scores[allergen]);
18
+ }
19
+
20
+ void get_allergens(unsigned int score, Allergen_List_t * list)
21
+ {
22
+ list->allergens = calloc(Allergen_Count, sizeof(Allergen_t));
23
+ list->count = 0;
24
+
25
+ for (Allergen_t allergen = 0; allergen < Allergen_Count; allergen++) {
26
+ if (is_allergic_to(allergen, score)) {
27
+ score -= scores[allergen];
28
+ list->allergens[list->count] = allergen;
29
+ list->count++;
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,26 @@
1
+ #ifndef _ALLERGIES_H
2
+ #define _ALLERGIES_H
3
+
4
+ #include <stdbool.h>
5
+
6
+ typedef enum {
7
+ Allergen_Eggs = 0,
8
+ Allergen_Peanuts,
9
+ Allergen_Shellfish,
10
+ Allergen_Strawberries,
11
+ Allergen_Tomatoes,
12
+ Allergen_Chocolate,
13
+ Allergen_Pollen,
14
+ Allergen_Cats,
15
+ Allergen_Count
16
+ } Allergen_t;
17
+
18
+ typedef struct {
19
+ int count;
20
+ Allergen_t *allergens;
21
+ } Allergen_List_t;
22
+
23
+ bool is_allergic_to(Allergen_t allergen, unsigned int score);
24
+ void get_allergens(unsigned int score, Allergen_List_t * list);
25
+
26
+ #endif