trackler 1.0.0 → 1.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -0
  3. data/CHANGELOG.md +9 -1
  4. data/README.md +10 -0
  5. data/common/CONTRIBUTING.md +50 -2
  6. data/common/exercises/alphametics/canonical-data.json +10 -10
  7. data/common/exercises/markdown/canonical-data.json +4 -4
  8. data/common/exercises/pov/canonical-data.json +356 -0
  9. data/lib/trackler/version.rb +1 -1
  10. data/trackler.gemspec +1 -2
  11. data/tracks/c/config.json +11 -1
  12. data/tracks/c/exercises/binary-search/makefile +16 -0
  13. data/tracks/c/exercises/binary-search/src/example.c +21 -0
  14. data/tracks/c/exercises/binary-search/src/example.h +8 -0
  15. data/tracks/c/exercises/binary-search/test/test_binary_search.c +99 -0
  16. data/tracks/c/exercises/binary-search/test/vendor/unity.c +1300 -0
  17. data/tracks/c/exercises/binary-search/test/vendor/unity.h +274 -0
  18. data/tracks/c/exercises/binary-search/test/vendor/unity_internals.h +701 -0
  19. data/tracks/clojure/config.json +3 -2
  20. data/tracks/clojure/exercises/bank-account/project.clj +4 -0
  21. data/tracks/clojure/exercises/bank-account/src/example.clj +17 -0
  22. data/tracks/clojure/exercises/bank-account/test/bank_account_test.clj +44 -0
  23. data/tracks/clojure/exercises/isogram/project.clj +4 -0
  24. data/tracks/clojure/exercises/isogram/src/example.clj +5 -0
  25. data/tracks/clojure/exercises/isogram/test/isogram_test.clj +17 -0
  26. data/tracks/csharp/config.json +27 -87
  27. data/tracks/csharp/exercises/exercises.csproj +265 -1
  28. data/tracks/csharp/exercises/grep/Example.cs +114 -0
  29. data/tracks/csharp/exercises/grep/GrepTest.cs +376 -0
  30. data/tracks/csharp/exercises/paket.references +2 -1
  31. data/tracks/csharp/exercises/poker/Example.cs +96 -0
  32. data/tracks/csharp/exercises/poker/PokerTest.cs +171 -0
  33. data/tracks/csharp/exercises/sgf-parsing/Example.cs +61 -0
  34. data/tracks/csharp/exercises/sgf-parsing/SgfParsing.cs +13 -0
  35. data/tracks/csharp/exercises/sgf-parsing/SgfParsingTest.cs +158 -0
  36. data/tracks/csharp/paket.dependencies +2 -1
  37. data/tracks/csharp/paket.lock +72 -0
  38. data/tracks/ecmascript/exercises/simple-cipher/simple-cipher.spec.js +1 -1
  39. data/tracks/elisp/config.json +6 -1
  40. data/tracks/elisp/exercises/etl/etl-test.el +90 -0
  41. data/tracks/elisp/exercises/etl/etl.el +9 -0
  42. data/tracks/elisp/exercises/etl/example.el +22 -0
  43. data/tracks/elisp/exercises/nucleotide-count/example.el +19 -0
  44. data/tracks/elisp/exercises/nucleotide-count/nucleotide-count-test.el +34 -0
  45. data/tracks/elisp/exercises/nucleotide-count/nucleotide-count.el +9 -0
  46. data/tracks/elisp/exercises/perfect-numbers/example.el +28 -0
  47. data/tracks/elisp/exercises/perfect-numbers/perfect-numbers-test.el +24 -0
  48. data/tracks/elisp/exercises/perfect-numbers/perfect-numbers.el +10 -0
  49. data/tracks/elisp/exercises/roman-numerals/example.el +36 -0
  50. data/tracks/elisp/exercises/roman-numerals/roman-numerals-test.el +30 -0
  51. data/tracks/elisp/exercises/roman-numerals/roman-numerals.el +10 -0
  52. data/tracks/elisp/exercises/word-count/example.el +18 -0
  53. data/tracks/elisp/exercises/word-count/word-count-test.el +64 -0
  54. data/tracks/elisp/exercises/word-count/word-count.el +9 -0
  55. data/tracks/elixir/README.md +4 -4
  56. data/tracks/elixir/SETUP.md +3 -3
  57. data/tracks/elixir/docs/TESTS.md +3 -3
  58. data/tracks/elixir/exercises/accumulate/accumulate_test.exs +7 -7
  59. data/tracks/elixir/exercises/acronym/acronym_test.exs +5 -5
  60. data/tracks/elixir/exercises/allergies/allergies_test.exs +13 -13
  61. data/tracks/elixir/exercises/anagram/anagram_test.exs +12 -12
  62. data/tracks/elixir/exercises/atbash-cipher/atbash_cipher_test.exs +9 -9
  63. data/tracks/elixir/exercises/bank-account/bank_account_test.exs +5 -5
  64. data/tracks/elixir/exercises/beer-song/beer_song_test.exs +6 -6
  65. data/tracks/elixir/exercises/binary-search/binary_search_test.exs +7 -7
  66. data/tracks/elixir/exercises/binary/binary_test.exs +13 -13
  67. data/tracks/elixir/exercises/bob/bob_test.exs +15 -15
  68. data/tracks/elixir/exercises/bowling/bowling_test.exs +18 -18
  69. data/tracks/elixir/exercises/bracket-push/bracket_push_test.exs +12 -12
  70. data/tracks/elixir/exercises/change/change_test.exs +7 -7
  71. data/tracks/elixir/exercises/connect/connect_test.exs +9 -9
  72. data/tracks/elixir/exercises/crypto-square/crypto_square_test.exs +7 -7
  73. data/tracks/elixir/exercises/custom-set/custom_set_test.exs +11 -11
  74. data/tracks/elixir/exercises/diamond/diamond_test.exs +4 -4
  75. data/tracks/elixir/exercises/difference-of-squares/difference_of_squares_test.exs +10 -10
  76. data/tracks/elixir/exercises/dot-dsl/dot_dsl_test.exs +17 -17
  77. data/tracks/elixir/exercises/etl/etl_test.exs +5 -5
  78. data/tracks/elixir/exercises/flatten-array/flatten_array_test.exs +6 -6
  79. data/tracks/elixir/exercises/forth/forth_test.exs +16 -16
  80. data/tracks/elixir/exercises/gigasecond/gigasecond_test.exs +5 -5
  81. data/tracks/elixir/exercises/grade-school/grade_school_test.exs +6 -6
  82. data/tracks/elixir/exercises/grains/grains_test.exs +9 -9
  83. data/tracks/elixir/exercises/hamming/hamming_test.exs +6 -6
  84. data/tracks/elixir/exercises/hello-world/hello_world_test.exs +3 -3
  85. data/tracks/elixir/exercises/hexadecimal/hexadecimal_test.exs +11 -11
  86. data/tracks/elixir/exercises/isogram/isogram_test.exs +10 -10
  87. data/tracks/elixir/exercises/kindergarten-garden/garden_test.exs +7 -7
  88. data/tracks/elixir/exercises/largest-series-product/largest_series_product_test.exs +17 -17
  89. data/tracks/elixir/exercises/leap/leap_test.exs +5 -5
  90. data/tracks/elixir/exercises/list-ops/list_ops_test.exs +26 -26
  91. data/tracks/elixir/exercises/luhn/luhn_test.exs +7 -7
  92. data/tracks/elixir/exercises/markdown/markdown_test.exs +10 -10
  93. data/tracks/elixir/exercises/meetup/meetup_test.exs +92 -92
  94. data/tracks/elixir/exercises/minesweeper/minesweeper_test.exs +8 -8
  95. data/tracks/elixir/exercises/nth-prime/nth_prime_test.exs +6 -6
  96. data/tracks/elixir/exercises/nucleotide-count/example.exs +0 -5
  97. data/tracks/elixir/exercises/nucleotide-count/nucleotide_count_test.exs +7 -7
  98. data/tracks/elixir/exercises/palindrome-products/palindrome_products_test.exs +6 -6
  99. data/tracks/elixir/exercises/pangram/pangram_test.exs +11 -11
  100. data/tracks/elixir/exercises/parallel-letter-frequency/parallel_letter_frequency_test.exs +10 -10
  101. data/tracks/elixir/exercises/pascals-triangle/pascals_triangle_test.exs +7 -7
  102. data/tracks/elixir/exercises/phone-number/phone_number_test.exs +10 -10
  103. data/tracks/elixir/exercises/prime-factors/prime_factors_test.exs +13 -13
  104. data/tracks/elixir/exercises/pythagorean-triplet/pythagorean_triplet_test.exs +8 -8
  105. data/tracks/elixir/exercises/queen-attack/queen_attack_test.exs +16 -16
  106. data/tracks/elixir/exercises/rail-fence-cipher/rail_fence_cipher_test.exs +13 -13
  107. data/tracks/elixir/exercises/raindrops/raindrops_test.exs +17 -17
  108. data/tracks/elixir/exercises/rna-transcription/rna_transcription_test.exs +6 -6
  109. data/tracks/elixir/exercises/robot-simulator/robot_simulator_test.exs +6 -6
  110. data/tracks/elixir/exercises/roman-numerals/roman_numerals_test.exs +19 -19
  111. data/tracks/elixir/exercises/run-length-encoding/rle_test.exs +6 -6
  112. data/tracks/elixir/exercises/saddle-points/saddle_points_test.exs +11 -11
  113. data/tracks/elixir/exercises/scrabble-score/scrabble_score_test.exs +9 -9
  114. data/tracks/elixir/exercises/sieve/sieve_test.exs +3 -3
  115. data/tracks/elixir/exercises/space-age/space_age_test.exs +9 -9
  116. data/tracks/elixir/exercises/sublist/sublist_test.exs +20 -20
  117. data/tracks/elixir/exercises/sum-of-multiples/sum_of_multiples_test.exs +11 -11
  118. data/tracks/elixir/exercises/test_helper.exs +1 -1
  119. data/tracks/elixir/exercises/triangle/triangle_test.exs +16 -16
  120. data/tracks/elixir/exercises/word-count/word_count_test.exs +9 -9
  121. data/tracks/elixir/exercises/wordy/wordy_test.exs +16 -16
  122. data/tracks/elixir/exercises/zipper/zipper_test.exs +13 -13
  123. data/tracks/fsharp/build.fsx +2 -7
  124. data/tracks/fsharp/config.json +0 -104
  125. data/tracks/fsharp/exercises/grep/GrepTest.fs +7 -1
  126. data/tracks/go/config.json +1 -0
  127. data/tracks/go/exercises/acronym/acronym_test.go +36 -0
  128. data/tracks/go/exercises/acronym/example.go +21 -0
  129. data/tracks/go/exercises/palindrome-products/example.go +2 -0
  130. data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +10 -0
  131. data/tracks/go/exercises/phone-number/example.go +2 -0
  132. data/tracks/go/exercises/phone-number/phone_number_test.go +44 -27
  133. data/tracks/go/exercises/robot-simulator/defs.go +6 -6
  134. data/tracks/go/exercises/robot-simulator/example.go +22 -22
  135. data/tracks/go/exercises/robot-simulator/robot_simulator_step2_test.go +28 -28
  136. data/tracks/go/exercises/robot-simulator/robot_simulator_step3_test.go +75 -76
  137. data/tracks/go/exercises/robot-simulator/robot_simulator_test.go +10 -4
  138. data/tracks/haskell/exercises/anagram/HINTS.md +22 -0
  139. data/tracks/haskell/exercises/anagram/package.yaml +3 -0
  140. data/tracks/haskell/exercises/anagram/src/Example.hs +10 -7
  141. data/tracks/haskell/exercises/anagram/test/Tests.hs +9 -3
  142. data/tracks/haskell/exercises/beer-song/HINTS.md +18 -0
  143. data/tracks/haskell/exercises/beer-song/src/Beer.hs +301 -3
  144. data/tracks/haskell/exercises/beer-song/src/Example.hs +5 -3
  145. data/tracks/haskell/exercises/beer-song/test/Tests.hs +332 -23
  146. data/tracks/haskell/exercises/crypto-square/src/CryptoSquare.hs +3 -17
  147. data/tracks/haskell/exercises/crypto-square/src/Example.hs +12 -20
  148. data/tracks/haskell/exercises/crypto-square/test/Tests.hs +46 -86
  149. data/tracks/haskell/exercises/leap/HINTS.md +11 -0
  150. data/tracks/haskell/exercises/leap/src/LeapYear.hs +1 -0
  151. data/tracks/java/exercises/pangram/src/test/java/PangramTest.java +34 -4
  152. data/tracks/lua/exercises/pov/pov_spec.lua +0 -13
  153. data/tracks/mips/docs/ABOUT.md +1 -1
  154. data/tracks/objective-c/config.json +225 -0
  155. data/tracks/objective-c/exercises/largest-series-product/LargestSeriesProductExample.h +8 -0
  156. data/tracks/objective-c/exercises/largest-series-product/LargestSeriesProductExample.m +63 -0
  157. data/tracks/objective-c/exercises/largest-series-product/LargestSeriesProductTest.m +84 -0
  158. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  159. data/tracks/ocaml/.travis-ci.sh +23 -0
  160. data/tracks/ocaml/.travis.yml +5 -1
  161. data/tracks/ocaml/Makefile +41 -0
  162. data/tracks/ocaml/config.json +18 -0
  163. data/tracks/ocaml/exercises/anagram/Makefile +1 -0
  164. data/tracks/ocaml/exercises/beer-song/Makefile +1 -0
  165. data/tracks/ocaml/exercises/beer-song/{beer.mli → beer_song.mli} +0 -0
  166. data/tracks/ocaml/exercises/beer-song/example.ml +1 -1
  167. data/tracks/ocaml/exercises/beer-song/test.ml +7 -6
  168. data/tracks/ocaml/exercises/bob/Makefile +1 -0
  169. data/tracks/ocaml/exercises/bowling/Makefile +1 -0
  170. data/tracks/ocaml/exercises/custom-set/Makefile +1 -0
  171. data/tracks/ocaml/exercises/difference-of-squares/.merlin +5 -0
  172. data/tracks/ocaml/exercises/difference-of-squares/Makefile +11 -0
  173. data/tracks/ocaml/exercises/difference-of-squares/difference_of_squares.mli +8 -0
  174. data/tracks/ocaml/exercises/difference-of-squares/example.ml +21 -0
  175. data/tracks/ocaml/exercises/difference-of-squares/test.ml +32 -0
  176. data/tracks/ocaml/exercises/grade-school/Makefile +1 -0
  177. data/tracks/ocaml/exercises/grade-school/{school.mli → grade_school.mli} +0 -0
  178. data/tracks/ocaml/exercises/grade-school/test.ml +27 -27
  179. data/tracks/ocaml/exercises/hamming/Makefile +1 -0
  180. data/tracks/ocaml/exercises/hangman/Makefile +1 -0
  181. data/tracks/ocaml/exercises/hello-world/Makefile +1 -1
  182. data/tracks/ocaml/exercises/hello-world/{hello.ml → hello_world.ml} +0 -0
  183. data/tracks/ocaml/exercises/hello-world/{hello.mli → hello_world.mli} +0 -0
  184. data/tracks/ocaml/exercises/hello-world/test.ml +1 -1
  185. data/tracks/ocaml/exercises/hexadecimal/Makefile +1 -0
  186. data/tracks/ocaml/exercises/leap/Makefile +1 -1
  187. data/tracks/ocaml/exercises/list-ops/Makefile +1 -0
  188. data/tracks/ocaml/exercises/luhn/Makefile +1 -0
  189. data/tracks/ocaml/exercises/minesweeper/Makefile +1 -0
  190. data/tracks/ocaml/exercises/nucleotide-count/Makefile +1 -0
  191. data/tracks/ocaml/exercises/nucleotide-count/{dna.mli → nucleotide_count.mli} +0 -0
  192. data/tracks/ocaml/exercises/nucleotide-count/test.ml +7 -7
  193. data/tracks/ocaml/exercises/phone-number/Makefile +1 -0
  194. data/tracks/ocaml/exercises/phone-number/{phone.mli → phone_number.mli} +0 -0
  195. data/tracks/ocaml/exercises/phone-number/test.ml +10 -10
  196. data/tracks/ocaml/exercises/point-mutations/Makefile +8 -0
  197. data/tracks/ocaml/exercises/point-mutations/example.ml +0 -0
  198. data/tracks/ocaml/exercises/prime-factors/Makefile +1 -0
  199. data/tracks/ocaml/exercises/raindrops/.merlin +5 -0
  200. data/tracks/ocaml/exercises/raindrops/Makefile +11 -0
  201. data/tracks/ocaml/exercises/raindrops/example.ml +11 -0
  202. data/tracks/ocaml/exercises/raindrops/raindrops.mli +7 -0
  203. data/tracks/ocaml/exercises/raindrops/test.ml +48 -0
  204. data/tracks/ocaml/exercises/rna-transcription/Makefile +1 -0
  205. data/tracks/ocaml/exercises/rna-transcription/{dna.mli → rna_transcription.mli} +0 -0
  206. data/tracks/ocaml/exercises/rna-transcription/test.ml +6 -6
  207. data/tracks/ocaml/exercises/roman-numerals/Makefile +1 -0
  208. data/tracks/ocaml/exercises/say/.gitignore +1 -0
  209. data/tracks/ocaml/exercises/say/.merlin +5 -0
  210. data/tracks/ocaml/exercises/say/Makefile +11 -0
  211. data/tracks/ocaml/exercises/say/example.ml +52 -0
  212. data/tracks/ocaml/exercises/say/say.mli +8 -0
  213. data/tracks/ocaml/exercises/say/test.ml +65 -0
  214. data/tracks/ocaml/exercises/space-age/Makefile +1 -0
  215. data/tracks/ocaml/exercises/word-count/Makefile +1 -0
  216. data/tracks/ocaml/exercises/word-count/example.ml +1 -1
  217. data/tracks/ocaml/exercises/zipper/HINT.md +5 -6
  218. data/tracks/ocaml/exercises/zipper/Makefile +1 -0
  219. data/tracks/ocaml/exercises/zipper/example.ml +2 -2
  220. data/tracks/ocaml/exercises/zipper/tree.ml +1 -1
  221. data/tracks/php/config.json +7 -1
  222. data/tracks/php/exercises/variable-length-quantity/example.php +56 -0
  223. data/tracks/php/exercises/variable-length-quantity/variable-length-quantity_test.php +149 -0
  224. data/tracks/python/config.json +1 -1
  225. data/tracks/ruby/.rubocop.yml +1915 -26
  226. data/tracks/ruby/bin/generate-acronym +7 -0
  227. data/tracks/ruby/bin/generate-nth-prime +7 -0
  228. data/tracks/ruby/config.json +482 -0
  229. data/tracks/ruby/exercises/acronym/.version +1 -0
  230. data/tracks/ruby/exercises/acronym/acronym_test.rb +45 -21
  231. data/tracks/ruby/exercises/acronym/example.rb +1 -1
  232. data/tracks/ruby/exercises/acronym/example.tt +19 -0
  233. data/tracks/ruby/exercises/anagram/anagram_test.rb +1 -1
  234. data/tracks/ruby/exercises/nth-prime/.version +1 -0
  235. data/tracks/ruby/exercises/nth-prime/example.rb +4 -0
  236. data/tracks/ruby/exercises/nth-prime/example.tt +23 -0
  237. data/tracks/ruby/exercises/nth-prime/nth_prime_test.rb +33 -10
  238. data/tracks/ruby/exercises/raindrops/.version +1 -1
  239. data/tracks/ruby/exercises/raindrops/example.rb +1 -1
  240. data/tracks/ruby/exercises/raindrops/raindrops_test.rb +20 -5
  241. data/tracks/ruby/lib/acronym_cases.rb +19 -0
  242. data/tracks/ruby/lib/generator.rb +3 -2
  243. data/tracks/ruby/lib/nth_prime_cases.rb +23 -0
  244. data/tracks/ruby/lib/raindrop_cases.rb +1 -1
  245. data/tracks/rust/README.md +1 -1
  246. data/tracks/scala/exercises/leap/src/test/scala/leap_test.scala +10 -0
  247. data/tracks/scala/exercises/prime-factors/example.scala +2 -5
  248. data/tracks/scala/exercises/prime-factors/src/test/scala/primefactors_test.scala +11 -13
  249. data/tracks/scheme/{anagram → exercises/anagram}/anagram-test.scm +0 -0
  250. data/tracks/scheme/{anagram → exercises/anagram}/anagram.scm +0 -0
  251. data/tracks/scheme/{anagram → exercises/anagram}/example.scm +0 -0
  252. data/tracks/scheme/{bob → exercises/bob}/bob-test.scm +0 -0
  253. data/tracks/scheme/{bob → exercises/bob}/bob.scm +0 -0
  254. data/tracks/scheme/{bob → exercises/bob}/example.scm +0 -0
  255. data/tracks/scheme/{difference-of-squares → exercises/difference-of-squares}/difference-of-squares-test.scm +0 -0
  256. data/tracks/scheme/{difference-of-squares → exercises/difference-of-squares}/example.scm +0 -0
  257. data/tracks/scheme/{difference-of-squares → exercises/difference-of-squares}/squares.scm +0 -0
  258. data/tracks/scheme/{grains → exercises/grains}/example.scm +0 -0
  259. data/tracks/scheme/{grains → exercises/grains}/grains-test.scm +0 -0
  260. data/tracks/scheme/{grains → exercises/grains}/grains.scm +0 -0
  261. data/tracks/scheme/{hamming → exercises/hamming}/example.scm +0 -0
  262. data/tracks/scheme/{hamming → exercises/hamming}/hamming-test.scm +0 -0
  263. data/tracks/scheme/{hamming → exercises/hamming}/hamming.scm +0 -0
  264. data/tracks/scheme/{hello-world → exercises/hello-world}/example.scm +0 -0
  265. data/tracks/scheme/{hello-world → exercises/hello-world}/hello-world-test.scm +0 -0
  266. data/tracks/scheme/{hello-world → exercises/hello-world}/hello-world.scm +0 -0
  267. data/tracks/scheme/{leap → exercises/leap}/example.scm +0 -0
  268. data/tracks/scheme/{leap → exercises/leap}/leap-test.scm +0 -0
  269. data/tracks/scheme/{leap → exercises/leap}/leap-year.scm +0 -0
  270. data/tracks/scheme/{list-ops → exercises/list-ops}/example.scm +0 -0
  271. data/tracks/scheme/{list-ops → exercises/list-ops}/list-ops-test.scm +0 -0
  272. data/tracks/scheme/{list-ops → exercises/list-ops}/list-ops.scm +0 -0
  273. data/tracks/scheme/{nucleotide-count → exercises/nucleotide-count}/example.scm +0 -0
  274. data/tracks/scheme/{nucleotide-count → exercises/nucleotide-count}/nucleotide-count-test.scm +0 -0
  275. data/tracks/scheme/{nucleotide-count → exercises/nucleotide-count}/nucleotide-count.scm +0 -0
  276. data/tracks/scheme/{phone-number → exercises/phone-number}/example.scm +0 -0
  277. data/tracks/scheme/{phone-number → exercises/phone-number}/phone-number-test.scm +0 -0
  278. data/tracks/scheme/{phone-number → exercises/phone-number}/phone-number.scm +0 -0
  279. data/tracks/scheme/{raindrops → exercises/raindrops}/example.scm +0 -0
  280. data/tracks/scheme/{raindrops → exercises/raindrops}/raindrops-test.scm +0 -0
  281. data/tracks/scheme/{raindrops → exercises/raindrops}/raindrops.scm +0 -0
  282. data/tracks/scheme/{rna-transcription → exercises/rna-transcription}/dna.scm +0 -0
  283. data/tracks/scheme/{rna-transcription → exercises/rna-transcription}/example.scm +0 -0
  284. data/tracks/scheme/{rna-transcription → exercises/rna-transcription}/rna-transcription-test.scm +0 -0
  285. data/tracks/scheme/{robot-name → exercises/robot-name}/example.scm +0 -0
  286. data/tracks/scheme/{robot-name → exercises/robot-name}/robot-name-test.scm +0 -0
  287. data/tracks/scheme/{robot-name → exercises/robot-name}/robot.scm +0 -0
  288. metadata +125 -64
