trackler 2.0.0.1 → 2.0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bump-content +3 -1
  3. data/bin/verify-metadata +2 -2
  4. data/common/exercises/alphametics/canonical-data.json +19 -9
  5. data/common/exercises/food-chain/canonical-data.json +7 -1
  6. data/common/exercises/grains/canonical-data.json +66 -0
  7. data/common/exercises/raindrops/description.md +4 -5
  8. data/common/exercises/triangle/canonical-data.json +81 -54
  9. data/lib/trackler/version.rb +1 -1
  10. data/tracks/c/config.json +26 -19
  11. data/tracks/c/exercises/allergies/makefile +15 -0
  12. data/tracks/c/exercises/allergies/src/allergies.h +21 -0
  13. data/tracks/c/exercises/allergies/src/example.c +32 -0
  14. data/tracks/c/exercises/allergies/src/example.h +26 -0
  15. data/tracks/c/exercises/allergies/test/test_allergies.c +203 -0
  16. data/tracks/c/exercises/allergies/test/vendor/unity.c +1300 -0
  17. data/tracks/c/exercises/allergies/test/vendor/unity.h +274 -0
  18. data/tracks/c/exercises/allergies/test/vendor/unity_internals.h +701 -0
  19. data/tracks/c/exercises/atbash-cipher/makefile +16 -0
  20. data/tracks/c/exercises/atbash-cipher/src/example.c +71 -0
  21. data/tracks/c/exercises/atbash-cipher/src/example.h +7 -0
  22. data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +113 -0
  23. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.c +1300 -0
  24. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.h +274 -0
  25. data/tracks/c/exercises/atbash-cipher/test/vendor/unity_internals.h +701 -0
  26. data/tracks/c/exercises/phone-number/makefile +16 -0
  27. data/tracks/c/exercises/phone-number/src/example.c +66 -0
  28. data/tracks/c/exercises/phone-number/src/example.h +8 -0
  29. data/tracks/c/exercises/phone-number/test/test_phone_number.c +108 -0
  30. data/tracks/c/exercises/phone-number/test/vendor/unity.c +1300 -0
  31. data/tracks/c/exercises/phone-number/test/vendor/unity.h +274 -0
  32. data/tracks/c/exercises/phone-number/test/vendor/unity_internals.h +701 -0
  33. data/tracks/csharp/config.json +8 -0
  34. data/tracks/csharp/exercises/bowling/BowlingTest.cs +188 -33
  35. data/tracks/csharp/exercises/bowling/Example.cs +38 -9
  36. data/tracks/csharp/exercises/rectangles/Example.cs +91 -0
  37. data/tracks/csharp/exercises/rectangles/RectanglesTest.cs +133 -0
  38. data/tracks/elisp/docs/INSTALLATION.org +1 -1
  39. data/tracks/elixir/config.json +8 -66
  40. data/tracks/elixir/docs/LEARNING.md +1 -1
  41. data/tracks/elixir/exercises/diamond/diamond_test.exs +12 -12
  42. data/tracks/elixir/exercises/grep/example.exs +92 -0
  43. data/tracks/elixir/exercises/grep/grep.exs +6 -0
  44. data/tracks/elixir/exercises/grep/grep_test.exs +259 -0
  45. data/tracks/elixir/exercises/markdown/markdown.exs +59 -2
  46. data/tracks/elixir/exercises/nucleotide-count/nucleotide_count_test.exs +4 -4
  47. data/tracks/elixir/exercises/phone-number/phone_number_test.exs +5 -0
  48. data/tracks/fsharp/exercises/bowling/BowlingTest.fs +158 -43
  49. data/tracks/fsharp/exercises/bowling/Example.fs +53 -24
  50. data/tracks/go/config.json +5 -0
  51. data/tracks/go/exercises/diamond/diamond_test.go +227 -0
  52. data/tracks/go/exercises/diamond/example.go +47 -0
  53. data/tracks/go/exercises/food-chain/example.go +1 -1
  54. data/tracks/go/exercises/food-chain/food_chain_test.go +30 -6
  55. data/tracks/go/exercises/nucleotide-count/example.go +21 -8
  56. data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +45 -37
  57. data/tracks/haskell/exercises/anagram/test/Tests.hs +1 -11
  58. data/tracks/java/bin/journey-test.sh +165 -128
  59. data/tracks/java/docs/ABOUT.md +5 -8
  60. data/tracks/java/exercises/hello-world/build.gradle +0 -6
  61. data/tracks/java/exercises/hello-world/src/test/java/HelloWorldTest.java +0 -1
  62. data/tracks/java/exercises/meetup/build.gradle +0 -1
  63. data/tracks/java/exercises/meetup/src/example/java/Meetup.java +9 -7
  64. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +185 -188
  65. data/tracks/lua/config.json +0 -73
  66. data/tracks/lua/exercises/bowling/bowling_spec.lua +92 -48
  67. data/tracks/lua/exercises/bowling/example.lua +4 -1
  68. data/tracks/objective-c/config.json +9 -30
  69. data/tracks/objective-c/exercises/pangram/PangramExample.h +7 -0
  70. data/tracks/objective-c/exercises/pangram/PangramExample.m +21 -0
  71. data/tracks/objective-c/exercises/pangram/PangramTest.m +51 -0
  72. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  73. data/tracks/ocaml/README.md +46 -1
  74. data/tracks/ocaml/SETUP.md +21 -2
  75. data/tracks/ocaml/config.json +48 -78
  76. data/tracks/perl5/README.md +15 -8
  77. data/tracks/perl5/testall.pl +5 -5
  78. data/tracks/php/config.json +26 -34
  79. data/tracks/php/docs/ABOUT.md +15 -0
  80. data/tracks/php/exercises/allergies/allergies_test.php +121 -0
  81. data/tracks/php/exercises/allergies/example.php +64 -0
  82. data/tracks/php/exercises/etl/etl_test.php +52 -0
  83. data/tracks/php/exercises/etl/example.php +12 -0
  84. data/tracks/php/exercises/nucleotide-count/example.php +25 -0
  85. data/tracks/php/exercises/nucleotide-count/nucleotide-count_test.php +36 -0
  86. data/tracks/php/exercises/pig-latin/example.php +25 -29
  87. data/tracks/php/exercises/pig-latin/pig-latin_test.php +26 -19
  88. data/tracks/php/exercises/space-age/example.php +65 -0
  89. data/tracks/php/exercises/space-age/space-age_test.php +70 -0
  90. data/tracks/php/exercises/triangle/example.php +43 -0
  91. data/tracks/php/exercises/triangle/triangle_test.php +140 -0
  92. data/tracks/pony/exercises/anagram/example.pony +6 -6
  93. data/tracks/pony/exercises/anagram/test.pony +3 -4
  94. data/tracks/pony/exercises/bob/test.pony +23 -23
  95. data/tracks/pony/exercises/difference-of-squares/test.pony +11 -11
  96. data/tracks/pony/exercises/hamming/example.pony +3 -3
  97. data/tracks/pony/exercises/hamming/test.pony +16 -16
  98. data/tracks/pony/exercises/hello-world/test.pony +5 -4
  99. data/tracks/pony/exercises/leap/test.pony +8 -8
  100. data/tracks/python/config.json +18 -0
  101. data/tracks/python/exercises/diamond/diamond_test.py +33 -0
  102. data/tracks/python/exercises/diamond/example.py +15 -0
  103. data/tracks/python/exercises/linked-list/example.py +47 -0
  104. data/tracks/python/exercises/linked-list/linked_list.py +13 -0
  105. data/tracks/python/exercises/linked-list/linked_list_test.py +49 -0
  106. data/tracks/python/exercises/list-ops/example.py +55 -0
  107. data/tracks/python/exercises/list-ops/list_ops.py +38 -0
  108. data/tracks/python/exercises/list-ops/list_ops_test.py +136 -0
  109. data/tracks/ruby/bin/generate +22 -2
  110. data/tracks/ruby/config.json +12 -83
  111. data/tracks/ruby/exercises/allergies/allergies_test.rb +0 -1
  112. data/tracks/ruby/exercises/atbash-cipher/atbash_cipher_test.rb +0 -1
  113. data/tracks/ruby/exercises/beer-song/beer_song_test.rb +1 -2
  114. data/tracks/ruby/exercises/binary/example.rb +0 -1
  115. data/tracks/ruby/exercises/binary-search-tree/binary_search_tree_test.rb +1 -1
  116. data/tracks/ruby/exercises/bowling/.version +1 -0
  117. data/tracks/ruby/exercises/bowling/bowling_test.rb +109 -133
  118. data/tracks/ruby/exercises/bowling/example.rb +7 -7
  119. data/tracks/ruby/exercises/bowling/example.tt +27 -0
  120. data/tracks/ruby/exercises/circular-buffer/circular_buffer_test.rb +0 -2
  121. data/tracks/ruby/exercises/clock/example.rb +0 -2
  122. data/tracks/ruby/exercises/connect/connect_test.rb +0 -1
  123. data/tracks/ruby/exercises/custom-set/custom_set_test.rb +0 -1
  124. data/tracks/ruby/exercises/diamond/diamond_test.rb +0 -1
  125. data/tracks/ruby/exercises/etl/etl_test.rb +1 -1
  126. data/tracks/ruby/exercises/house/house_test.rb +0 -1
  127. data/tracks/ruby/exercises/isogram/isogram_test.rb +2 -2
  128. data/tracks/ruby/exercises/largest-series-product/example.tt +0 -3
  129. data/tracks/ruby/exercises/largest-series-product/largest_series_product_test.rb +0 -4
  130. data/tracks/ruby/exercises/linked-list/linked_list_test.rb +1 -1
  131. data/tracks/ruby/exercises/meetup/meetup_test.rb +0 -1
  132. data/tracks/ruby/exercises/nth-prime/example.tt +0 -2
  133. data/tracks/ruby/exercises/nth-prime/nth_prime_test.rb +0 -2
  134. data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +1 -2
  135. data/tracks/ruby/exercises/protein-translation/protein_translation_test.rb +0 -1
  136. data/tracks/ruby/exercises/proverb/proverb_test.rb +1 -3
  137. data/tracks/ruby/exercises/queen-attack/example.rb +3 -1
  138. data/tracks/ruby/exercises/queen-attack/queen_attack_test.rb +34 -8
  139. data/tracks/ruby/exercises/robot-simulator/robot_simulator_test.rb +1 -1
  140. data/tracks/ruby/exercises/strain/strain_test.rb +2 -2
  141. data/tracks/ruby/exercises/tournament/.version +1 -0
  142. data/tracks/ruby/exercises/tournament/example.rb +54 -0
  143. data/tracks/ruby/exercises/tournament/example.tt +23 -0
  144. data/tracks/ruby/exercises/tournament/tournament_test.rb +92 -0
  145. data/tracks/ruby/exercises/transpose/.version +1 -0
  146. data/tracks/ruby/exercises/transpose/example.rb +14 -0
  147. data/tracks/ruby/exercises/transpose/example.tt +22 -0
  148. data/tracks/ruby/exercises/transpose/transpose_test.rb +303 -0
  149. data/tracks/ruby/lib/bowling_cases.rb +46 -0
  150. data/tracks/ruby/lib/isogram_cases.rb +1 -1
  151. data/tracks/ruby/lib/tournament_cases.rb +45 -0
  152. data/tracks/ruby/lib/transpose_cases.rb +45 -0
  153. data/tracks/rust/config.json +2 -0
  154. data/tracks/rust/exercises/bowling/.gitignore +7 -0
  155. data/tracks/rust/exercises/bowling/Cargo.toml +3 -0
  156. data/tracks/rust/exercises/bowling/example.rs +134 -0
  157. data/tracks/rust/exercises/bowling/tests/bowling.rs +373 -0
  158. data/tracks/rust/exercises/grains/.gitignore +7 -0
  159. data/tracks/rust/exercises/grains/Cargo.toml +3 -0
  160. data/tracks/rust/exercises/grains/example.rs +11 -0
  161. data/tracks/rust/exercises/grains/src/lib.rs +7 -0
  162. data/tracks/rust/exercises/grains/tests/grains.rs +63 -0
  163. data/tracks/rust/problems.md +2 -0
  164. data/tracks/scala/README.md +38 -0
  165. data/tracks/scala/config.json +20 -74
  166. data/tracks/scala/exercises/accumulate/src/test/scala/accumulate_test.scala +4 -0
  167. data/tracks/scala/exercises/allergies/src/test/scala/allergies_test.scala +11 -0
  168. data/tracks/scala/exercises/alphametics/build.sbt +6 -0
  169. data/tracks/scala/exercises/alphametics/example.scala +125 -0
  170. data/tracks/scala/exercises/alphametics/src/main/scala/.keep +0 -0
  171. data/tracks/scala/exercises/alphametics/src/test/scala/AlphameticsTest.scala +62 -0
  172. data/tracks/scala/exercises/atbash-cipher/src/test/scala/atbash_test.scala +8 -0
  173. data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +4 -0
  174. data/tracks/scala/exercises/binary/src/test/scala/binary_test.scala +13 -0
  175. data/tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala +11 -0
  176. data/tracks/scala/exercises/bowling/Example.scala +116 -0
  177. data/tracks/scala/exercises/bowling/build.sbt +3 -0
  178. data/tracks/scala/exercises/bowling/src/main/scala/Bowling.scala +11 -0
  179. data/tracks/scala/exercises/bowling/src/test/scala/BowlingSuite.scala +237 -0
  180. data/tracks/scala/exercises/clock/src/test/scala/ClockTest.scala +50 -0
  181. data/tracks/scala/exercises/connect/README.md +17 -0
  182. data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +7 -0
  183. data/tracks/scala/exercises/crypto-square/src/test/scala/{CrytpoSquareTest.scala → CryptoSquareTest.scala} +9 -0
  184. data/tracks/scala/exercises/custom-set/src/test/scala/CustomSetTest.scala +36 -0
  185. data/tracks/scala/exercises/difference-of-squares/src/test/scala/squares_test.scala +8 -0
  186. data/tracks/scala/exercises/forth/src/test/scala/ForthTest.scala +22 -0
  187. data/tracks/scala/exercises/hexadecimal/src/test/scala/HexadecimalTest.scala +8 -0
  188. data/tracks/scala/exercises/kindergarten-garden/src/test/scala/GardenTest.scala +5 -0
  189. data/tracks/scala/exercises/largest-series-product/src/test/scala/SeriesTest.scala +2 -0
  190. data/tracks/scala/exercises/linked-list/src/test/scala/DequeTest.scala +4 -0
  191. data/tracks/scala/exercises/luhn/src/test/scala/LuhnTest.scala +4 -0
  192. data/tracks/scala/exercises/matrix/src/test/scala/MatrixTest.scala +2 -0
  193. data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +6 -0
  194. data/tracks/scala/exercises/nth-prime/src/test/scala/PrimeTest.scala +5 -0
  195. data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrTest.scala +15 -0
  196. data/tracks/scala/exercises/octal/src/test/scala/OctalTest.scala +7 -0
  197. data/tracks/scala/exercises/parallel-letter-frequency/src/test/scala/FrequencyTest.scala +8 -0
  198. data/tracks/scala/exercises/pascals-triangle/src/test/scala/PascalsTriangleTest.scala +5 -0
  199. data/tracks/scala/exercises/pig-latin/src/test/scala/PigLatinTest.scala +4 -0
  200. data/tracks/scala/exercises/pythagorean-triplet/src/test/scala/PythagoreanTripletTest.scala +3 -0
  201. data/tracks/scala/exercises/queen-attack/src/test/scala/QueensTest.scala +5 -0
  202. data/tracks/scala/exercises/robot-simulator/src/test/scala/RobotTest.scala +16 -8
  203. data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +34 -17
  204. data/tracks/scala/exercises/scrabble-score/src/test/scala/scrabble_score_test.scala +6 -0
  205. data/tracks/scala/exercises/secret-handshake/src/test/scala/SecretHandshakeTest.scala +18 -9
  206. data/tracks/scala/exercises/series/src/test/scala/SeriesTest.scala +4 -2
  207. data/tracks/scala/exercises/sieve/src/test/scala/SieveTest.scala +8 -4
  208. data/tracks/scala/exercises/simple-cipher/src/test/scala/CipherTest.scala +17 -9
  209. data/tracks/scala/exercises/sublist/src/test/scala/sublist_test.scala +17 -0
  210. data/tracks/scala/exercises/trinary/src/test/scala/TrinaryTest.scala +14 -7
  211. data/tracks/scala/exercises/wordy/src/test/scala/WordProblemTest.scala +28 -14
  212. data/tracks/scala/project/Build.scala +3 -3
  213. data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +57 -0
  214. data/tracks/sml/config.json +41 -6
  215. data/tracks/sml/exercises/flatten-array/example.sml +6 -0
  216. data/tracks/sml/exercises/flatten-array/test_flatten_array.sml +10 -0
  217. data/tracks/sml/exercises/nth-prime/example.sml +46 -0
  218. data/tracks/sml/exercises/nth-prime/test_nth_prime.sml +14 -0
  219. data/tracks/sml/exercises/raindrops/example.sml +9 -0
  220. data/tracks/sml/exercises/raindrops/raindrops.sml +2 -0
  221. data/tracks/sml/exercises/raindrops/test_raindrops.sml +95 -0
  222. data/tracks/swift/config.json +269 -328
  223. data/tracks/swift/exercises/pangram/PangramExample.swift +17 -0
  224. data/tracks/swift/exercises/pangram/PangramTest.swift +43 -0
  225. data/tracks/swift/xcodeProject/xSwift.xcodeproj/project.pbxproj +16 -0
  226. metadata +95 -3
