trackler 2.0.0.8 → 2.0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/bob/canonical-data.json +1 -20
  3. data/common/exercises/raindrops/canonical-data.json +18 -0
  4. data/common/exercises/sublist/canonical-data.json +5 -0
  5. data/lib/trackler/version.rb +1 -1
  6. data/tracks/clojure/config.json +5 -0
  7. data/tracks/clojure/exercises/pig-latin/project.clj +4 -0
  8. data/tracks/clojure/exercises/pig-latin/src/example.clj +49 -0
  9. data/tracks/clojure/exercises/pig-latin/test/pig_latin_test.clj +92 -0
  10. data/tracks/clojure/exercises/robot-name/src/example.clj +8 -11
  11. data/tracks/clojure/exercises/robot-name/test/robot_name_test.clj +23 -18
  12. data/tracks/crystal/config.json +6 -0
  13. data/tracks/crystal/exercises/acronym/spec/acronym_spec.cr +7 -7
  14. data/tracks/crystal/exercises/forth/spec/forth_spec.cr +198 -0
  15. data/tracks/crystal/exercises/forth/src/example.cr +187 -0
  16. data/tracks/crystal/exercises/hello-world/spec/hello_world_spec.cr +3 -3
  17. data/tracks/crystal/src/generator/exercises/acronym.cr +1 -1
  18. data/tracks/crystal/src/generator/exercises/exercise_generator.cr +3 -2
  19. data/tracks/crystal/src/generator/exercises/forth.cr +56 -0
  20. data/tracks/crystal/src/generator/exercises/templates/example.tt +2 -2
  21. data/tracks/crystal/src/generator/spec/exercise_generator_spec.cr +5 -3
  22. data/tracks/csharp/exercises/wordy/WordyTest.cs +2 -2
  23. data/tracks/elixir/config.json +83 -70
  24. data/tracks/fsharp/exercises/wordy/WordyTest.fs +1 -1
  25. data/tracks/go/config.json +28 -3
  26. data/tracks/go/exercises/all-your-base/all_your_base_test.go +185 -0
  27. data/tracks/go/exercises/all-your-base/example.go +60 -0
  28. data/tracks/go/exercises/isogram/example.go +15 -0
  29. data/tracks/go/exercises/isogram/isogram_test.go +50 -0
  30. data/tracks/go/exercises/ledger/ledger.go +2 -2
  31. data/tracks/go/exercises/pangram/example.go +32 -0
  32. data/tracks/go/exercises/pangram/pangram_test.go +43 -0
  33. data/tracks/go/exercises/protein-translation/example.go +59 -0
  34. data/tracks/go/exercises/protein-translation/protein_translation_test.go +69 -0
  35. data/tracks/go/exercises/tree-building/tree_building.go +1 -1
  36. data/tracks/go/exercises/twelve-days/example.go +57 -0
  37. data/tracks/go/exercises/twelve-days/twelve_days_test.go +79 -0
  38. data/tracks/haskell/.travis.yml +13 -8
  39. data/tracks/haskell/config.json +6 -0
  40. data/tracks/haskell/exercises/accumulate/stack.yaml +1 -1
  41. data/tracks/haskell/exercises/all-your-base/stack.yaml +1 -1
  42. data/tracks/haskell/exercises/allergies/stack.yaml +1 -1
  43. data/tracks/haskell/exercises/alphametics/stack.yaml +1 -1
  44. data/tracks/haskell/exercises/anagram/stack.yaml +1 -1
  45. data/tracks/haskell/exercises/atbash-cipher/stack.yaml +1 -1
  46. data/tracks/haskell/exercises/bank-account/stack.yaml +1 -1
  47. data/tracks/haskell/exercises/beer-song/stack.yaml +1 -1
  48. data/tracks/haskell/exercises/binary/stack.yaml +1 -1
  49. data/tracks/haskell/exercises/binary-search-tree/stack.yaml +1 -1
  50. data/tracks/haskell/exercises/bob/stack.yaml +1 -1
  51. data/tracks/haskell/exercises/bowling/HINTS.md +19 -0
  52. data/tracks/haskell/exercises/bowling/examples/success-standard/package.yaml +16 -0
  53. data/tracks/haskell/exercises/bowling/examples/success-standard/src/Bowling.hs +84 -0
  54. data/tracks/haskell/exercises/bowling/package.yaml +19 -0
  55. data/tracks/haskell/exercises/bowling/src/Bowling.hs +9 -0
  56. data/tracks/haskell/exercises/bowling/stack.yaml +1 -0
  57. data/tracks/haskell/exercises/bowling/test/Tests.hs +143 -0
  58. data/tracks/haskell/exercises/change/stack.yaml +1 -1
  59. data/tracks/haskell/exercises/clock/stack.yaml +1 -1
  60. data/tracks/haskell/exercises/connect/stack.yaml +1 -1
  61. data/tracks/haskell/exercises/crypto-square/stack.yaml +1 -1
  62. data/tracks/haskell/exercises/custom-set/stack.yaml +1 -1
  63. data/tracks/haskell/exercises/difference-of-squares/stack.yaml +1 -1
  64. data/tracks/haskell/exercises/dominoes/stack.yaml +1 -1
  65. data/tracks/haskell/exercises/etl/stack.yaml +1 -1
  66. data/tracks/haskell/exercises/food-chain/stack.yaml +1 -1
  67. data/tracks/haskell/exercises/forth/stack.yaml +1 -1
  68. data/tracks/haskell/exercises/gigasecond/stack.yaml +1 -1
  69. data/tracks/haskell/exercises/go-counting/stack.yaml +1 -1
  70. data/tracks/haskell/exercises/grade-school/stack.yaml +1 -1
  71. data/tracks/haskell/exercises/grains/stack.yaml +1 -1
  72. data/tracks/haskell/exercises/hamming/stack.yaml +1 -1
  73. data/tracks/haskell/exercises/hexadecimal/stack.yaml +1 -1
  74. data/tracks/haskell/exercises/house/stack.yaml +1 -1
  75. data/tracks/haskell/exercises/kindergarten-garden/stack.yaml +1 -1
  76. data/tracks/haskell/exercises/largest-series-product/stack.yaml +1 -1
  77. data/tracks/haskell/exercises/leap/stack.yaml +1 -1
  78. data/tracks/haskell/exercises/lens-person/stack.yaml +1 -1
  79. data/tracks/haskell/exercises/linked-list/stack.yaml +1 -1
  80. data/tracks/haskell/exercises/list-ops/stack.yaml +1 -1
  81. data/tracks/haskell/exercises/luhn/stack.yaml +1 -1
  82. data/tracks/haskell/exercises/matrix/stack.yaml +1 -1
  83. data/tracks/haskell/exercises/meetup/stack.yaml +1 -1
  84. data/tracks/haskell/exercises/minesweeper/stack.yaml +1 -1
  85. data/tracks/haskell/exercises/nth-prime/stack.yaml +1 -1
  86. data/tracks/haskell/exercises/nucleotide-count/stack.yaml +1 -1
  87. data/tracks/haskell/exercises/ocr-numbers/stack.yaml +1 -1
  88. data/tracks/haskell/exercises/octal/stack.yaml +1 -1
  89. data/tracks/haskell/exercises/palindrome-products/stack.yaml +1 -1
  90. data/tracks/haskell/exercises/parallel-letter-frequency/stack.yaml +1 -1
  91. data/tracks/haskell/exercises/pascals-triangle/stack.yaml +1 -1
  92. data/tracks/haskell/exercises/phone-number/stack.yaml +1 -1
  93. data/tracks/haskell/exercises/pig-latin/stack.yaml +1 -1
  94. data/tracks/haskell/exercises/pov/stack.yaml +1 -1
  95. data/tracks/haskell/exercises/prime-factors/stack.yaml +1 -1
  96. data/tracks/haskell/exercises/pythagorean-triplet/stack.yaml +1 -1
  97. data/tracks/haskell/exercises/queen-attack/stack.yaml +1 -1
  98. data/tracks/haskell/exercises/raindrops/stack.yaml +1 -1
  99. data/tracks/haskell/exercises/rna-transcription/stack.yaml +1 -1
  100. data/tracks/haskell/exercises/robot-name/stack.yaml +1 -1
  101. data/tracks/haskell/exercises/robot-simulator/stack.yaml +1 -1
  102. data/tracks/haskell/exercises/roman-numerals/stack.yaml +1 -1
  103. data/tracks/haskell/exercises/saddle-points/stack.yaml +1 -1
  104. data/tracks/haskell/exercises/say/stack.yaml +1 -1
  105. data/tracks/haskell/exercises/scrabble-score/stack.yaml +1 -1
  106. data/tracks/haskell/exercises/secret-handshake/stack.yaml +1 -1
  107. data/tracks/haskell/exercises/series/stack.yaml +1 -1
  108. data/tracks/haskell/exercises/sgf-parsing/stack.yaml +1 -1
  109. data/tracks/haskell/exercises/sieve/stack.yaml +1 -1
  110. data/tracks/haskell/exercises/simple-cipher/stack.yaml +1 -1
  111. data/tracks/haskell/exercises/simple-linked-list/stack.yaml +1 -1
  112. data/tracks/haskell/exercises/space-age/stack.yaml +1 -1
  113. data/tracks/haskell/exercises/strain/stack.yaml +1 -1
  114. data/tracks/haskell/exercises/sublist/stack.yaml +1 -1
  115. data/tracks/haskell/exercises/sum-of-multiples/stack.yaml +1 -1
  116. data/tracks/haskell/exercises/triangle/stack.yaml +1 -1
  117. data/tracks/haskell/exercises/trinary/stack.yaml +1 -1
  118. data/tracks/haskell/exercises/word-count/stack.yaml +1 -1
  119. data/tracks/haskell/exercises/wordy/stack.yaml +1 -1
  120. data/tracks/haskell/exercises/zebra-puzzle/stack.yaml +1 -1
  121. data/tracks/haskell/exercises/zipper/stack.yaml +1 -1
  122. data/tracks/java/config.json +13 -1
  123. data/tracks/java/exercises/etl/src/main/java/Etl.java +3 -3
  124. data/tracks/java/exercises/hello-world/GETTING_STARTED.md +1 -1
  125. data/tracks/java/exercises/hello-world/src/main/java/HelloWorld.java +3 -3
  126. data/tracks/java/exercises/minesweeper/build.gradle +17 -0
  127. data/tracks/java/exercises/minesweeper/src/example/java/MinesweeperBoard.java +111 -0
  128. data/tracks/java/exercises/minesweeper/src/main/java/MinesweeperBoard.java +5 -0
  129. data/tracks/java/exercises/minesweeper/src/test/java/MinesweeperBoardTest.java +295 -0
  130. data/tracks/java/exercises/nucleotide-count/src/test/java/NucleotideTest.java +67 -67
  131. data/tracks/java/exercises/series/build.gradle +18 -0
  132. data/tracks/java/exercises/series/src/example/java/Series.java +39 -0
  133. data/tracks/java/exercises/series/src/main/java/.keep +0 -0
  134. data/tracks/java/exercises/series/src/main/java/Series.java +3 -0
  135. data/tracks/java/exercises/series/src/test/java/.keep +0 -0
  136. data/tracks/java/exercises/series/src/test/java/SeriesTest.java +154 -0
  137. data/tracks/java/exercises/settings.gradle +2 -0
  138. data/tracks/javascript/exercises/custom-set/custom-set.spec.js +130 -84
  139. data/tracks/javascript/exercises/custom-set/example-gen.js +200 -0
  140. data/tracks/ocaml/Makefile +5 -1
  141. data/tracks/ocaml/config.json +2 -1
  142. data/tracks/ocaml/exercises/anagram/test.ml +35 -24
  143. data/tracks/ocaml/exercises/bob/example.ml +1 -1
  144. data/tracks/ocaml/exercises/bob/test.ml +53 -40
  145. data/tracks/ocaml/exercises/hamming/test.ml +41 -31
  146. data/tracks/ocaml/exercises/raindrops/test.ml +38 -39
  147. data/tracks/ocaml/tools/test-generator/.merlin +5 -0
  148. data/tracks/ocaml/tools/test-generator/Makefile +15 -0
  149. data/tracks/ocaml/tools/test-generator/_tags +0 -0
  150. data/tracks/ocaml/tools/test-generator/src/codegen.ml +17 -0
  151. data/tracks/ocaml/tools/test-generator/src/codegen.mli +7 -0
  152. data/tracks/ocaml/tools/test-generator/src/leap.json +39 -0
  153. data/tracks/ocaml/tools/test-generator/src/model.ml +31 -0
  154. data/tracks/ocaml/tools/test-generator/src/parser.ml +61 -0
  155. data/tracks/ocaml/tools/test-generator/src/parser.mli +9 -0
  156. data/tracks/ocaml/tools/test-generator/src/special_cases.ml +12 -0
  157. data/tracks/ocaml/tools/test-generator/src/special_cases.mli +7 -0
  158. data/tracks/ocaml/tools/test-generator/src/test_gen.ml +25 -0
  159. data/tracks/ocaml/tools/test-generator/src/test_generator.ml +62 -0
  160. data/tracks/ocaml/tools/test-generator/src/test_generator.mli +6 -0
  161. data/tracks/ocaml/tools/test-generator/src/utils.ml +32 -0
  162. data/tracks/ocaml/tools/test-generator/src/utils.mli +18 -0
  163. data/tracks/ocaml/tools/test-generator/templates/anagram/template.ml +17 -0
  164. data/tracks/ocaml/tools/test-generator/templates/bob/template.ml +15 -0
  165. data/tracks/ocaml/tools/test-generator/templates/hamming/template.ml +30 -0
  166. data/tracks/ocaml/tools/test-generator/templates/leap/template.ml +15 -0
  167. data/tracks/ocaml/tools/test-generator/templates/raindrops/template.ml +15 -0
  168. data/tracks/ocaml/tools/test-generator/templates/word-count/template.ml +19 -0
  169. data/tracks/ocaml/tools/test-generator/test/all_tests.ml +11 -0
  170. data/tracks/ocaml/tools/test-generator/test/codegen_test.ml +20 -0
  171. data/tracks/ocaml/tools/test-generator/test/model_test.ml +27 -0
  172. data/tracks/ocaml/tools/test-generator/test/parser_test.ml +73 -0
  173. data/tracks/ocaml/tools/test-generator/test/special_cases_test.ml +22 -0
  174. data/tracks/ocaml/tools/test-generator/test/test_generator_test.ml +11 -0
  175. data/tracks/ocaml/tools/test-generator/test/utils_test.ml +21 -0
  176. data/tracks/perl5/config.json +1 -1
  177. data/tracks/perl6/accumulate/accumulate.t +8 -2
  178. data/tracks/perl6/anagram/Example.pm +1 -1
  179. data/tracks/perl6/anagram/anagram.t +7 -8
  180. data/tracks/perl6/binary/Example.pm +1 -1
  181. data/tracks/perl6/binary/binary.t +7 -8
  182. data/tracks/perl6/bob/bob.t +1 -3
  183. data/tracks/perl6/config.json +1 -0
  184. data/tracks/perl6/grains/grains.t +7 -2
  185. data/tracks/perl6/leap/leap.t +3 -1
  186. data/tracks/perl6/raindrops/raindrops.t +8 -2
  187. data/tracks/perl6/rna-transcription/rna_transcription.t +8 -9
  188. data/tracks/perl6/robot-name/robot.t +8 -9
  189. data/tracks/perl6/scrabble-score/Example.pm +1 -1
  190. data/tracks/perl6/scrabble-score/scrabble_score.t +8 -2
  191. data/tracks/perl6/word-count/word_count.t +8 -2
  192. data/tracks/php/config.json +5 -0
  193. data/tracks/php/exercises/markdown/example.php +85 -0
  194. data/tracks/php/exercises/markdown/markdown.php +82 -0
  195. data/tracks/php/exercises/markdown/markdown_test.php +57 -0
  196. data/tracks/python/exercises/hamming/example.py +3 -0
  197. data/tracks/python/exercises/hamming/hamming_test.py +40 -14
  198. data/tracks/python/exercises/rna-transcription/example.py +6 -1
  199. data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +9 -0
  200. data/tracks/ruby/config.json +6 -0
  201. data/tracks/ruby/exercises/dominoes/.version +1 -0
  202. data/tracks/ruby/exercises/dominoes/dominoes_test.rb +149 -0
  203. data/tracks/ruby/exercises/dominoes/example.rb +37 -0
  204. data/tracks/ruby/exercises/dominoes/example.tt +57 -0
  205. data/tracks/ruby/exercises/pangram/.version +1 -1
  206. data/tracks/ruby/exercises/pangram/example.rb +2 -2
  207. data/tracks/ruby/exercises/pangram/example.tt +5 -7
  208. data/tracks/ruby/exercises/pangram/pangram_test.rb +30 -25
  209. data/tracks/ruby/exercises/queen-attack/.version +1 -0
  210. data/tracks/ruby/exercises/queen-attack/example.rb +5 -30
  211. data/tracks/ruby/exercises/queen-attack/example.tt +22 -0
  212. data/tracks/ruby/exercises/queen-attack/queen_attack_test.rb +46 -95
  213. data/tracks/ruby/exercises/triangle/.version +1 -0
  214. data/tracks/ruby/exercises/triangle/example.rb +15 -22
  215. data/tracks/ruby/exercises/triangle/example.tt +20 -0
  216. data/tracks/ruby/exercises/triangle/triangle_test.rb +80 -40
  217. data/tracks/ruby/lib/dominoes_cases.rb +23 -0
  218. data/tracks/ruby/lib/pangram_cases.rb +19 -4
  219. data/tracks/ruby/lib/queen_attack_cases.rb +54 -0
  220. data/tracks/ruby/lib/triangle_cases.rb +51 -0
  221. data/tracks/scala/config.json +6 -0
  222. data/tracks/scala/exercises/dominoes/Example.scala +41 -0
  223. data/tracks/scala/exercises/dominoes/build.sbt +3 -0
  224. data/tracks/scala/exercises/dominoes/src/main/scala/Dominoes.scala +4 -0
  225. data/tracks/scala/exercises/dominoes/src/test/scala/DominoesSuite.scala +91 -0
  226. metadata +83 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b7fb0f61f9c8eeb36237b4d667c18c9a637d465
