trackler 2.0.6.11 → 2.0.6.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. checksums.yaml +4 -4
  2. data/common/CONTRIBUTING.md +6 -1
  3. data/common/exercises/difference-of-squares/metadata.yml +1 -1
  4. data/common/exercises/luhn/canonical-data.json +2 -2
  5. data/common/exercises/rectangles/canonical-data.json +25 -0
  6. data/common/exercises/rectangles/description.md +11 -3
  7. data/lib/trackler/version.rb +1 -1
  8. data/tracks/ceylon/config.json +9 -0
  9. data/tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon +38 -39
  10. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +28 -29
  11. data/tracks/ceylon/exercises/largest-series-product/example/Series.ceylon +13 -0
  12. data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/Series.ceylon +5 -0
  13. data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/SeriesTest.ceylon +30 -0
  14. data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/module.ceylon +3 -0
  15. data/tracks/csharp/config.json +41 -0
  16. data/tracks/csharp/exercises/alphametics/AlphameticsTest.cs +122 -0
  17. data/tracks/csharp/exercises/alphametics/Example.cs +139 -0
  18. data/tracks/csharp/exercises/dot-dsl/DotDslTest.cs +91 -0
  19. data/tracks/csharp/exercises/dot-dsl/Example.cs +90 -0
  20. data/tracks/csharp/exercises/dot-dsl/HINTS.md +2 -0
  21. data/tracks/csharp/exercises/error-handling/ErrorHandlingTest.cs +65 -0
  22. data/tracks/csharp/exercises/error-handling/Example.cs +34 -0
  23. data/tracks/csharp/exercises/exercises.csproj +1 -1
  24. data/tracks/csharp/exercises/hangman/Example.cs +85 -0
  25. data/tracks/csharp/exercises/hangman/HangmanTest.cs +140 -0
  26. data/tracks/csharp/exercises/ledger/Example.cs +106 -0
  27. data/tracks/csharp/exercises/ledger/Ledger.cs +166 -0
  28. data/tracks/csharp/exercises/ledger/LedgerTest.cs +168 -0
  29. data/tracks/elixir/exercises/allergies/allergies_test.exs +2 -2
  30. data/tracks/elixir/exercises/markdown/example.exs +3 -3
  31. data/tracks/elixir/exercises/phone-number/example.exs +0 -2
  32. data/tracks/elixir/exercises/queen-attack/example.exs +1 -1
  33. data/tracks/elixir/exercises/wordy/example.exs +6 -6
  34. data/tracks/elixir/exercises/zipper/zipper_test.exs +12 -12
  35. data/tracks/elixir/mix.exs +1 -1
  36. data/tracks/fsharp/config.json +8 -8
  37. data/tracks/fsharp/docs/ABOUT.md +4 -0
  38. data/tracks/fsharp/exercises/alphametics/AlphameticsTest.fs +33 -13
  39. data/tracks/fsharp/exercises/alphametics/Example.fs +29 -64
  40. data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTreeTest.fs +14 -14
  41. data/tracks/fsharp/exercises/binary-search-tree/Example.fs +17 -14
  42. data/tracks/fsharp/exercises/triangle/TriangleTest.fs +0 -5
  43. data/tracks/go/README.md +3 -3
  44. data/tracks/go/config.json +10 -3
  45. data/tracks/go/exercises/acronym/acronym.go +5 -0
  46. data/tracks/go/exercises/bob/example_gen.go +1 -1
  47. data/tracks/go/exercises/clock/example_gen.go +1 -1
  48. data/tracks/go/exercises/connect/example_gen.go +1 -1
  49. data/tracks/go/exercises/custom-set/example_gen.go +1 -1
  50. data/tracks/go/exercises/gigasecond/example_gen.go +1 -1
  51. data/tracks/go/exercises/hamming/example_gen.go +1 -1
  52. data/tracks/go/exercises/largest-series-product/example_gen.go +1 -1
  53. data/tracks/go/exercises/leap/cases_test.go +5 -7
  54. data/tracks/go/exercises/leap/example.go +1 -1
  55. data/tracks/go/exercises/leap/example_gen.go +1 -1
  56. data/tracks/go/exercises/leap/leap.go +1 -1
  57. data/tracks/go/exercises/leap/leap_test.go +1 -1
  58. data/tracks/go/exercises/meetup/example_gen.go +1 -1
  59. data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +0 -5
  60. data/tracks/go/exercises/pangram/pangram.go +5 -0
  61. data/tracks/go/exercises/raindrops/example_gen.go +1 -1
  62. data/tracks/go/exercises/rna-transcription/example_gen.go +1 -1
  63. data/tracks/go/exercises/roman-numerals/example_gen.go +1 -1
  64. data/tracks/go/exercises/word-count/example_gen.go +1 -1
  65. data/tracks/go/gen/gen.go +3 -2
  66. data/tracks/haskell/exercises/accumulate/src/Accumulate.hs +1 -1
  67. data/tracks/haskell/exercises/all-your-base/src/Base.hs +1 -1
  68. data/tracks/haskell/exercises/allergies/src/Allergies.hs +2 -2
  69. data/tracks/haskell/exercises/alphametics/src/Alphametics.hs +1 -1
  70. data/tracks/haskell/exercises/anagram/src/Anagram.hs +1 -1
  71. data/tracks/haskell/exercises/atbash-cipher/src/Atbash.hs +2 -2
  72. data/tracks/haskell/exercises/bank-account/src/BankAccount.hs +4 -4
  73. data/tracks/haskell/exercises/binary/src/Binary.hs +1 -1
  74. data/tracks/haskell/exercises/binary-search-tree/src/BST.hs +8 -8
  75. data/tracks/haskell/exercises/bob/src/Bob.hs +1 -1
  76. data/tracks/haskell/exercises/bowling/src/Bowling.hs +1 -1
  77. data/tracks/haskell/exercises/change/src/Change.hs +1 -1
  78. data/tracks/haskell/exercises/clock/src/Clock.hs +4 -4
  79. data/tracks/haskell/exercises/connect/src/Connect.hs +1 -1
  80. data/tracks/haskell/exercises/crypto-square/src/CryptoSquare.hs +1 -1
  81. data/tracks/haskell/exercises/custom-set/src/CustomSet.hs +13 -13
  82. data/tracks/haskell/exercises/difference-of-squares/src/Squares.hs +3 -3
  83. data/tracks/haskell/exercises/dominoes/src/Dominoes.hs +1 -1
  84. data/tracks/haskell/exercises/etl/src/ETL.hs +1 -1
  85. data/tracks/haskell/exercises/forth/src/Forth.hs +3 -3
  86. data/tracks/haskell/exercises/gigasecond/src/Gigasecond.hs +1 -1
  87. data/tracks/haskell/exercises/go-counting/src/Counting.hs +2 -2
  88. data/tracks/haskell/exercises/grade-school/src/School.hs +4 -4
  89. data/tracks/haskell/exercises/grains/src/Grains.hs +2 -2
  90. data/tracks/haskell/exercises/hamming/src/Hamming.hs +1 -1
  91. data/tracks/haskell/exercises/hexadecimal/src/Hexadecimal.hs +1 -1
  92. data/tracks/haskell/exercises/kindergarten-garden/src/Garden.hs +3 -3
  93. data/tracks/haskell/exercises/largest-series-product/src/Series.hs +1 -1
  94. data/tracks/haskell/exercises/leap/src/LeapYear.hs +1 -1
  95. data/tracks/haskell/exercises/lens-person/src/Person.hs +4 -4
  96. data/tracks/haskell/exercises/linked-list/src/Deque.hs +5 -5
  97. data/tracks/haskell/exercises/list-ops/src/ListOps.hs +8 -8
  98. data/tracks/haskell/exercises/luhn/src/Luhn.hs +5 -5
  99. data/tracks/haskell/exercises/matrix/src/Matrix.hs +10 -10
  100. data/tracks/haskell/exercises/meetup/src/Meetup.hs +1 -1
  101. data/tracks/haskell/exercises/minesweeper/src/Minesweeper.hs +1 -1
  102. data/tracks/haskell/exercises/nth-prime/src/Prime.hs +1 -1
  103. data/tracks/haskell/exercises/nucleotide-count/src/DNA.hs +2 -2
  104. data/tracks/haskell/exercises/ocr-numbers/src/OCR.hs +1 -1
  105. data/tracks/haskell/exercises/octal/src/Octal.hs +2 -2
  106. data/tracks/haskell/exercises/palindrome-products/src/Palindromes.hs +2 -2
  107. data/tracks/haskell/exercises/parallel-letter-frequency/src/Frequency.hs +1 -1
  108. data/tracks/haskell/exercises/pascals-triangle/src/Triangle.hs +1 -1
  109. data/tracks/haskell/exercises/phone-number/src/Phone.hs +3 -3
  110. data/tracks/haskell/exercises/pig-latin/src/PigLatin.hs +1 -1
  111. data/tracks/haskell/exercises/pov/src/POV.hs +2 -2
  112. data/tracks/haskell/exercises/prime-factors/src/PrimeFactors.hs +1 -1
  113. data/tracks/haskell/exercises/pythagorean-triplet/src/Triplet.hs +3 -3
  114. data/tracks/haskell/exercises/queen-attack/src/Queens.hs +2 -2
  115. data/tracks/haskell/exercises/raindrops/src/Raindrops.hs +1 -1
  116. data/tracks/haskell/exercises/rna-transcription/src/DNA.hs +1 -1
  117. data/tracks/haskell/exercises/robot-name/src/Robot.hs +3 -3
  118. data/tracks/haskell/exercises/robot-simulator/src/Robot.hs +6 -6
  119. data/tracks/haskell/exercises/roman-numerals/src/Roman.hs +1 -1
  120. data/tracks/haskell/exercises/run-length-encoding/src/RunLength.hs +2 -2
  121. data/tracks/haskell/exercises/saddle-points/src/Matrix.hs +1 -1
  122. data/tracks/haskell/exercises/say/src/Say.hs +1 -1
  123. data/tracks/haskell/exercises/scrabble-score/src/Scrabble.hs +2 -2
  124. data/tracks/haskell/exercises/secret-handshake/src/SecretHandshake.hs +1 -1
  125. data/tracks/haskell/exercises/series/src/Series.hs +1 -1
  126. data/tracks/haskell/exercises/sgf-parsing/src/Sgf.hs +1 -1
  127. data/tracks/haskell/exercises/sieve/src/Sieve.hs +1 -1
  128. data/tracks/haskell/exercises/simple-cipher/src/Cipher.hs +3 -3
  129. data/tracks/haskell/exercises/simple-linked-list/src/LinkedList.hs +8 -8
  130. data/tracks/haskell/exercises/space-age/src/SpaceAge.hs +1 -1
  131. data/tracks/haskell/exercises/strain/src/Strain.hs +2 -2
  132. data/tracks/haskell/exercises/sublist/src/Sublist.hs +1 -1
  133. data/tracks/haskell/exercises/sum-of-multiples/src/SumOfMultiples.hs +1 -1
  134. data/tracks/haskell/exercises/triangle/src/Triangle.hs +1 -1
  135. data/tracks/haskell/exercises/trinary/src/Trinary.hs +2 -2
  136. data/tracks/haskell/exercises/word-count/src/WordCount.hs +1 -1
  137. data/tracks/haskell/exercises/wordy/src/WordProblem.hs +1 -1
  138. data/tracks/haskell/exercises/zebra-puzzle/src/ZebraPuzzle.hs +1 -1
  139. data/tracks/haskell/exercises/zipper/src/Zipper.hs +9 -9
  140. data/tracks/java/docs/MAINTAINING.md +48 -0
  141. data/tracks/java/exercises/queen-attack/src/test/java/QueenAttackCalculatorTest.java +51 -51
  142. data/tracks/kotlin/exercises/etl/src/example/kotlin/ETL.kt +1 -1
  143. data/tracks/kotlin/exercises/etl/src/test/kotlin/ETLTest.kt +19 -19
  144. data/tracks/kotlin/exercises/pangram/src/test/kotlin/PangramTest.kt +5 -0
  145. data/tracks/lisp/docs/ABOUT.md +9 -0
  146. data/tracks/lua/exercises/transpose/example.lua +1 -1
  147. data/tracks/lua/exercises/transpose/transpose_spec.lua +16 -0
  148. data/tracks/pascal/config.json +36 -36
  149. data/tracks/pascal/exercises/bob/uBobTests.pas +0 -1
  150. data/tracks/pascal/exercises/hamming/uHammingTests.pas +0 -1
  151. data/tracks/pascal/exercises/leap/uLeapTests.pas +0 -1
  152. data/tracks/pascal/exercises/saddle-points/uSaddlePointsExample.pas +11 -0
  153. data/tracks/pascal/exercises/saddle-points/uSaddlePointsTests.pas +9 -1
  154. data/tracks/perl6/exercises/atbash-cipher/cipher.t +1 -1
  155. data/tracks/php/config.json +7 -0
  156. data/tracks/php/exercises/robot-simulator/example.php +148 -0
  157. data/tracks/php/exercises/robot-simulator/robot-simulator_test.php +168 -0
  158. data/tracks/pony/config.json +16 -7
  159. data/tracks/pony/exercises/roman-numerals/example.pony +35 -0
  160. data/tracks/pony/exercises/roman-numerals/test.pony +45 -0
  161. data/tracks/python/requirements-travis.txt +1 -1
  162. data/tracks/ruby/.rubocop.yml +1 -1
  163. data/tracks/ruby/bin/enable-executable +1 -1
  164. data/tracks/ruby/bin/executable-tests-check +1 -1
  165. data/tracks/ruby/exercises/acronym/example.tt +2 -3
  166. data/tracks/ruby/exercises/all-your-base/example.tt +2 -2
  167. data/tracks/ruby/exercises/alphametics/example.tt +2 -2
  168. data/tracks/ruby/exercises/anagram/example.tt +2 -3
  169. data/tracks/ruby/exercises/binary/example.tt +2 -3
  170. data/tracks/ruby/exercises/bowling/example.tt +2 -3
  171. data/tracks/ruby/exercises/bracket-push/example.tt +2 -3
  172. data/tracks/ruby/exercises/clock/example.tt +2 -3
  173. data/tracks/ruby/exercises/connect/example.rb +1 -1
  174. data/tracks/ruby/exercises/connect/example.tt +1 -1
  175. data/tracks/ruby/exercises/custom-set/example.tt +2 -3
  176. data/tracks/ruby/exercises/diamond/example.rb +1 -1
  177. data/tracks/ruby/exercises/difference-of-squares/example.tt +2 -3
  178. data/tracks/ruby/exercises/dominoes/example.tt +2 -2
  179. data/tracks/ruby/exercises/gigasecond/example.tt +2 -3
  180. data/tracks/ruby/exercises/grains/example.tt +2 -2
  181. data/tracks/ruby/exercises/hamming/example.tt +2 -3
  182. data/tracks/ruby/exercises/hello-world/example.tt +1 -2
  183. data/tracks/ruby/exercises/isogram/example.tt +2 -2
  184. data/tracks/ruby/exercises/largest-series-product/example.tt +2 -4
  185. data/tracks/ruby/exercises/leap/example.tt +2 -3
  186. data/tracks/ruby/exercises/nth-prime/example.tt +2 -4
  187. data/tracks/ruby/exercises/pangram/example.tt +2 -2
  188. data/tracks/ruby/exercises/queen-attack/example.tt +2 -3
  189. data/tracks/ruby/exercises/raindrops/example.tt +2 -3
  190. data/tracks/ruby/exercises/rna-transcription/example.tt +2 -3
  191. data/tracks/ruby/exercises/roman-numerals/example.tt +2 -3
  192. data/tracks/ruby/exercises/run-length-encoding/example.tt +2 -3
  193. data/tracks/ruby/exercises/sieve/example.tt +2 -4
  194. data/tracks/ruby/exercises/simple-linked-list/simple_linked_list_test.rb +6 -6
  195. data/tracks/ruby/exercises/tournament/example.tt +2 -3
  196. data/tracks/ruby/exercises/transpose/example.tt +2 -3
  197. data/tracks/ruby/exercises/triangle/example.tt +2 -3
  198. data/tracks/ruby/exercises/two-bucket/example.tt +2 -3
  199. data/tracks/ruby/exercises/word-count/example.tt +2 -3
  200. data/tracks/ruby/exercises/wordy/example.tt +2 -2
  201. data/tracks/ruby/lib/acronym_cases.rb +2 -0
  202. data/tracks/ruby/lib/all_your_base_cases.rb +3 -1
  203. data/tracks/ruby/lib/alphametics_cases.rb +6 -4
  204. data/tracks/ruby/lib/anagram_cases.rb +2 -0
  205. data/tracks/ruby/lib/binary_cases.rb +2 -0
  206. data/tracks/ruby/lib/bowling_cases.rb +2 -0
  207. data/tracks/ruby/lib/bracket_push_cases.rb +2 -0
  208. data/tracks/ruby/lib/clock_cases.rb +2 -0
  209. data/tracks/ruby/lib/connect_cases.rb +2 -0
  210. data/tracks/ruby/lib/custom_set_cases.rb +2 -0
  211. data/tracks/ruby/lib/difference_of_squares_cases.rb +2 -0
  212. data/tracks/ruby/lib/dominoes_cases.rb +2 -0
  213. data/tracks/ruby/lib/exercise_cases.rb +2 -0
  214. data/tracks/ruby/lib/generator/files/track_files.rb +3 -3
  215. data/tracks/ruby/lib/generator/files.rb +1 -1
  216. data/tracks/ruby/lib/generator/template_values.rb +5 -14
  217. data/tracks/ruby/lib/gigasecond_cases.rb +2 -0
  218. data/tracks/ruby/lib/grains_cases.rb +3 -1
  219. data/tracks/ruby/lib/hamming_cases.rb +2 -0
  220. data/tracks/ruby/lib/hello_world_cases.rb +2 -0
  221. data/tracks/ruby/lib/isogram_cases.rb +3 -1
  222. data/tracks/ruby/lib/largest_series_product_cases.rb +2 -0
  223. data/tracks/ruby/lib/leap_cases.rb +2 -0
  224. data/tracks/ruby/lib/nth_prime_cases.rb +2 -0
  225. data/tracks/ruby/lib/pangram_cases.rb +3 -1
  226. data/tracks/ruby/lib/queen_attack_cases.rb +2 -0
  227. data/tracks/ruby/lib/raindrops_cases.rb +2 -0
  228. data/tracks/ruby/lib/rna_transcription_cases.rb +2 -0
  229. data/tracks/ruby/lib/roman_numerals_cases.rb +2 -0
  230. data/tracks/ruby/lib/run_length_encoding_cases.rb +2 -0
  231. data/tracks/ruby/lib/sieve_cases.rb +2 -0
  232. data/tracks/ruby/lib/tournament_cases.rb +2 -0
  233. data/tracks/ruby/lib/transpose_cases.rb +2 -0
  234. data/tracks/ruby/lib/triangle_cases.rb +2 -0
  235. data/tracks/ruby/lib/two_bucket_cases.rb +2 -0
  236. data/tracks/ruby/lib/word_count_cases.rb +2 -0
  237. data/tracks/ruby/lib/wordy_cases.rb +2 -0
  238. data/tracks/ruby/test/fixtures/xruby/exercises/alpha/example.tt +2 -2
  239. data/tracks/ruby/test/fixtures/xruby/lib/alpha_cases.rb +1 -1
  240. data/tracks/ruby/test/generator/command_line_test.rb +1 -1
  241. data/tracks/ruby/test/generator/template_values_test.rb +7 -7
  242. data/tracks/rust/.travis.yml +4 -0
  243. data/tracks/rust/_test/check-exercises.sh +11 -2
  244. data/tracks/rust/config.json +9 -0
  245. data/tracks/rust/exercises/luhn/.gitignore +7 -0
  246. data/tracks/rust/exercises/luhn/Cargo.toml +3 -0
  247. data/tracks/rust/exercises/luhn/example.rs +13 -0
  248. data/tracks/rust/exercises/luhn/tests/luhn.rs +38 -0
  249. data/tracks/rust/exercises/parallel-letter-frequency/HINTS.md +32 -0
  250. data/tracks/rust/exercises/parallel-letter-frequency/benches/benchmark.rs +99 -0
  251. data/tracks/scala/config.json +57 -1
  252. data/tracks/scala/exercises/allergies/build.sbt +2 -2
  253. data/tracks/scala/exercises/atbash-cipher/build.sbt +2 -2
  254. data/tracks/scala/exercises/bank-account/build.sbt +3 -2
  255. data/tracks/scala/exercises/binary-search-tree/build.sbt +2 -2
  256. data/tracks/scala/exercises/clock/build.sbt +2 -2
  257. data/tracks/scala/exercises/crypto-square/build.sbt +2 -2
  258. data/tracks/scala/exercises/custom-set/build.sbt +3 -2
  259. data/tracks/scala/exercises/food-chain/build.sbt +3 -2
  260. data/tracks/scala/exercises/house/build.sbt +2 -2
  261. data/tracks/scala/exercises/kindergarten-garden/build.sbt +3 -2
  262. data/tracks/scala/exercises/largest-series-product/build.sbt +2 -2
  263. data/tracks/scala/exercises/linked-list/build.sbt +3 -2
  264. data/tracks/scala/exercises/matrix/build.sbt +2 -2
  265. data/tracks/scala/exercises/minesweeper/build.sbt +2 -2
  266. data/tracks/scala/exercises/nth-prime/build.sbt +2 -2
  267. data/tracks/scala/exercises/ocr-numbers/build.sbt +2 -2
  268. data/tracks/scala/exercises/palindrome-products/build.sbt +2 -2
  269. data/tracks/scala/exercises/prime-factors/build.sbt +3 -2
  270. data/tracks/scala/exercises/queen-attack/build.sbt +2 -2
  271. data/tracks/scala/exercises/raindrops/build.sbt +2 -2
  272. data/tracks/scala/exercises/robot-simulator/build.sbt +2 -2
  273. data/tracks/scala/exercises/triangle/build.sbt +2 -2
  274. data/tracks/scala/exercises/trinary/build.sbt +2 -2
  275. data/tracks/scala/exercises/wordy/build.sbt +3 -3
  276. metadata +33 -2