@@ -10,22 +10,22 @@ actor Main is TestList
10
10
  fun tag tests(test: PonyTest) =>
11
11
  test(_TestSquares)
12
12
 
13
- class _TestSquares iso is UnitTest
13
+ class iso _TestSquares is UnitTest
14
14
  """
15
15
  Test Difference of Squares package
16
16
  """
17
17
 
18
18
  fun name(): String => "difference-of-squares/Squares"
19
19
 
20
- fun apply(h: TestHelper): TestResult =>
21
- h.expect_eq[U32](225, Squares(5).square_of_sums())
22
- h.expect_eq[U32](55, Squares(5).sum_of_squares())
23
- h.expect_eq[U32](170, Squares(5).difference())
20
+ fun apply(h: TestHelper) =>
21
+ h.assert_eq[U32](225, Squares(5).square_of_sums())
22
+ h.assert_eq[U32](55, Squares(5).sum_of_squares())
23
+ h.assert_eq[U32](170, Squares(5).difference())
24
24
 
25
- h.expect_eq[U32](3025, Squares(10).square_of_sums())
26
- h.expect_eq[U32](385, Squares(10).sum_of_squares())
27
- h.expect_eq[U32](2640, Squares(10).difference())
25
+ h.assert_eq[U32](3025, Squares(10).square_of_sums())
26
+ h.assert_eq[U32](385, Squares(10).sum_of_squares())
27
+ h.assert_eq[U32](2640, Squares(10).difference())
28
28
 