4
- data.tar.gz: 24aa9513475689221e00ddad5585c67e64047858
3
+ metadata.gz: 8b7052e1aa34da1303db05680e424c5e292e29be
4
+ data.tar.gz: 74176fc6e34d0e6a9549d763f537418d2ed523f8
5
5
  SHA512:
6
- metadata.gz: 116e406aaeb2ddd1cd16ce8aee2774f44974b5694a6270b5953edc510e1536c3d75edaf2777c1c41fe4dd6e6b3b56c86231fcb19c15f154a3293d69feea6aeac
7
- data.tar.gz: ce7b0811e5696f6c036afa6d51306636af107bd5c892bc91a2623726d3eaa28e7421609aadc711776c418bf6ed953a0437542300b590f5a4f80f6e81bbc15e59
6
+ metadata.gz: 1f950ed2480962dab6eb855c6b332fbbe8d9de480b0990db072ada4986bac5fa84461212eb34cfeb0ce9b13c1d05d309ec485c0d665ab6329c3aa4cebe63ef43
7
+ data.tar.gz: 90e9f0168b2d5e463abec0a322b5e942162dc2db55f90577a90ee5527e1977ca52de495fa8e0b388ae60108d980c9851fb015deccb7c97253a90f9d1a548d114
@@ -1,13 +1,4 @@
1
1
  {
2
- "#": [
3
- "For 'gibberish', some languages generate a random strings.",
4
- "Similarly for 'prolonged silence' and 'alternate silence' some",
5
- "languages generate random length strings of a whitespace character.",
6
- "",
7
- "The \\u escaped 'other' whitespace (in case you don't have all of",
8
- "these codes memorized) are b: vertical tab, a0: non-breaking space,",
9
- "and 2002: en-space."
10
- ],
11
2
  "cases": [
12
3
  {
13
4
  "description": "stating something",
@@ -74,16 +65,6 @@
74
65
  "input": "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!",
75
66
  "expected": "Whoa, chill out!"
76
67
  },
77
- {
78
- "description": "shouting with umlauts",
79
- "input": "ÜMLÄÜTS!",
80
- "expected": "Whoa, chill out!"
81
- },
82
- {
83
- "description": "calmly speaking with umlauts",
84
- "input": "ÜMLäÜTS!",
85
- "expected": "Whatever."
86
- },
87
68
  {
88
69
  "description": "shouting with no exclamation mark",
89
70
  "input": "I HATE YOU",
@@ -136,7 +117,7 @@
136
117
  },
137
118
  {
138
119
  "description": "other whitespace",
139
- "input": "\n\r \t\u000b\u00a0\u2002",
120
+ "input": "\n\r \t",
140
121
  "expected": "Fine. Be that way!"
141
122
  },
142
123
  {
@@ -1,74 +1,92 @@
1
1
  {
2
2
  "cases": [
3
3
  {
4
+ "description" : "the sound for 1 is 1",
4
5
  "number" : 1,
5
6
  "expected": "1"
6
7
  },
7
8
  {
9
+ "description" : "the sound for 3 is Pling",
8
10
  "number" : 3,
9
11
  "expected": "Pling"
10
12
  },
11
13
  {
14
+ "description" : "the sound for 5 is Plang",
12
15
  "number" : 5,
13
16
  "expected": "Plang"
14
17
  },
15
18
  {
19
+ "description" : "the sound for 7 is Plong",
16
20
  "number" : 7,
17
21
  "expected": "Plong"
18
22
  },
19
23
  {
24
+ "description" : "the sound for 6 is Pling as it has a factor 3",
20
25
  "number" : 6,
21
26
  "expected": "Pling"
22
27
  },
23
28
  {
29
+ "description" : "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base",
24
30
  "number" : 8,
25
31
  "expected": "8"
26
32
  },
27
33
  {
34
+ "description" : "the sound for 9 is Pling as it has a factor 3",
28
35
  "number" : 9,
29
36
  "expected": "Pling"
30
37
  },
31
38
  {
39
+ "description" : "the sound for 10 is Plang as it has a factor 5",
32
40
  "number" : 10,
33
41
  "expected": "Plang"
34
42
  },
35
43
  {
44
+ "description" : "the sound for 14 is Plong as it has a factor of 7",
36
45
  "number" : 14,
37
46
  "expected": "Plong"
38
47
  },
39
48
  {
49
+ "description" : "the sound for 15 is PlingPlang as it has factors 3 and 5",
40
50
  "number" : 15,
41
51
  "expected": "PlingPlang"
42
52
  },
43
53
  {
54
+ "description" : "the sound for 21 is PlingPlong as it has factors 3 and 7",
44
55
  "number" : 21,
45
56
  "expected": "PlingPlong"
46
57
  },
47
58
  {
59
+ "description" : "the sound for 25 is Plang as it has a factor 5",
48
60
  "number" : 25,
49
61
  "expected": "Plang"
50
62
  },
51
63
  {
64
+ "description" : "the sound for 27 is Pling as it has a factor 3",
52
65
  "number" : 27,
53
66
  "expected": "Pling"
54
67
  },
55
68
  {
69
+ "description" : "the sound for 35 is PlangPlong as it has factors 5 and 7",
56
70
  "number" : 35,
57
71
  "expected": "PlangPlong"
58
72
  },
59
73
  {
74
+ "description" : "the sound for 49 is Plong as it has a factor 7",
60
75
  "number" : 49,
61
76
  "expected": "Plong"
62
77
  },
63
78
  {
79
+ "description" : "the sound for 52 is 52",
64
80
  "number" : 52,
65
81
  "expected": "52"
66
82
  },
67
83
  {
84
+ "description" : "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7",
68
85
  "number" : 105,
69
86
  "expected": "PlingPlangPlong"
70
87
  },
71
88
  {
89
+ "description" : "the sound for 3125 is Plang as it has a factor 5",
72
90
  "number" : 3125,
73
91
  "expected": "Plang"
74
92
  }
@@ -92,5 +92,10 @@
92
92
  "list_one": [1, 2, 3],
93
93
  "list_two": [3, 2, 1],
94
94
  "expectation": "unequal"
95
+ }, {
96
+ "description": "same digits but different numbers",
97
+ "list_one": [1, 0, 1],
98
+ "list_two": [10, 1],
99
+ "expectation": "unequal"
95
100
  }]
96
101
  }
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.0.8"
2
+ VERSION = "2.0.0.9"
3
3
  end
@@ -280,6 +280,11 @@
280
280
  "difficulty": 1,
281
281
  "slug": "isogram",
282
282
  "topics": []
283
+ },
284
+ {
285
+ "difficulty": 1,
286
+ "slug": "pig-latin",
287
+ "topics": []
283
288
  }
284
289
  ]