@@ -3,8 +3,7 @@ gem 'minitest', '>= 5.0.0'
3
3
  require 'minitest/autorun'
4
4
  require_relative 'word_count'
5
5
 
6
- # Test data version:
7
- # <%= sha1 %>
6
+ # Common test data version: <%= abbreviated_commit_hash %>
8
7
  class PhraseTest < Minitest::Test<% test_cases.each do |test_case| %>
9
8
  def <%= test_case.name %><% if test_case.skipped? %>
10
9
  skip<% end %>
@@ -16,7 +15,7 @@ class PhraseTest < Minitest::Test<% test_cases.each do |test_case| %>
16
15
  <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
17
16
  def test_bookkeeping
18
17
  skip
19
- assert_equal <%= version.next %>, BookKeeping::VERSION
18
+ assert_equal <%= version %>, BookKeeping::VERSION
20
19
  end
21
20
  end
22
21
 
@@ -1,7 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require_relative 'wordy'
3
3
 
4
- # Test data version: <%= sha1 %>
4
+ # Common test data version: <%= abbreviated_commit_hash %>
5
5
  class WordyTest < Minitest::Test<% test_cases.each do |test_case| %>
6
6
  def <%= test_case.test_name %>
7
7
  <%= test_case.skipped %>
@@ -12,6 +12,6 @@ class WordyTest < Minitest::Test<% test_cases.each do |test_case| %>
12
12
  <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