29
- h.expect_eq[U32](25502500, Squares(100).square_of_sums())
30
- h.expect_eq[U32](338350, Squares(100).sum_of_squares())
31
- h.expect_eq[U32](25164150, Squares(100).difference())
29
+ h.assert_eq[U32](25502500, Squares(100).square_of_sums())
30
+ h.assert_eq[U32](338350, Squares(100).sum_of_squares())
31
+ h.assert_eq[U32](25164150, Squares(100).difference())
@@ -12,11 +12,11 @@ class Hamming
12
12
  compute_distance(strand1, strand2)
13
13
 
14
14
  fun compute_distance(strand1: String, strand2: String): U8 ? =>
15
- let size: U64 = strand1.size()
15
+ let size: USize = strand1.size()
16
16
  var dist: U8 = U8(0)
17
- var idx: I64 = 0
17
+ var idx: ISize = 0
18
18
 
19
- while idx < size.i64() do
19
+ while idx < size.isize() do
20
20
  if (strand1.at_offset(idx).ne(strand2.at_offset(idx))) then
21
21
  dist = dist + 1
22
22
  end
@@ -11,30 +11,30 @@ actor Main is TestList
11
11
  test(_HammingDistanceTest)
12
12
  test(_HammingParamTest)
13
13
 
14
- class _HammingDistanceTest iso is UnitTest
14
+ class iso _HammingDistanceTest is UnitTest
15
15
  """
16
16
  Test Hamming package returns the right distance
17
17
  """