285
290
  }
@@ -0,0 +1,4 @@
1
+ (defproject pig-latin "0.1.0-SNAPSHOT"
2
+ :description "pig latin exercise."
3
+ :url "https://github.com/exercism/xclojure/tree/master/exercises/pig-latin"
4
+ :dependencies [[org.clojure/clojure "1.8.0"]])
@@ -0,0 +1,49 @@
1
+ (ns pig-latin
2
+ (:require [clojure.string :as str]))
3
+
4
+ (defn- starts-with-any [prefixes word]
5
+ (some (partial str/starts-with? word) prefixes))
6
+
7
+ (defn- starts-with-vowel-like? [word]
8
+ (starts-with-any #{"yt" "xr"} word))
9
+
10
+ (defn- starts-with-vowel? [word]
11
+ (starts-with-any #{"a" "e" "i" "o" "u"} word))
12
+
13
+ (defn- starts-with-two-letter-prefix? [word]
14
+ (starts-with-any #{"ch" "qu" "th"} word))
15
+
16
+ (defn- starts-with-three-letter-prefix? [word]
17
+ (starts-with-any #{"thr" "sch"} word))
18
+
19
+ (defn- starts-with-qu-and-preceeding-constanant? [word]
20
+ (and (not (starts-with-vowel? word))
21
+ (str/starts-with? (subs word 1) "qu")))
22
+
23
+ (defn- rotate [word n]
24
+ (str (subs word n) (subs word 0 n)))
25
+
26
+ (defn- append-ay [word]
27
+ (str word "ay"))
28
+
29
+ (defn- translate-word [word]
30
+ (cond
31
+ (or (starts-with-vowel? word)
32
+ (starts-with-vowel-like? word))
33
+ (append-ay word)
34
+
35
+ (or
36
+ (starts-with-three-letter-prefix? word)
37
+ (starts-with-qu-and-preceeding-constanant? word))
38
+ (append-ay (rotate word 3))
39
+
40
+ (starts-with-two-letter-prefix? word)
41
+ (append-ay (rotate word 2))
42
+
43
+ :else
44
+ (append-ay (rotate word 1))))
45
+
46
+ (defn translate [words]
47
+ (->> (str/split words #" ")
48
+ (map translate-word)
49
+ (str/join " ")))
@@ -0,0 +1,92 @@
1
+ (ns pig-latin-test
2
+ (:require [clojure.test :refer [deftest is]]
3
+ pig-latin))
4
+
5
+ ;; ay is added to words that start with vowels
6
+
7
+ (deftest word-beginning-with-a
8
+ (is (= "appleay"
9
+ (pig-latin/translate "apple"))))
10
+
11
+ (deftest word-beginning-with-e
12
+ (is (= "earay"
13
+ (pig-latin/translate "ear"))))
14
+
15
+ (deftest word-beginning-with-i
16
+ (is (= "iglooay"
17
+ (pig-latin/translate "igloo"))))
18
+
19
+ (deftest word-beginning-with-o
20
+ (is (= "objectay"
21
+ (pig-latin/translate "object"))))
22
+
23
+ (deftest word-beginning-with-u
24
+ (is (= "underay"
25
+ (pig-latin/translate "under"))))
26
+
27
+ (deftest word-beginning-with-a-vowel-and-followed-by-a-qu
28
+ (is (= "equalay"
29
+ (pig-latin/translate "equal"))))
30
+
31
+ ;; first letter and ay are moved to the end of words that start with consonants
32
+
33
+ (deftest word-beginning-with-p
34
+ (is (= "igpay"
35
+ (pig-latin/translate "pig"))))
36
+
37
+ (deftest word-beginning-with-k
38
+ (is (= "oalakay"
39
+ (pig-latin/translate "koala"))))
40
+
41
+ (deftest word-beginning-with-y
42
+ (is (= "ellowyay"
43
+ (pig-latin/translate "yellow"))))
44
+
45
+ (deftest word-beginning-with-x
46
+ (is (= "enonxay"
47
+ (pig-latin/translate "xenon"))))
48
+
49
+ (deftest word-beginning-with-q-without-a-following-u
50
+ (is (= "atqay"
51
+ (pig-latin/translate "qat"))))
52
+
53
+ ;; some letter clusters are treated like a single consonant
54
+
55
+ (deftest word-beginning-with-ch
56
+ (is (= "airchay"
57
+ (pig-latin/translate "chair"))))
58
+
59
+ (deftest word-beginning-with-qu
60
+ (is (= "eenquay"
61
+ (pig-latin/translate "queen"))))
62
+
63
+ (deftest word-beginning-with-qu-and-a-preceding-consonant
64
+ (is (= "aresquay"
65
+ (pig-latin/translate "square"))))
66
+
67
+ (deftest word-beginning-with-th
68
+ (is (= "erapythay"
69
+ (pig-latin/translate "therapy"))))
70
+
71
+ (deftest word-beginning-with-thr
72
+ (is (= "ushthray"
73
+ (pig-latin/translate "thrush"))))
74
+
75
+ (deftest word-beginning-with-sch
76
+ (is (= "oolschay"
77
+ (pig-latin/translate "school"))))
78
+
79
+ ;; some letter clusters are treated like a single vowel
80
+
81
+ (deftest word-beginning-with-yt
82
+ (is (= "yttriaay"
83
+ (pig-latin/translate "yttria"))))
84
+
85
+ (deftest word-beginning-with-xr
86
+ (is (= "xrayay"
87
+ (pig-latin/translate "xray"))))
88
+
89
+ ;; phrases are translated
90
+ (deftest a-whole-phrase
91
+ (is (= "ickquay astfay unray"
92
+ (pig-latin/translate "quick fast run"))))
@@ -1,19 +1,16 @@
1
1
  (ns robot-name)
2
2
 
3
- (defn robot []
4
- {:name (atom "")})
5
-
6
- (def random (java.util.Random.))
7
- (def letters (map char (range 65 91)))
8
- (defn generate-name []
3
+ (def ^:private random (java.util.Random.))
4
+ (def ^:private letters (map char (range 65 91)))
5
+ (defn- generate-name []
9
6
  (str (apply str (take 2 (shuffle letters)))
10
7
  (+ 100 (.nextInt random 899))))
11
8
 
9
+ (defn robot []
10
+ (atom {:name (generate-name)}))
11
+
12
12
  (defn robot-name [robot]
13
- (let [n @(:name robot)]
14
- (if (= "" n)
15
- (swap! (:name robot) #(str %1 (generate-name)))
16
- n)))
13
+ (:name @robot))
17
14
 
18
15
  (defn reset-name [robot]
19
- (swap! (:name robot) (fn [_] "")))
16
+ (swap! robot assoc :name (generate-name)))
@@ -2,25 +2,30 @@
2
2
  (:require [clojure.test :refer [deftest is testing]]
3
3
  robot-name))
4
4
 
5
- (def ^:private robbie (robot-name/robot))
6
- (def ^:private clutz (robot-name/robot))
7
-
8
5
  (deftest robot-name
9
- (testing "robot-name"
10
- (is (re-seq #"[A-Z]{2}\d{3}" (robot-name/robot-name robbie))
11
- "name matches expected pattern")
12
- (is (= (robot-name/robot-name robbie) (robot-name/robot-name robbie))
13
- "name is persistent")
14
- (is (not= (robot-name/robot-name clutz) (robot-name/robot-name robbie))
15
- "different robots have different names")))
6
+ (let [a-robot (robot-name/robot)
7
+ its-name (robot-name/robot-name a-robot)]
8
+ (testing "robot-name"
9
+ (is (re-seq #"[A-Z]{2}\d{3}" its-name)
10
+ "name matches expected pattern")
11
+ (is (= its-name (robot-name/robot-name a-robot))
12
+ "name doesn't change until you reset it")
13
+ (is (not= its-name (-> (robot-name/robot) robot-name/robot-name))
14
+ "different robots have different names"))))
16
15
 
17
16
  (deftest reset-name
18
- (testing "reset-name"
19
- (let [original-name (robot-name/robot-name robbie)]
20
- (robot-name/reset-name robbie)
21
- (is (re-seq #"[A-Z]{2}\d{3}" (robot-name/robot-name robbie))
17
+ (let [a-robot (robot-name/robot)
18
+ its-original-name (robot-name/robot-name a-robot)
19
+ its-new-name (do (robot-name/reset-name a-robot)
20
+ (robot-name/robot-name a-robot))]
21
+
22
+ (testing "reset-name"
23
+ (is (re-seq #"[A-Z]{2}\d{3}" its-new-name)
22
24
  "new name matches expected pattern")
23
- (is (= (robot-name/robot-name robbie) (robot-name/robot-name robbie))
24
- "new name is persistent")
25
- (is (not= original-name (robot-name/robot-name robbie))
26
- "new name is different from old name"))))
25
+ (is (not= its-original-name its-new-name)
26
+ "new name is different from old name")
27
+ (is (= its-new-name (robot-name/robot-name a-robot))
28
+ "new name doesn't change until you reset it")
29
+ (is (not= its-new-name (do (robot-name/reset-name a-robot)
30
+ (robot-name/robot-name a-robot)))
31
+ "new names are different each time"))))
@@ -118,6 +118,12 @@
118
118
  "difficulty": 1,
119
119
  "topics": [
120
120
  ]
121
+ },
122
+ {
123
+ "slug": "forth",
124
+ "difficulty": 3,
125
+ "topics": [
126
+ ]
121
127
  }
122
128
  ],
123
129
  "deprecated": [
@@ -2,31 +2,31 @@ require "spec"
2
2
  require "../src/*"
3
3
 
4
4
  describe "Acronym" do
5
- it "tests basic" do
5
+ it "does basic" do
6
6
  Acronym.abbreviate("Portable Network Graphics").should eq("PNG")
7
7
  end
8
8
 
9
- it "tests lowercase words" do
9
+ pending "does lowercase words" do
10
10
  Acronym.abbreviate("Ruby on Rails").should eq("ROR")
11
11
  end
12
12
 
13
- it "tests camelcase" do
13
+ pending "does camelcase" do
14
14
  Acronym.abbreviate("HyperText Markup Language").should eq("HTML")
15
15
  end
16
16
 
17
- it "tests punctuation" do
17
+ pending "does punctuation" do
18
18
  Acronym.abbreviate("First In, First Out").should eq("FIFO")
19
19
  end
20
20
 
21
- it "tests all caps words" do
21
+ pending "does all caps words" do
22
22
  Acronym.abbreviate("PHP: Hypertext Preprocessor").should eq("PHP")
23
23
  end
24
24
 
25
- it "tests non-acronym all caps word" do
25
+ pending "does non-acronym all caps word" do
26
26
  Acronym.abbreviate("GNU Image Manipulation Program").should eq("GIMP")
27
27
  end
28
28
 
29
- it "tests hyphenated" do
29
+ pending "does hyphenated" do
30
30
  Acronym.abbreviate("Complementary metal-oxide semiconductor").should eq("CMOS")
31
31
  end
32
32
  end
@@ -0,0 +1,198 @@
1
+ require "spec"
2
+ require "../src/*"
3
+
4
+ describe "Forth" do
5
+ it "empty input results in empty stack" do
6
+ Forth.evaluate("").should eq([] of Int32)
7
+ end
8
+
9
+ pending "numbers just get pushed onto the stack" do
10
+ Forth.evaluate("1 2 3 4 5").should eq([1, 2, 3, 4, 5])
11
+ end
12
+
13
+ pending "all non-word characters are separators" do
14
+ Forth.evaluate("1\u{0}2\u{13}3\n4\r5 6\t7").should eq([1, 2, 3, 4, 5, 6, 7])
15
+ end
16
+
17
+ pending "can add two numbers" do
18
+ Forth.evaluate("1 2 +").should eq([3])
19
+ end
20
+
21
+ pending "errors if there is nothing on the stack" do
22
+ expect_raises do
23
+ Forth.evaluate("+")
24
+ end
25
+ end
26
+
27
+ pending "errors if there is only one value on the stack" do
28
+ expect_raises do
29
+ Forth.evaluate("1 +")
30
+ end
31
+ end
32
+
33
+ pending "can subtract two numbers" do
34
+ Forth.evaluate("3 4 -").should eq([-1])
35
+ end
36
+
37
+ pending "errors if there is nothing on the stack" do
38
+ expect_raises do
39
+ Forth.evaluate("-")
40
+ end
41
+ end
42
+
43
+ pending "errors if there is only one value on the stack" do
44
+ expect_raises do
45
+ Forth.evaluate("1 -")
46
+ end
47
+ end
48
+
49
+ pending "can multiply two numbers" do
50
+ Forth.evaluate("2 4 *").should eq([8])
51
+ end
52
+
53
+ pending "errors if there is nothing on the stack" do
54
+ expect_raises do
55
+ Forth.evaluate("*")
56
+ end
57
+ end
58
+
59
+ pending "errors if there is only one value on the stack" do
60
+ expect_raises do
61
+ Forth.evaluate("1 *")
62
+ end
63
+ end
64
+
65
+ pending "can divide two numbers" do
66
+ Forth.evaluate("12 3 /").should eq([4])
67
+ end
68
+
69
+ pending "performs integer division" do
70
+ Forth.evaluate("8 3 /").should eq([2])
71
+ end
72
+
73
+ pending "errors if dividing by zero" do
74
+ expect_raises do
75
+ Forth.evaluate("4 0 /")
76
+ end
77
+ end
78
+
79
+ pending "errors if there is nothing on the stack" do
80
+ expect_raises do
81
+ Forth.evaluate("/")
82
+ end
83
+ end
84
+
85
+ pending "errors if there is only one value on the stack" do
86
+ expect_raises do
87
+ Forth.evaluate("1 /")
88
+ end
89
+ end
90
+
91
+ pending "addition and subtraction" do
92
+ Forth.evaluate("1 2 + 4 -").should eq([-1])
93
+ end
94
+
95
+ pending "multiplication and division" do
96
+ Forth.evaluate("2 4 * 3 /").should eq([2])
97
+ end
98
+
99
+ pending "copies the top value on the stack" do
100
+ Forth.evaluate("1 DUP").should eq([1, 1])
101
+ end
102
+
103
+ pending "is case-insensitive" do
104
+ Forth.evaluate("1 2 Dup").should eq([1, 2, 2])
105
+ end
106
+
107
+ pending "errors if there is nothing on the stack" do
108
+ expect_raises do
109
+ Forth.evaluate("dup")
110
+ end
111
+ end
112
+
113
+ pending "removes the top value on the stack if it is the only one" do
114
+ Forth.evaluate("1 drop").should eq([] of Int32)
115
+ end
116
+
117
+ pending "removes the top value on the stack if it is not the only one" do
118
+ Forth.evaluate("1 2 drop").should eq([1])
119
+ end
120
+
121
+ pending "errors if there is nothing on the stack" do
122
+ expect_raises do
123
+ Forth.evaluate("drop")
124
+ end
125
+ end
126
+
127
+ pending "swaps the top two values on the stack if they are the only ones" do
128
+ Forth.evaluate("1 2 swap").should eq([2, 1])
129
+ end
130
+
131
+ pending "swaps the top two values on the stack if they are not the only ones" do
132
+ Forth.evaluate("1 2 3 swap").should eq([1, 3, 2])
133
+ end
134
+
135
+ pending "errors if there is nothing on the stack" do
136
+ expect_raises do
137
+ Forth.evaluate("swap")
138
+ end
139
+ end
140
+
141
+ pending "errors if there is only one value on the stack" do
142
+ expect_raises do
143
+ Forth.evaluate("1 swap")
144
+ end
145
+ end
146
+
147
+ pending "copies the second element if there are only two" do
148
+ Forth.evaluate("1 2 over").should eq([1, 2, 1])
149
+ end
150
+
151
+ pending "copies the second element if there are more than two" do
152
+ Forth.evaluate("1 2 3 over").should eq([1, 2, 3, 2])
153
+ end
154
+
155
+ pending "errors if there is nothing on the stack" do
156
+ expect_raises do
157
+ Forth.evaluate("over")
158
+ end
159
+ end
160
+
161
+ pending "errors if there is only one value on the stack" do
162
+ expect_raises do
163
+ Forth.evaluate("1 over")
164
+ end
165
+ end
166
+
167
+ pending "can consist of built-in words" do
168
+ Forth.evaluate(": dup-twice dup dup ;1 dup-twice").should eq([1, 1, 1])
169
+ end
170
+
171
+ pending "execute in the right order" do
172
+ Forth.evaluate(": countup 1 2 3 ;countup").should eq([1, 2, 3])
173
+ end
174
+
175
+ pending "can override other user-defined words" do
176
+ Forth.evaluate(": foo dup ;: foo dup dup ;1 foo").should eq([1, 1, 1])
177
+ end
178
+
179
+ pending "can override built-in words" do
180
+ Forth.evaluate(": swap dup ;1 swap").should eq([1, 1])
181
+ end
182
+
183
+ pending "can consist of arbitrary characters such as Unicode characters" do
184
+ Forth.evaluate(": € 220371 ; €").should eq([220371])
185
+ end
186
+
187
+ pending "cannot redefine numbers" do
188
+ expect_raises do
189
+ Forth.evaluate(": 1 2 ;")
190
+ end
191
+ end
192
+
193
+ pending "errors if executing a non-existent word" do
194
+ expect_raises do
195
+ Forth.evaluate("foo")
196
+ end
197
+ end
198
+ end