@@ -25,16 +25,22 @@ import (
25
25
  "testing"
26
26
  )
27
27
 
28
+ const targetTestVersion = 3
29
+
28
30
  func TestStep1(t *testing.T) {
31
+
32
+ if testVersion != targetTestVersion {
33
+ t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
34
+ }
29
35
  want := func(x, y int, dir Dir) {
30
36
  _, _, line, _ := runtime.Caller(1)
31
- if X != x || Y != y {
37
+ if Step1Robot.X != x || Step1Robot.Y != y {
32
38
  t.Fatalf("(from line %d) robot at = %d, %d. Want %d, %d.",
33
- line, X, Y, x, y)
39
+ line, Step1Robot.X, Step1Robot.Y, x, y)
34
40
  }
35
- if Facing != dir {
41
+ if Step1Robot.Dir != dir {
36
42
  t.Fatalf("(from line %d) robot facing %v, want %v.",
37
- line, Facing, dir)
43
+ line, Step1Robot.Dir, dir)
38
44
  }
39
45
  }
40
46
  want(0, 0, N)
@@ -0,0 +1,22 @@
1
+ ## Hints
2
+
3
+ To complete this exercise you need to implement the function `anagramsFor`,
4
+ that takes a *word* and a group of *words*, returning the ones that are
5
+ anagrams of the given *word*.
6
+
7
+ If it is your first time solving this exercise, it is recommended that you
8
+ stick to the provided signature:
9
+
10
+ ```haskell
11
+ anagramsFor :: String -> [String] -> [String]
12
+ ```
13
+
14
+ Later, it may be a good idea to revisit this problem and play with other data
15
+ types and libraries:
16
+
17
+ - `Text`, from package *text*.
18
+ - `Sequence` and `Set`, from package *containers*.
19
+ - `MultiSet`, from package *multiset*
20
+
21
+ The test suite was intentionally designed to accept almost any type signature
22
+ that makes sense, so you are encouraged to find the one you think is the best.
@@ -9,6 +9,9 @@ library:
9
9
  dependencies:
10
10
  # - foo # List here the packages you
11
11
  # - bar # want to use in your solution.
12
+ - containers
13
+ - multiset
14
+ - text
12
15
 
13
16
  tests:
14
17
  test:
@@ -1,10 +1,13 @@
1
1
  module Anagram (anagramsFor) where
2
- import Data.List (sort)
3
- import Data.Char (toLower)
4
2
 
5
- anagramsFor :: String -> [String] -> [String]
6
- anagramsFor word = filter (isAnagram . normalize)
3
+ import Data.Function (on)
4
+ import Data.MultiSet (fromList)
5
+ import Data.Set (Set, filter)
6
+ import Data.Text (Text, toLower, unpack)
7
+ import Prelude hiding (filter)
8
+
9
+ anagramsFor :: Text -> Set Text -> Set Text
10
+ anagramsFor x = filter (\w -> x `isDistinctOf` w && x `isAnagramOf` w)
7
11
  where
8
- normalize xs = let nxs = map toLower xs in (nxs, sort nxs)
9
- (nw, sw) = normalize word
10
- isAnagram (w, s) = nw /= w && sw == s
12
+ isDistinctOf = (/=) `on` toLower
13
+ isAnagramOf = (==) `on` fromList . unpack . toLower
@@ -1,7 +1,8 @@
1
1
  {-# LANGUAGE RecordWildCards #-}
2
2
 
3
3
  import Data.Foldable (for_)
4
- import Test.Hspec (Spec, describe, it, shouldBe)
4
+ import GHC.Exts (fromList, toList)
5
+ import Test.Hspec (Spec, describe, it, shouldMatchList)
5
6
  import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
6
7
 
7
8
  import Anagram (anagramsFor)
@@ -14,9 +15,14 @@ specs = describe "anagram" $
14
15
  describe "anagramsFor" $ for_ cases test
15
16
  where
16
17
 
17
- test Case{..} = it description $ expression `shouldBe` expected
18
+ test Case{..} = it description $ expression `shouldMatchList` expected
18
19
  where
19
- expression = anagramsFor subject candidates
20
+ expression = map toList
21
+ . toList
22
+ . anagramsFor (fromList subject)
23
+ . fromList
24
+ . map fromList
25
+ $ candidates
20
26
 
21
27
  -- Test cases adapted from `exercism/x-common/anagrams.json` on 2016-07-25.
22
28
 
@@ -0,0 +1,18 @@
1
+ ## Hints
2
+
3
+ This exercise is about [code refactoring](https://en.wikipedia.org/wiki/Refactoring),
4
+ so we are providing you with a solution that already passes the tests.
5
+
6
+ The challenge is to rewrite it until you are proud of it, and learn
7
+ something in the process.
8
+
9
+ If you don't know where to start, here are some ideas:
10
+
11
+ - Try to reduce repetition to a minimum.
12
+ - Try to make the code readable.
13
+
14
+ Take your time.
15
+
16
+ Change one thing at a time and check if your solution still passes the tests.
17
+
18
+ Have fun!
@@ -1,5 +1,303 @@
1
- module Beer (verse, sing) where
1
+ module Beer (song) where
2
2
 
3
- verse = undefined
3
+ song :: String
4
+ song = "99 bottles of beer on the wall, 99 bottles of beer.\n\
5
+ \Take one down and pass it around, 98 bottles of beer on the wall.\n\
6
+ \\n\
7
+ \98 bottles of beer on the wall, 98 bottles of beer.\n\
8
+ \Take one down and pass it around, 97 bottles of beer on the wall.\n\
9
+ \\n\
10
+ \97 bottles of beer on the wall, 97 bottles of beer.\n\
11
+ \Take one down and pass it around, 96 bottles of beer on the wall.\n\
12
+ \\n\
13
+ \96 bottles of beer on the wall, 96 bottles of beer.\n\
14
+ \Take one down and pass it around, 95 bottles of beer on the wall.\n\
15
+ \\n\
16
+ \95 bottles of beer on the wall, 95 bottles of beer.\n\
17
+ \Take one down and pass it around, 94 bottles of beer on the wall.\n\
18
+ \\n\
19
+ \94 bottles of beer on the wall, 94 bottles of beer.\n\
20
+ \Take one down and pass it around, 93 bottles of beer on the wall.\n\
21
+ \\n\
22
+ \93 bottles of beer on the wall, 93 bottles of beer.\n\
23
+ \Take one down and pass it around, 92 bottles of beer on the wall.\n\
24
+ \\n\
25
+ \92 bottles of beer on the wall, 92 bottles of beer.\n\
26
+ \Take one down and pass it around, 91 bottles of beer on the wall.\n\
27
+ \\n\
28
+ \91 bottles of beer on the wall, 91 bottles of beer.\n\
29
+ \Take one down and pass it around, 90 bottles of beer on the wall.\n\
30
+ \\n\
31
+ \90 bottles of beer on the wall, 90 bottles of beer.\n\
32
+ \Take one down and pass it around, 89 bottles of beer on the wall.\n\
33
+ \\n\
34
+ \89 bottles of beer on the wall, 89 bottles of beer.\n\
35
+ \Take one down and pass it around, 88 bottles of beer on the wall.\n\
36
+ \\n\
37
+ \88 bottles of beer on the wall, 88 bottles of beer.\n\
38
+ \Take one down and pass it around, 87 bottles of beer on the wall.\n\
39
+ \\n\
40
+ \87 bottles of beer on the wall, 87 bottles of beer.\n\
41
+ \Take one down and pass it around, 86 bottles of beer on the wall.\n\
42
+ \\n\
43
+ \86 bottles of beer on the wall, 86 bottles of beer.\n\
44
+ \Take one down and pass it around, 85 bottles of beer on the wall.\n\
45
+ \\n\
46
+ \85 bottles of beer on the wall, 85 bottles of beer.\n\
47
+ \Take one down and pass it around, 84 bottles of beer on the wall.\n\
48
+ \\n\
49
+ \84 bottles of beer on the wall, 84 bottles of beer.\n\
50
+ \Take one down and pass it around, 83 bottles of beer on the wall.\n\
51
+ \\n\
52
+ \83 bottles of beer on the wall, 83 bottles of beer.\n\
53
+ \Take one down and pass it around, 82 bottles of beer on the wall.\n\
54
+ \\n\
55
+ \82 bottles of beer on the wall, 82 bottles of beer.\n\
56
+ \Take one down and pass it around, 81 bottles of beer on the wall.\n\
57
+ \\n\
58
+ \81 bottles of beer on the wall, 81 bottles of beer.\n\
59
+ \Take one down and pass it around, 80 bottles of beer on the wall.\n\
60
+ \\n\
61
+ \80 bottles of beer on the wall, 80 bottles of beer.\n\
62
+ \Take one down and pass it around, 79 bottles of beer on the wall.\n\
63
+ \\n\
64
+ \79 bottles of beer on the wall, 79 bottles of beer.\n\
65
+ \Take one down and pass it around, 78 bottles of beer on the wall.\n\
66
+ \\n\
67
+ \78 bottles of beer on the wall, 78 bottles of beer.\n\
68
+ \Take one down and pass it around, 77 bottles of beer on the wall.\n\
69
+ \\n\
70
+ \77 bottles of beer on the wall, 77 bottles of beer.\n\
71
+ \Take one down and pass it around, 76 bottles of beer on the wall.\n\
72
+ \\n\
73
+ \76 bottles of beer on the wall, 76 bottles of beer.\n\
74
+ \Take one down and pass it around, 75 bottles of beer on the wall.\n\
75
+ \\n\
76
+ \75 bottles of beer on the wall, 75 bottles of beer.\n\
77
+ \Take one down and pass it around, 74 bottles of beer on the wall.\n\
78
+ \\n\
79
+ \74 bottles of beer on the wall, 74 bottles of beer.\n\
80
+ \Take one down and pass it around, 73 bottles of beer on the wall.\n\
81
+ \\n\
82
+ \73 bottles of beer on the wall, 73 bottles of beer.\n\
83
+ \Take one down and pass it around, 72 bottles of beer on the wall.\n\
84
+ \\n\
85
+ \72 bottles of beer on the wall, 72 bottles of beer.\n\
86
+ \Take one down and pass it around, 71 bottles of beer on the wall.\n\
87
+ \\n\
88
+ \71 bottles of beer on the wall, 71 bottles of beer.\n\
89
+ \Take one down and pass it around, 70 bottles of beer on the wall.\n\
90
+ \\n\
91
+ \70 bottles of beer on the wall, 70 bottles of beer.\n\
92
+ \Take one down and pass it around, 69 bottles of beer on the wall.\n\
93
+ \\n\
94
+ \69 bottles of beer on the wall, 69 bottles of beer.\n\
95
+ \Take one down and pass it around, 68 bottles of beer on the wall.\n\
96
+ \\n\
97
+ \68 bottles of beer on the wall, 68 bottles of beer.\n\
98
+ \Take one down and pass it around, 67 bottles of beer on the wall.\n\
99
+ \\n\
100
+ \67 bottles of beer on the wall, 67 bottles of beer.\n\
101
+ \Take one down and pass it around, 66 bottles of beer on the wall.\n\
102
+ \\n\
103
+ \66 bottles of beer on the wall, 66 bottles of beer.\n\
104
+ \Take one down and pass it around, 65 bottles of beer on the wall.\n\
105
+ \\n\
106
+ \65 bottles of beer on the wall, 65 bottles of beer.\n\
107
+ \Take one down and pass it around, 64 bottles of beer on the wall.\n\
108
+ \\n\
109
+ \64 bottles of beer on the wall, 64 bottles of beer.\n\
110
+ \Take one down and pass it around, 63 bottles of beer on the wall.\n\
111
+ \\n\
112
+ \63 bottles of beer on the wall, 63 bottles of beer.\n\
113
+ \Take one down and pass it around, 62 bottles of beer on the wall.\n\
114
+ \\n\
115
+ \62 bottles of beer on the wall, 62 bottles of beer.\n\
116
+ \Take one down and pass it around, 61 bottles of beer on the wall.\n\
117
+ \\n\
118
+ \61 bottles of beer on the wall, 61 bottles of beer.\n\
119
+ \Take one down and pass it around, 60 bottles of beer on the wall.\n\
120
+ \\n\
121
+ \60 bottles of beer on the wall, 60 bottles of beer.\n\
122
+ \Take one down and pass it around, 59 bottles of beer on the wall.\n\
123
+ \\n\
124
+ \59 bottles of beer on the wall, 59 bottles of beer.\n\
125
+ \Take one down and pass it around, 58 bottles of beer on the wall.\n\
126
+ \\n\
127
+ \58 bottles of beer on the wall, 58 bottles of beer.\n\
128
+ \Take one down and pass it around, 57 bottles of beer on the wall.\n\
129
+ \\n\
130
+ \57 bottles of beer on the wall, 57 bottles of beer.\n\
131
+ \Take one down and pass it around, 56 bottles of beer on the wall.\n\
132
+ \\n\
133
+ \56 bottles of beer on the wall, 56 bottles of beer.\n\
134
+ \Take one down and pass it around, 55 bottles of beer on the wall.\n\
135
+ \\n\
136
+ \55 bottles of beer on the wall, 55 bottles of beer.\n\
137
+ \Take one down and pass it around, 54 bottles of beer on the wall.\n\
138
+ \\n\
139
+ \54 bottles of beer on the wall, 54 bottles of beer.\n\
140
+ \Take one down and pass it around, 53 bottles of beer on the wall.\n\
141
+ \\n\
142
+ \53 bottles of beer on the wall, 53 bottles of beer.\n\
143
+ \Take one down and pass it around, 52 bottles of beer on the wall.\n\
144
+ \\n\
145
+ \52 bottles of beer on the wall, 52 bottles of beer.\n\
146
+ \Take one down and pass it around, 51 bottles of beer on the wall.\n\
147
+ \\n\
148
+ \51 bottles of beer on the wall, 51 bottles of beer.\n\
149
+ \Take one down and pass it around, 50 bottles of beer on the wall.\n\
150
+ \\n\
151
+ \50 bottles of beer on the wall, 50 bottles of beer.\n\
152
+ \Take one down and pass it around, 49 bottles of beer on the wall.\n\
153
+ \\n\
154
+ \49 bottles of beer on the wall, 49 bottles of beer.\n\
155
+ \Take one down and pass it around, 48 bottles of beer on the wall.\n\
156
+ \\n\
157
+ \48 bottles of beer on the wall, 48 bottles of beer.\n\
158
+ \Take one down and pass it around, 47 bottles of beer on the wall.\n\
159
+ \\n\
160
+ \47 bottles of beer on the wall, 47 bottles of beer.\n\
161
+ \Take one down and pass it around, 46 bottles of beer on the wall.\n\
162
+ \\n\
163
+ \46 bottles of beer on the wall, 46 bottles of beer.\n\
164
+ \Take one down and pass it around, 45 bottles of beer on the wall.\n\
165
+ \\n\
166
+ \45 bottles of beer on the wall, 45 bottles of beer.\n\
167
+ \Take one down and pass it around, 44 bottles of beer on the wall.\n\
168
+ \\n\
169
+ \44 bottles of beer on the wall, 44 bottles of beer.\n\
170
+ \Take one down and pass it around, 43 bottles of beer on the wall.\n\
171
+ \\n\
172
+ \43 bottles of beer on the wall, 43 bottles of beer.\n\
173
+ \Take one down and pass it around, 42 bottles of beer on the wall.\n\
174
+ \\n\
175
+ \42 bottles of beer on the wall, 42 bottles of beer.\n\
176
+ \Take one down and pass it around, 41 bottles of beer on the wall.\n\
177
+ \\n\
178
+ \41 bottles of beer on the wall, 41 bottles of beer.\n\
179
+ \Take one down and pass it around, 40 bottles of beer on the wall.\n\
180
+ \\n\
181
+ \40 bottles of beer on the wall, 40 bottles of beer.\n\
182
+ \Take one down and pass it around, 39 bottles of beer on the wall.\n\
183
+ \\n\
184
+ \39 bottles of beer on the wall, 39 bottles of beer.\n\
185
+ \Take one down and pass it around, 38 bottles of beer on the wall.\n\
186
+ \\n\
187
+ \38 bottles of beer on the wall, 38 bottles of beer.\n\
188
+ \Take one down and pass it around, 37 bottles of beer on the wall.\n\
189
+ \\n\
190
+ \37 bottles of beer on the wall, 37 bottles of beer.\n\
191
+ \Take one down and pass it around, 36 bottles of beer on the wall.\n\
192
+ \\n\
193
+ \36 bottles of beer on the wall, 36 bottles of beer.\n\
194
+ \Take one down and pass it around, 35 bottles of beer on the wall.\n\
195
+ \\n\
196
+ \35 bottles of beer on the wall, 35 bottles of beer.\n\
197
+ \Take one down and pass it around, 34 bottles of beer on the wall.\n\
198
+ \\n\
199
+ \34 bottles of beer on the wall, 34 bottles of beer.\n\
200
+ \Take one down and pass it around, 33 bottles of beer on the wall.\n\
201
+ \\n\
202
+ \33 bottles of beer on the wall, 33 bottles of beer.\n\
203
+ \Take one down and pass it around, 32 bottles of beer on the wall.\n\
204
+ \\n\
205
+ \32 bottles of beer on the wall, 32 bottles of beer.\n\
206
+ \Take one down and pass it around, 31 bottles of beer on the wall.\n\
207
+ \\n\
208
+ \31 bottles of beer on the wall, 31 bottles of beer.\n\
209
+ \Take one down and pass it around, 30 bottles of beer on the wall.\n\
210
+ \\n\
211
+ \30 bottles of beer on the wall, 30 bottles of beer.\n\
212
+ \Take one down and pass it around, 29 bottles of beer on the wall.\n\
213
+ \\n\
214
+ \29 bottles of beer on the wall, 29 bottles of beer.\n\
215
+ \Take one down and pass it around, 28 bottles of beer on the wall.\n\
216
+ \\n\
217
+ \28 bottles of beer on the wall, 28 bottles of beer.\n\
218
+ \Take one down and pass it around, 27 bottles of beer on the wall.\n\
219
+ \\n\
220
+ \27 bottles of beer on the wall, 27 bottles of beer.\n\
221
+ \Take one down and pass it around, 26 bottles of beer on the wall.\n\
222
+ \\n\
223
+ \26 bottles of beer on the wall, 26 bottles of beer.\n\
224
+ \Take one down and pass it around, 25 bottles of beer on the wall.\n\
225
+ \\n\
226
+ \25 bottles of beer on the wall, 25 bottles of beer.\n\
227
+ \Take one down and pass it around, 24 bottles of beer on the wall.\n\
228
+ \\n\
229
+ \24 bottles of beer on the wall, 24 bottles of beer.\n\
230
+ \Take one down and pass it around, 23 bottles of beer on the wall.\n\
231
+ \\n\
232
+ \23 bottles of beer on the wall, 23 bottles of beer.\n\
233
+ \Take one down and pass it around, 22 bottles of beer on the wall.\n\
234
+ \\n\
235
+ \22 bottles of beer on the wall, 22 bottles of beer.\n\
236
+ \Take one down and pass it around, 21 bottles of beer on the wall.\n\
237
+ \\n\
238
+ \21 bottles of beer on the wall, 21 bottles of beer.\n\
239
+ \Take one down and pass it around, 20 bottles of beer on the wall.\n\
240
+ \\n\
241
+ \20 bottles of beer on the wall, 20 bottles of beer.\n\
242
+ \Take one down and pass it around, 19 bottles of beer on the wall.\n\
243
+ \\n\
244
+ \19 bottles of beer on the wall, 19 bottles of beer.\n\
245
+ \Take one down and pass it around, 18 bottles of beer on the wall.\n\
246
+ \\n\
247
+ \18 bottles of beer on the wall, 18 bottles of beer.\n\
248
+ \Take one down and pass it around, 17 bottles of beer on the wall.\n\
249
+ \\n\
250
+ \17 bottles of beer on the wall, 17 bottles of beer.\n\
251
+ \Take one down and pass it around, 16 bottles of beer on the wall.\n\
252
+ \\n\
253
+ \16 bottles of beer on the wall, 16 bottles of beer.\n\
254
+ \Take one down and pass it around, 15 bottles of beer on the wall.\n\
255
+ \\n\
256
+ \15 bottles of beer on the wall, 15 bottles of beer.\n\
257
+ \Take one down and pass it around, 14 bottles of beer on the wall.\n\
258
+ \\n\
259
+ \14 bottles of beer on the wall, 14 bottles of beer.\n\
260
+ \Take one down and pass it around, 13 bottles of beer on the wall.\n\
261
+ \\n\
262
+ \13 bottles of beer on the wall, 13 bottles of beer.\n\
263
+ \Take one down and pass it around, 12 bottles of beer on the wall.\n\
264
+ \\n\
265
+ \12 bottles of beer on the wall, 12 bottles of beer.\n\
266
+ \Take one down and pass it around, 11 bottles of beer on the wall.\n\
267
+ \\n\
268
+ \11 bottles of beer on the wall, 11 bottles of beer.\n\
269
+ \Take one down and pass it around, 10 bottles of beer on the wall.\n\
270
+ \\n\
271
+ \10 bottles of beer on the wall, 10 bottles of beer.\n\
272
+ \Take one down and pass it around, 9 bottles of beer on the wall.\n\
273
+ \\n\
274
+ \9 bottles of beer on the wall, 9 bottles of beer.\n\
275
+ \Take one down and pass it around, 8 bottles of beer on the wall.\n\
276
+ \\n\
277
+ \8 bottles of beer on the wall, 8 bottles of beer.\n\
278
+ \Take one down and pass it around, 7 bottles of beer on the wall.\n\
279
+ \\n\
280
+ \7 bottles of beer on the wall, 7 bottles of beer.\n\
281
+ \Take one down and pass it around, 6 bottles of beer on the wall.\n\
282
+ \\n\
283
+ \6 bottles of beer on the wall, 6 bottles of beer.\n\
284
+ \Take one down and pass it around, 5 bottles of beer on the wall.\n\
285
+ \\n\
286
+ \5 bottles of beer on the wall, 5 bottles of beer.\n\
287
+ \Take one down and pass it around, 4 bottles of beer on the wall.\n\
288
+ \\n\
289
+ \4 bottles of beer on the wall, 4 bottles of beer.\n\
290
+ \Take one down and pass it around, 3 bottles of beer on the wall.\n\
291
+ \\n\
292
+ \3 bottles of beer on the wall, 3 bottles of beer.\n\
293
+ \Take one down and pass it around, 2 bottles of beer on the wall.\n\
294
+ \\n\
295
+ \2 bottles of beer on the wall, 2 bottles of beer.\n\
296
+ \Take one down and pass it around, 1 bottle of beer on the wall.\n\
297
+ \\n\
298
+ \1 bottle of beer on the wall, 1 bottle of beer.\n\
299
+ \Take it down and pass it around, no more bottles of beer on the wall.\n\
300
+ \\n\
301
+ \No more bottles of beer on the wall, no more bottles of beer.\n\
302
+ \Go to the store and buy some more, 99 bottles of beer on the wall.\n"
4
303
 
5
- sing = undefined
@@ -1,5 +1,7 @@
1
- module Beer (verse, sing) where
1
+ module Beer (song) where
2
+
2
3
  import Data.Char (toUpper)
4
+ import Data.List (intercalate)
3
5
 
4
6
  capitalize :: String -> String
5
7
  capitalize (h : t) = toUpper h : t
@@ -30,5 +32,5 @@ verse n = unlines
30
32
  [ capitalize (stanza n) ++ " on the wall, " ++ stanza n ++ "."
31
33
  , action n ++ ", " ++ stanza (pred n) ++ " on the wall." ]
32
34
 
33
- sing :: Int -> Int -> String
34
- sing from to = unlines $ map verse [from, from - 1 .. to]
35
+ song :: String
36
+ song = intercalate "\n" $ map verse [99, 98 .. 0]