18
18
  fun name(): String => "hamming/Hamming"
19
19
 
20
- fun apply(h: TestHelper): TestResult ? =>
21
- h.expect_eq[U8](0, Hamming("A", "A"))
22
- h.expect_eq[U8](0, Hamming("GGACTGA", "GGACTGA"))
23
- h.expect_eq[U8](1, Hamming("A", "G"))
24
- h.expect_eq[U8](2, Hamming("AG", "CT"))
25
- h.expect_eq[U8](1, Hamming("AT", "CT"))
26
- h.expect_eq[U8](1, Hamming("GGACG", "GGTCG"))
27
- h.expect_eq[U8](2, Hamming("ACCAGGG", "ACTATGG"))
28
- h.expect_eq[U8](1, Hamming("AGG", "AGA"))
29
- h.expect_eq[U8](4, Hamming("GATACA", "GCATAA"))
30
- h.expect_eq[U8](9, Hamming("GGACGGATTCTG", "AGGACGGATTCT"))
20
+ fun apply(h: TestHelper): None ? =>
21
+ h.assert_eq[U8](0, Hamming("A", "A"))
22
+ h.assert_eq[U8](0, Hamming("GGACTGA", "GGACTGA"))
23
+ h.assert_eq[U8](1, Hamming("A", "G"))
24
+ h.assert_eq[U8](2, Hamming("AG", "CT"))
25
+ h.assert_eq[U8](1, Hamming("AT", "CT"))
26
+ h.assert_eq[U8](1, Hamming("GGACG", "GGTCG"))
27
+ h.assert_eq[U8](2, Hamming("ACCAGGG", "ACTATGG"))
28
+ h.assert_eq[U8](1, Hamming("AGG", "AGA"))
29
+ h.assert_eq[U8](4, Hamming("GATACA", "GCATAA"))
30
+ h.assert_eq[U8](9, Hamming("GGACGGATTCTG", "AGGACGGATTCT"))
31
31
 