13
13
  def test_bookkeeping
14
14
  skip
15
- assert_equal <%= version.next %>, BookKeeping::VERSION
15
+ assert_equal <%= version %>, BookKeeping::VERSION
16
16
  end
17
17
  end
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class AcronymCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.tr(' ', '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class AllYourBaseCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.downcase.tr(' -', '_')
@@ -95,7 +97,7 @@ class AllYourBaseCase::PreProcessor
95
97
  end
96
98
 
97
99
  def handle_special_cases
98
- [4,2] if row['input_digits'] == [0, 6, 0]
100
+ [4, 2] if row['input_digits'] == [0, 6, 0]
99
101
  end
100
102
  end
101
103
  end
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class AlphameticsCase < OpenStruct
2
4
  def test_name
3
5
  "test_#{description.tr(' ', '_')}"
@@ -20,7 +22,7 @@ class AlphameticsCase < OpenStruct
20
22
  "input = %s\n" % input,
21
23
  "expected = %s\n" % expect,
22
24
  "assert_equal expected, Alphametics.solve(input)"
23
- indent(body,4)
25
+ indent(body, 4)
24
26
  end
25
27
 
26
28
  def runtime_comment
@@ -30,7 +32,7 @@ class AlphameticsCase < OpenStruct
30
32
  "# The obvious algorithm can take a long time to solve this puzzle,\n",
31
33
  "# but an optimised solution can solve it fairly quickly.\n",
32
34
  "# (It's OK to submit your solution without getting this test to pass.)\n"
33
- indent(comments,2)
35
+ indent(comments, 2)
34
36
  end
35
37
  end
36
38
 
@@ -41,7 +43,7 @@ class AlphameticsCase < OpenStruct
41
43
  end
42
44
 
43
45
  def expected_values
44
- "{ #{indent(expected_values_as_lines,17)} }"
46
+ "{ #{indent(expected_values_as_lines, 17)} }"
45
47
  end
46
48
 
47
49
  def expected_values_as_lines
@@ -50,7 +52,7 @@ class AlphameticsCase < OpenStruct
50
52
  end
51
53
 
52
54
  def expected_values_as_strings
53
- expected.sort.map { |(key,value)| "'#{key}' => #{value}" }
55
+ expected.sort.map { |(key, value)| "'#{key}' => #{value}" }
54
56
  end
55
57
 
56
58
  def add_trailing_comma_and_newline(lines)
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class AnagramCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.gsub(/[ -]/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class BinaryCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.gsub(/[ -]/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class BowlingCase < OpenStruct
2
4
  def test_name
3
5
  "test_#{description.downcase.tr(' ', '_')}"
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class BracketPushCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.gsub(/[ -]/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class ClockCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class ConnectCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class CustomSetCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.gsub(/ |-/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class DifferenceOfSquaresCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.gsub(/[ -]/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class DominoesCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.gsub("can't", 'can not').gsub(/[= -]+/, '_')
@@ -0,0 +1,2 @@
1
+ require 'ostruct'
2
+ require 'json'
@@ -11,7 +11,7 @@ module Generator
11
11
  end
12
12
 
13
13
  def filename(exercise_name)
14
- "#{exercise_name.tr('-','_')}_cases"
14
+ "#{exercise_name.tr('-', '_')}_cases"
15
15
  end
16
16
 
17
17
  def proc_name(exercise_name)
@@ -19,7 +19,7 @@ module Generator
19
19
  end
20
20
 
21
21
  def exercise_name(filename)
22
- %r{([^/]*)_cases\.rb$}.match(filename).captures[0].tr('_','-')
22
+ %r{([^/]*)_cases\.rb$}.match(filename).captures[0].tr('_', '-')
23
23
  end
24
24
  end
25
25
 
@@ -71,7 +71,7 @@ module Generator
71
71
  end
72
72
 
73
73
  class MinitestTestsFile < Writable
74
- def generate(template:,values:)
74
+ def generate(template:, values:)
75
75
  content = ERB.new(template, nil, '<>').result values.get_binding
76
76
  save(content)
77
77
  end
@@ -4,7 +4,7 @@ module Generator
4
4
  module Files
5
5
  class Readable
6
6
  attr_reader :filename, :repository_root
7
- def initialize(filename:,repository_root: nil)
7
+ def initialize(filename:, repository_root: nil)
8
8
  @filename = filename
9
9
  @repository_root = repository_root
10
10
  end
@@ -1,10 +1,10 @@
1
1
  module Generator
2
2
  # Contains methods accessible to the ERB template
3
3
  class TemplateValues
4
- attr_reader :sha1, :version, :test_cases
4
+ attr_reader :abbreviated_commit_hash, :version, :test_cases
5
5
 
6
- def initialize(sha1:, version:, test_cases:)
7
- @sha1 = sha1
6
+ def initialize(abbreviated_commit_hash:, version:, test_cases:)
7
+ @abbreviated_commit_hash = abbreviated_commit_hash
8
8
  @version = version
9
9
  @test_cases = test_cases
10
10
  end
@@ -16,20 +16,11 @@ module Generator
16
16
 
17
17
  module TemplateValuesFactory
18
18
  def template_values
19
- # These are needed by the 'ExerciseCases' classes
20
- # TODO: move these into the individual classes
21
- require 'ostruct'
22
- require 'json'
23
19
  require cases_require_name
24
20
 
25
- # Compensate for the version.next that appears in template files.
26
- # TODO: remove the .next from the template files and remove compensation
27
- compensated_version = version - 1
28
-
29
21
  TemplateValues.new(
30
- # TODO: rename sha1 to abbreviated_commit_hash
31
- sha1: canonical_data.abbreviated_commit_hash,
32
- version: compensated_version,
22
+ abbreviated_commit_hash: canonical_data.abbreviated_commit_hash,
23
+ version: version,
33
24
  test_cases: test_cases_proc.call(canonical_data.to_s)
34
25
  )
35
26
  end
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  require 'time'
2
4
 
3
5
  class GigasecondCase < OpenStruct
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class GrainsCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.downcase.tr_s(' ', '_')
@@ -14,7 +16,7 @@ class GrainsCase < OpenStruct
14
16
  private
15
17
 
16
18
  def underscore_format(number)
17
- number.to_s.reverse.gsub(/...(?=.)/,'\&_').reverse
19
+ number.to_s.reverse.gsub(/...(?=.)/, '\&_').reverse
18
20
  end
19
21
  end
20
22
 
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class HammingCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.gsub(/[ -]/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class HelloWorldCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.gsub(/[ -]/, '_')
@@ -1,7 +1,9 @@
1
+ require 'exercise_cases'
2
+
1
3
  class IsogramCase < OpenStruct
2
4
 
3
5
  def name
4
- format('test_%s', description.downcase.gsub(/[ -]/,'_'))
6
+ format('test_%s', description.downcase.gsub(/[ -]/, '_'))
5
7
  end
6
8
 
7
9
  def assertion
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class LargestSeriesProductCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.tr('()', '').tr(' -', '_').downcase
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class LeapCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.downcase.gsub(/[ -]/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class NthPrimeCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.downcase.gsub(/[ -]/, '_')
@@ -1,6 +1,8 @@
1
+ require 'exercise_cases'
2
+
1
3
  class PangramCase < OpenStruct
2
4
  def name
3
- 'test_%s' % description.downcase.tr_s(" -'", '_').sub(/_$/,'')
5
+ 'test_%s' % description.downcase.tr_s(" -'", '_').sub(/_$/, '')
4
6
  end
5
7
 
6
8
  def workload
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class QueenCase < OpenStruct
2
4
  def test_name
3
5
  "test_#{description.gsub(/[ ]/, '_')}"
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class RaindropsCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % number
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class RnaTranscriptionCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.gsub(/[ -]/, '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class RomanNumeralsCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % number.to_s
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class RunLengthEncodingCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % cleaned_description
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class SieveCase < OpenStruct
2
4
  OPEN_ARRAY = "[\n\s\s\s\s\s\s".freeze
3
5
  CLOSE_ARRAY = "\n\s\s\s\s]".freeze
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class TournamentCase < OpenStruct
2
4
  def test_name
3
5
  "test_#{description.tr(' ', '_').tr('()', '')}"
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class TransposeCase < OpenStruct
2
4
  def test_name
3
5
  "test_#{description.tr(' ', '_')}"
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class TriangleCase < OpenStruct
2
4
  def test_name
3
5
  initial = description.downcase
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class TwoBucketCase < OpenStruct
2
4
  def test_name
3
5
  "test_bucket_one_#{bucket_one}_bucket_two_"\
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class WordCountCase < OpenStruct
2
4
  def name
3
5
  'test_%s' % description.tr(' ', '_')
@@ -1,3 +1,5 @@
1
+ require 'exercise_cases'
2
+
1
3
  class WordyCase < OpenStruct
2
4
  def test_name
3
5
  'test_%s' % description.downcase.tr(' ', '_')
@@ -4,7 +4,7 @@
4
4
  require 'minitest/autorun'
5
5
  require_relative 'alpha'
6
6
 
7
- # Common test data version: <%= sha1 %>
7
+ # Common test data version: <%= abbreviated_commit_hash %>
8
8
  class AlphaTest < Minitest::Test<% test_cases.each do |test_case| %>
9
9
  def <%= test_case.name %>
10
10
  <%= test_case.skip %>
@@ -15,6 +15,6 @@ class AlphaTest < Minitest::Test<% test_cases.each do |test_case| %>
15
15
  <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
16
16
  def test_bookkeeping
17
17
  skip
18
- assert_equal <%= version.next %>, BookKeeping::VERSION
18
+ assert_equal <%= version %>, BookKeeping::VERSION
19
19
  end
20
20
  end
@@ -1,7 +1,7 @@
1
1
  class AlphaCase < OpenStruct
2
2
 
3
3
  def name
4
- format('test_%s', description.downcase.gsub(/[ -]/,'_'))
4
+ format('test_%s', description.downcase.gsub(/[ -]/, '_'))
5
5
  end
6
6
 
7
7
  def assertion
@@ -16,7 +16,7 @@ module Generator
16
16
 
17
17
  def test_invalid_metadata_repository_outputs_message_to_stderr
18
18
  paths = Paths.new(metadata: 'test/fixtures/nonexistent', track: nil)
19
- expected_stderr = <<-MESSAGE.gsub(/^ {6}/,'')
19
+ expected_stderr = <<-MESSAGE.gsub(/^ {6}/, '')
20
20
  'x-common' repository not found.
21
21
  Try running the command:
22
22
  git clone https://github.com/exercism/x-common.git "test/fixtures/nonexistent"
@@ -2,26 +2,26 @@ require_relative '../test_helper'
2
2
 
3
3
  module Generator
4
4
  class TestCasesValuesTest < Minitest::Test
5
- def test_sha1
6
- expected_sha1 = '1234567'
7
- subject = TemplateValues.new(sha1: expected_sha1, version: nil, test_cases: nil)
8
- assert_equal expected_sha1, subject.sha1
5
+ def test_abbreviated_commit_hash
6
+ expected_abbreviated_commit_hash = '1234567'
7
+ subject = TemplateValues.new(abbreviated_commit_hash: expected_abbreviated_commit_hash, version: nil, test_cases: nil)
8
+ assert_equal expected_abbreviated_commit_hash, subject.abbreviated_commit_hash
9
9
  end
10
10
 
11
11
  def test_version
12
12
  expected_version = '1234567'
13
- subject = TemplateValues.new(version: expected_version, sha1: nil, test_cases: nil)
13
+ subject = TemplateValues.new(version: expected_version, abbreviated_commit_hash: nil, test_cases: nil)
14
14
  assert_equal expected_version, subject.version
15
15
  end
16
16
 
17
17
  def test_test_cases
18
18
  expected_test_cases = 'should be TemplateValues class'
19
- subject = TemplateValues.new(test_cases: expected_test_cases, sha1: nil, version: nil)
19
+ subject = TemplateValues.new(test_cases: expected_test_cases, abbreviated_commit_hash: nil, version: nil)
20
20
  assert_equal expected_test_cases, subject.test_cases
21
21
  end
22
22
 
23
23
  def test_get_binding
24
- subject = TemplateValues.new(sha1: nil,version: nil, test_cases: nil)
24
+ subject = TemplateValues.new(abbreviated_commit_hash: nil, version: nil, test_cases: nil)
25
25
  assert_instance_of Binding, subject.get_binding
26
26
  end
27
27
  end
@@ -13,6 +13,10 @@ env:
13
13
  - DENYWARNINGS=
14
14
  - DENYWARNINGS=1
15
15
  matrix:
16
+ include:
17
+ - rust: nightly
18
+ env: BENCHMARK=1
19
+ script: "./_test/check-exercises.sh"
16
20
  allow_failures:
17
21
  - rust: nightly
18
22
  - rust: beta
@@ -6,6 +6,12 @@ if [ -z "$DENYWARNINGS" ]; then
6
6
  set -e
7
7
  fi
8
8
 
9
+ if [ -n "$BENCHMARK" ]; then
10
+ files=exercises/*/benches
11
+ else
12
+ files=exercises/*/tests
13
+ fi
14
+
9
15
  tmp=${TMPDIR:-/tmp/}
10
16
  mkdir "${tmp}exercises"
11
17
 
@@ -13,7 +19,7 @@ exitcode=0
13
19
 
14
20
  # An exercise worth testing is defined here as any top level directory with
15
21
  # a 'tests' directory
16
- for exercise in exercises/*/tests; do
22
+ for exercise in $files; do
17
23
  # This assumes that exercises are only one directory deep
18
24
  # and that the primary module is named the same as the directory
19
25
  directory=$(dirname "${exercise}");
@@ -38,7 +44,10 @@ for exercise in exercises/*/tests; do
38
44
  sed -i '/\[ignore\]/d' $test
39
45
  done
40
46
 
41
- if [ -n "$DENYWARNINGS" ]; then
47
+ # Run benchmarks instead of tests when enabled.
48
+ if [ -n "$BENCHMARK" ]; then
49
+ cargo bench
50
+ elif [ -n "$DENYWARNINGS" ]; then
42
51
  sed -i -e '1i #![deny(warnings)]' src/lib.rs
43
52
 
44
53
  # No-run mode so we see no test output.
@@ -122,6 +122,15 @@
122
122
  "match"
123
123
  ]
124
124
  },
125
+ {
126
+ "slug": "luhn",
127
+ "difficulty": 1,
128
+ "topics": [
129
+ "str to digits",
130
+ "iterators",
131
+ "higher-order functions"
132
+ ]
133
+ },
125
134
  {
126
135
  "slug": "largest-series-product",
127
136
  "difficulty": 1,
@@ -0,0 +1,7 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
5
+ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6
+ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
7
+ Cargo.lock
@@ -0,0 +1,3 @@
1
+ [package]
2
+ name = "luhn"
3
+ version = "0.0.0"
@@ -0,0 +1,13 @@
1
+ pub fn is_valid(candidate: &str) -> bool {
2
+ if candidate.chars().any(|c| c.is_alphabetic()) || candidate.chars().count() == 1 {
3
+ return false;
4
+ }
5
+
6
+ candidate.chars()
7
+ .filter_map(|c| c.to_digit(10))
8
+ .rev()
9
+ .enumerate()
10
+ .map(|(index, digit)| if index % 2 == 0 { digit } else { digit * 2 })
11
+ .map(|digit| if digit > 9 { digit - 9 } else { digit })
12
+ .sum::<u32>() % 10 == 0
13
+ }
@@ -0,0 +1,38 @@
1
+ extern crate luhn;
2
+
3
+ use luhn::*;
4
+
5
+ #[test]
6
+ fn single_digit_string_is_invalid() {
7
+ assert!(!is_valid("1"));
8
+ }
9
+
10
+ #[test]
11
+ #[ignore]
12
+ fn single_zero_string_is_invalid() {
13
+ assert!(!is_valid("0"));
14
+ }
15
+
16
+ #[test]
17
+ #[ignore]
18
+ fn valid_canadian_sin_is_valid() {
19
+ assert!(is_valid("046 454 286"));
20
+ }
21
+
22
+ #[test]
23
+ #[ignore]
24
+ fn invalid_canadian_sin_is_invalid() {
25
+ assert!(!is_valid("046 454 287"));
26
+ }
27
+
28
+ #[test]
29
+ #[ignore]
30
+ fn invalid_credit_card_is_invalid() {
31
+ assert!(!is_valid("8273 1232 7352 0569"));
32
+ }
33
+
34
+ #[test]
35
+ #[ignore]
36
+ fn strings_that_contain_non_digits_are_invalid() {
37
+ assert!(!is_valid("046a 454 286"));
38
+ }
@@ -0,0 +1,32 @@
1
+ # Parallel Letter Frequency in Rust
2
+
3
+ Learn more about concurrency in Rust here:
4
+
5
+ - [Concurrency](https://doc.rust-lang.org/book/concurrency.html)
6
+
7
+ ## Bonus
8
+
9
+ This exercise also includes a benchmark, with a sequential implementation as a
10
+ baseline. You can compare your solution to the benchmark. Observe the
11
+ effect different size inputs have on the performance of each. Can you
12
+ surpass the benchmark using concurrent programming techniques?
13
+
14
+ As of this writing, test::Bencher is unstable and only available on
15
+ *nightly* Rust. Run the benchmarks with Cargo:
16
+
17
+ ```
18
+ cargo bench
19
+ ```
20
+
21
+ If you are using rustup.rs:
22
+
23
+ ```
24
+ rustup run nightly cargo bench
25
+ ```
26
+
27
+ - [Benchmark tests](https://doc.rust-lang.org/book/benchmark-tests.html)
28
+
29
+ Learn more about nightly Rust:
30
+
31
+ - [Nightly Rust](https://doc.rust-lang.org/book/nightly-rust.html)
32
+ - [Rustup: Working with nightly](https://github.com/rust-lang-nursery/rustup.rs#working-with-nightly-rust)