32
- class _HammingParamTest iso is UnitTest
32
+ class iso _HammingParamTest is UnitTest
33
33
  """
34
34
  Test Hamming package returns the right distance
35
35
  """
36
36
  fun name(): String => "hamming/Hamming"
37
37
 
38
- fun apply(h: TestHelper): TestResult =>
39
- h.expect_error(lambda()? => Hamming("GAT", "GA") end)
40
- h.expect_error(lambda()? => Hamming("GA", "GAC") end)
38
+ fun apply(h: TestHelper) =>
39
+ h.assert_error(lambda()? => Hamming("GAT", "GA") end)
40
+ h.assert_error(lambda()? => Hamming("GA", "GAC") end)
@@ -10,14 +10,15 @@ actor Main is TestList
10
10
  fun tag tests(test: PonyTest) =>
11
11
  test(_TestHelloWorld)
12
12
 
13
- class _TestHelloWorld iso is UnitTest
13
+ class iso _TestHelloWorld is UnitTest
14
14
  """
15
15
  Test HelloWorld package
16
16
  """
17
17
  fun name(): String => "hello-world/HelloWorld"
18
18
 
19
- fun apply(h: TestHelper): TestResult =>
19
+ fun apply(h: TestHelper) =>
20
20
  let hello: HelloWorld = HelloWorld.create()
21
21
 
22
- h.expect_eq[String]("Hello, World!", hello.say_hello())
23
- h.expect_eq[String]("Hello, Exercism!", hello.say_hello("Exercism"))
22
+ h.assert_eq[String]("Hello, World!", hello.say_hello())
23
+ h.assert_eq[String]("Hello, Exercism!", hello.say_hello("Exercism"))
24
+
@@ -10,18 +10,18 @@ actor Main is TestList
10
10
  fun tag tests(test: PonyTest) =>
11
11
  test(_LeapTest)
12
12
 
13
- class _LeapTest iso is UnitTest
13
+ class iso _LeapTest is UnitTest
14
14
  """
15
15
  Test Leap package
16
16
  """
17
17
  fun name(): String => "leap/Leap"
18
18
 
19
- fun apply(h: TestHelper): TestResult =>
20
- // Note -> Current master-branch simplifies these functions to
19
+ fun apply(h: TestHelper) =>
20
+ // Note -> Current master-branch simplifies these functions to
21
21
  // assert_true/false, and removes expect
22
22
  // https://github.com/ponylang/ponyc/blob/master/packages/ponytest/helper.pony
23
- h.expect_true(Leap(1996), "Testing a leap year")
24
- h.expect_false(Leap(1997), "Testing an odd year")
25
- h.expect_false(Leap(1998), "Testing a non-leap even year")
26
- h.expect_false(Leap(1900), "Testing a century")
27
- h.expect_true(Leap(2000), "Testing an exceptional century")
23
+ h.assert_true(Leap(1996), "Testing a leap year")
24
+ h.assert_false(Leap(1997), "Testing an odd year")
25
+ h.assert_false(Leap(1998), "Testing a non-leap even year")
26
+ h.assert_false(Leap(1900), "Testing a century")
27
+ h.assert_true(Leap(2000), "Testing an exceptional century")
@@ -411,6 +411,24 @@
411
411
  "difficulty": 1,
412
412
  "topics": [
413
413
  ]
414
+ },
415
+ {
416
+ "slug": "list-ops",
417
+ "difficulty": 1,
418
+ "topics": [
419
+ ]
420
+ },
421
+ {
422
+ "slug": "linked-list",
423
+ "difficulty": 1,
424
+ "topics": [
425
+ ]
426
+ },
427
+ {
428
+ "slug": "diamond",
429
+ "difficulty": 1,
430
+ "topics": [
431
+ ]
414
432
  }
415
433
  ],
416
434
  "deprecated": [
@@ -0,0 +1,33 @@
1
+ import unittest
2
+
3
+ from diamond import make_diamond
4
+
5
+
6
+ class DiamondTests(unittest.TestCase):
7
+
8
+ def test_letter_A(self):
9
+ self.assertMultiLineEqual('A\n', make_diamond('A'))
10
+
11
+ def test_letter_C(self):
12
+ result = [' A ',
13
+ ' B B ',
14
+ 'C C',
15
+ ' B B ',
16
+ ' A ']
17
+ self.assertMultiLineEqual('\n'.join(result) + '\n', make_diamond('C'))
18
+
19
+ def test_letter_E(self):
20
+ result = [' A ',
21
+ ' B B ',
22
+ ' C C ',
23
+ ' D D ',
24
+ 'E E',
25
+ ' D D ',
26
+ ' C C ',
27
+ ' B B ',
28
+ ' A ']
29
+ self.assertMultiLineEqual('\n'.join(result) + '\n', make_diamond('E'))
30
+
31
+
32
+ if __name__ == '__main__':
33
+ unittest.main()
@@ -0,0 +1,15 @@
1
+ def make_diamond(letter):
2
+ rows = ord(letter) - 64
3
+ cols = rows * 2 - 1
4
+ half = make_half(rows, cols)
5
+ return ''.join(half + half[-2::-1])
6
+
7
+
8
+ def make_half(rows, cols):
9
+ diamond_half = []
10
+ for x in range(rows):
11
+ row = [' '] * cols
12
+ row[rows - 1 - x] = chr(x + 65)
13
+ row[rows - 1 + x] = chr(x + 65)
14
+ diamond_half.append(''.join(row) + '\n')
15
+ return diamond_half
@@ -0,0 +1,47 @@
1
+ class Node(object):
2
+ def __init__(self, value, next=None, prev=None):
3
+ self.value = value
4
+ self.next = next
5
+ self.prev = prev
6
+
7
+
8
+ class LinkedList(object):
9
+ def __init__(self):
10
+ self.head = None
11
+ self.tail = None
12
+
13
+ def push(self, value):
14
+ new_node = Node(value)
15
+ if not self.head:
16
+ self.head = self.tail = new_node
17
+ else:
18
+ new_node.prev = self.tail
19
+ self.tail.next = new_node
20
+ self.tail = new_node
21
+
22
+ def pop(self):
23
+ node = self.tail
24
+ if node is None or node.prev is None:
25
+ self.head = self.tail = None
26
+ else:
27
+ self.tail = self.tail.prev
28
+ self.tail.next = None
29
+ return node.value
30
+
31
+ def shift(self):
32
+ node = self.head
33
+ if node is None or node.next is None:
34
+ self.head = self.tail = None
35
+ else:
36
+ self.head = self.head.next
37
+ self.head.prev = None
38
+ return node.value
39
+
40
+ def unshift(self, value):
41
+ new_node = Node(value)
42
+ if not self.head:
43
+ self.head = self.tail = new_node
44
+ else:
45
+ new_node.next = self.head
46
+ self.head.prev = new_node
47
+ self.head = new_node
@@ -0,0 +1,13 @@
1
+ # Skeleton file for the Python "linked-list" exercise.
2
+
3
+
4
+ class Node(object):
5
+ def __init__(self, value, next=None, prev=None):
6
+ self.value = value
7
+ self.next = next
8
+ self.prev = prev
9
+
10
+
11
+ class LinkedList(object):
12
+ def __init__(self):
13
+ pass # Complete the Deque class ...
@@ -0,0 +1,49 @@
1
+ import unittest
2
+
3
+ from linked_list import LinkedList
4
+
5
+
6
+ class LinkedListTests(unittest.TestCase):
7
+
8
+ def setUp(self):
9
+ self.list = LinkedList()
10
+
11
+ def test_push_pop(self):
12
+ self.list.push(10)
13
+ self.list.push(20)
14
+ self.assertEqual(20, self.list.pop())
15
+ self.assertEqual(10, self.list.pop())
16
+
17
+ def test_push_shift(self):
18
+ self.list.push(10)
19
+ self.list.push(20)
20
+ self.assertEqual(10, self.list.shift())
21
+ self.assertEqual(20, self.list.shift())
22
+
23
+ def test_unshift_shift(self):
24
+ self.list.unshift(10)
25
+ self.list.unshift(20)
26
+ self.assertEqual(20, self.list.shift())
27
+ self.assertEqual(10, self.list.shift())
28
+
29
+ def test_unshift_pop(self):
30
+ self.list.unshift(10)
31
+ self.list.unshift(20)
32
+ self.assertEqual(10, self.list.pop())
33
+ self.assertEqual(20, self.list.pop())
34
+
35
+ def test_all(self):
36
+ self.list.push(10)
37
+ self.list.push(20)
38
+ self.assertEqual(20, self.list.pop())
39
+ self.list.push(30)
40
+ self.assertEqual(10, self.list.shift())
41
+ self.list.unshift(40)
42
+ self.list.push(50)
43
+ self.assertEqual(40, self.list.shift())
44
+ self.assertEqual(50, self.list.pop())
45
+ self.assertEqual(30, self.list.shift())
46
+
47
+
48
+ if __name__ == '__main__':
49
+ unittest.main()
@@ -0,0 +1,55 @@
1
+ def map_clone(function, xs):
2
+ return (function(elem) for elem in xs)
3
+
4
+
5
+ def length(xs):
6
+ return sum(1 for x in xs)
7
+
8
+
9
+ def filter_clone(function, xs):
10
+ return (x for x in xs if function(x))
11
+
12
+
13
+ def reverse(xs):
14
+ if not xs:
15
+ return []
16
+ else:
17
+ return xs[::-1]
18
+
19
+
20
+ def append(xs, y):
21
+ xs[len(xs):] = [y]
22
+ return xs
23
+
24
+
25
+ def foldl(function, xs, acc):
26
+ if(len(xs) == 0):
27
+ return acc
28
+ else:
29
+ return foldl(function, xs[1:], function(acc, xs[0]))
30
+
31
+
32
+ def foldr(function, xs, acc):
33
+ if(len(xs) == 0):
34
+ return acc
35
+ else:
36
+ return function(xs[0], foldr(function, xs[1:], acc))
37
+
38
+
39
+ def flat(xs):
40
+ out = []
41
+ for item in xs:
42
+ if isinstance(item, (list, tuple)):
43
+ out.extend(flat(item))
44
+ else:
45
+ out.append(item)
46
+ return out
47
+
48
+
49
+ def concat(xs, ys):
50
+ if not ys:
51
+ return xs
52
+ else:
53
+ for item in ys:
54
+ xs.append(item)
55
+ return xs
@@ -0,0 +1,38 @@
1
+ # Please, do not use the built-in python functions like map, reduce, len, etc.
2
+ # that solve the same problems and try to solve it yourself instead.
3
+
4
+
5
+ def map_clone(function, xs):
6
+ return xs
7
+
8
+
9
+ def length(xs):
10
+ return xs
11
+
12
+
13
+ def filter_clone(function, xs):
14
+ return xs
15
+
16
+
17
+ def reverse(xs):
18
+ return xs
19
+
20
+
21
+ def append(xs, y):
22
+ return xs
23
+
24
+
25
+ def foldl(function, xs, acc):
26
+ return xs
27
+
28
+
29
+ def foldr(function, xs, acc):
30
+ return xs
31
+
32
+
33
+ def flat(xs):
34
+ return xs
35
+
36
+
37
+ def concat(xs, ys):
38
+ return xs
@@ -0,0 +1,136 @@
1
+ import unittest
2
+ import operator
3
+
4
+ import list_ops
5
+
6
+
7
+ class ListOpsTest(unittest.TestCase):
8
+
9
+ # tests for map
10
+ def test_map_square(self):
11
+ self.assertEqual(
12
+ (1, 4, 9, 16, 25, 36, 49, 64, 81, 100),
13
+ tuple(list_ops.map_clone(
14
+ lambda x: x**2, (1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
15
+ )
16
+ )
17
+
18
+ def test_map_cube(self):
19
+ self.assertEqual(
20
+ (-1, 8, -27, 64, -125, 216, -343, 512, -729, 1000),
21
+ tuple(list_ops.map_clone(
22
+ lambda x: x**3, (-1, 2, -3, 4, -5, 6, -7, 8, -9, 10))
23
+ )
24
+ )
25
+
26
+ def test_map_absolute(self):
27
+ self.assertEqual(
28
+ (1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
29
+ tuple(list_ops.map_clone(
30
+ lambda x: abs(x), (-1, 2, -3, 4, -5, 6, -7, 8, -9, 10))
31
+ )
32
+ )
33
+
34
+ def test_map_empty(self):
35
+ self.assertEqual([], list(list_ops.map_clone(operator.index, [])))
36
+
37
+ # tests for length
38
+ def test_pos_leng(self):
39
+ self.assertEqual(10, list_ops.length((-1, 2, -3, 4, -5, 6, -7, 8, -9, 10)))
40
+
41
+ def test_empty_len(self):
42
+ self.assertEqual(0, list_ops.length([]))
43
+
44
+ # tests for filter
45
+ def test_filter_odd(self):
46
+ self.assertEqual(
47
+ (1, 3, 5),
48
+ tuple(list_ops.filter_clone(lambda x: x % 2 != 0, [1, 2, 3, 4, 5, 6]))
49
+ )
50
+
51
+ def test_filter_even(self):
52
+ self.assertEqual(
53
+ (2, 4, 6),
54
+ tuple(list_ops.filter_clone(lambda x: x % 2 == 0, [1, 2, 3, 4, 5, 6]))
55
+ )
56
+
57
+ # tests for reverse
58
+ def test_reverse_small(self):
59
+ self.assertEqual([1, 2, 3], list_ops.reverse([3, 2, 1]))
60
+
61
+ def test_reverse_mixed_types(self):
62
+ self.assertEqual(
63
+ (1, "cat", 4.0, "xyz"),
64
+ list_ops.reverse(("xyz", 4.0, "cat", 1))
65
+ )
66
+
67
+ def test_reverse_empty(self):
68
+ self.assertEqual([], list_ops.reverse(()))
69
+
70
+ # tests for append
71
+ def test_append_tuple(self):
72
+ self.assertEqual(
73
+ ["10", "python", "hello"],
74
+ list_ops.append(["10", "python"], "hello")
75
+ )
76
+
77
+ def test_append_range(self):
78
+ self.assertEqual([100, range(1000)], list_ops.append([100], range(1000)))
79
+
80
+ def test_append_to_empty(self):
81
+ self.assertEqual([42], list_ops.append([], 42))
82
+
83
+ # tests for foldl
84
+ def test_foldl_sum(self):
85
+ self.assertEqual(21, list_ops.foldl(operator.add, [1, 2, 3, 4, 5, 6], 0))
86
+
87
+ def test_foldl_product(self):
88
+ self.assertEqual(720, list_ops.foldl(operator.mul, [1, 2, 3, 4, 5, 6], 1))
89
+
90
+ def test_foldl_div(self):
91
+ self.assertEqual(0, list_ops.foldl(operator.floordiv, [1, 2, 3, 4, 5, 6], 1))
92
+
93
+ def test_foldl_sub(self):
94
+ self.assertEqual(-15, list_ops.foldl(operator.sub, [1, 2, 3, 4, 5], 0))
95
+
96
+ # tests for foldr
97
+ def test_foldr_sub(self):
98
+ self.assertEqual(3, list_ops.foldr(operator.sub, [1, 2, 3, 4, 5], 0))
99
+
100
+ def test_foldr_add_str(self):
101
+ self.assertEqual(
102
+ "exercism!",
103
+ list_ops.foldr(operator.add, ["e", "x", "e", "r", "c", "i", "s", "m"], "!"))
104
+
105
+ # tests for flatten
106
+ def test_flatten_nested(self):
107
+ self.assertEqual([1, 2, 3, 4], list_ops.flat([[[1, 2], [3]], [[4]]]))
108
+
109
+ def test_flatten_once(self):
110
+ self.assertEqual(["x", "y", "z"], list_ops.flat([["x", "y", "z"]]))
111
+
112
+ def test_flatten_empty(self):
113
+ self.assertEqual([], list_ops.flat([]))
114
+
115
+ # tests for concat
116
+ def test_concat_two(self):
117
+ self.assertEqual(
118
+ [1, 3, 5, 8, 9, 4, 5, 6],
119
+ list_ops.concat([1, 3, 5, 8], [9, 4, 5, 6])
120
+ )
121
+
122
+ def test_concat_nothing(self):
123
+ self.assertEqual(
124
+ ["orange", "apple", "banana"],
125
+ list_ops.concat(['orange', 'apple', 'banana'], None)
126
+ )
127
+
128
+ def test_concat_empty(self):
129
+ self.assertEqual(
130
+ [],
131
+ list_ops.concat([], [])
132
+ )
133
+
134
+
135
+ if __name__ == '__main__':
136
+ unittest.main()
@@ -1,10 +1,29 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require_relative '../lib/helper'
4
+ require 'generator'
5
+
6
+ def available_generators
7
+ cases = File.join( __dir__, '../lib/*_cases.rb')
8
+ Dir[cases].map {|filename| /([^\/]*)_cases\.rb$/.match(filename).captures}
9
+ end
10
+
11
+ def usage
12
+ "Usage: #{$PROGRAM_NAME} exercise_generator\n\n" +
13
+ "Available exercise generators:\n" +
14
+ available_generators.sort.join(' ')
15
+ end
16
+
3
17
  exercise = ARGV[0]
18
+
19
+ unless exercise
20
+ STDERR.puts "Exercise name required!\n"
21
+ puts usage
22
+ exit
23
+ end
24
+
4
25
  cases = "#{exercise.tr('-','_')}_cases"
5
26
 
6
- require_relative '../lib/helper'
7
- require 'generator'
8
27
  begin
9
28
  require "#{cases}"
10
29
  rescue LoadError
@@ -14,3 +33,4 @@ end
14
33
 
15
34
  klass = Object.const_get(cases.split('_').map(&:capitalize).join)
16
35
  Generator.new(exercise, klass).generate
36
+