trackler 2.0.0.1 → 2.0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. checksums.yaml +4 -4
  2. data/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
@@ -6,10 +6,6 @@ require_relative 'largest_series_product'
6
6
  # Test data version:
7
7
  # deb225e Implement canonical dataset for scrabble-score problem (#255)
8
8
 
9
- # Rubocop directives
10
- # rubocop:disable Style/NumericLiterals
11
- # rubocop:disable Metrics/LineLength
12
- #
13
9
  class Seriestest < Minitest::Test
14
10
  def test_can_find_the_largest_product_of_2_with_numbers_in_order
15
11
  assert_equal 72, Series.new('0123456789').largest_product(2)
@@ -39,7 +39,7 @@ class DequeTest < Minitest::Test
39
39
  assert_equal 20, deque.pop
40
40
  end
41
41
 
42
- def test_example # rubocop:disable Metrics/MethodLength
42
+ def test_example
43
43
  skip
44
44
  deque = Deque.new
45
45
  deque.push(10)
@@ -8,7 +8,6 @@ require_relative 'meetup'
8
8
  # and a method day(weekday, schedule)
9
9
  # where weekday is one of :monday, :tuesday, etc
10
10
  # and schedule is :first, :second, :third, :fourth, :last or :teenth.
11
- # rubocop:disable Style/AlignParameters
12
11
  class MeetupTest < Minitest::Test
13
12
  def test_monteenth_of_may_2013
14
13
  assert_equal Date.new(2013, 5, 13),
@@ -5,8 +5,6 @@ require_relative 'nth_prime'
5
5
 
6
6
  # Test data version:
7
7
  # <%= sha1 %>
8
- # Rubocop directives
9
- # rubocop:disable Style/NumericLiterals
10
8
  #
11
9
  class NthPrimeTest < Minitest::Test<% test_cases.each do |test_case| %>
12
10
  def <%= test_case.name %><% if test_case.skipped? %>
@@ -5,8 +5,6 @@ require_relative 'nth_prime'
5
5
 
6
6
  # Test data version:
7
7
  # bb79e10
8
- # Rubocop directives
9
- # rubocop:disable Style/NumericLiterals
10
8
  #
11
9
  class NthPrimeTest < Minitest::Test
12
10
  def test_first_prime
@@ -4,7 +4,6 @@ require 'minitest/autorun'
4
4
  require_relative 'ocr_numbers'
5
5
 
6
6
  class OCRTest < Minitest::Test
7
- # rubocop:disable Style/TrailingWhitespace
8
7
  def test_recognize_zero
9
8
  text = <<-NUMBER.chomp
10
9
  _
@@ -169,7 +168,7 @@ class OCRTest < Minitest::Test
169
168
  assert_equal '1234567890', OCR.new(text).convert
170
169
  end
171
170
 
172
- def test_identify_123_456_789 # rubocop:disable Metrics/MethodLength
171
+ def test_identify_123_456_789
173
172
  skip
174
173
  text = <<-NUMBER.chomp
175
174
  _ _
@@ -3,7 +3,6 @@ gem 'minitest', '>= 5.0.0'
3
3
  require 'minitest/autorun'
4
4
  require_relative 'protein_translation'
5
5
 
6
- # rubocop:disable Style/MethodName
7
6
  class TranslationTest < Minitest::Test
8
7
  def test_AUG_translates_to_methionine
9
8
  assert_equal 'Methionine', Translation.of_codon('AUG')
@@ -38,7 +38,7 @@ class ProverbTest < Minitest::Test
38
38
  assert_equal expected, proverb.to_s
39
39
  end
40
40
 
41
- def test_the_whole_proverb # rubocop:disable Metrics/MethodLength
41
+ def test_the_whole_proverb
42
42
  skip
43
43
  chain = %w(nail shoe horse rider message battle kingdom)
44
44
  proverb = Proverb.new(*chain)
@@ -52,7 +52,6 @@ class ProverbTest < Minitest::Test
52
52
  assert_equal expected, proverb.to_s
53
53
  end
54
54
 
55
- # rubocop:disable Metrics/MethodLength
56
55
  def test_an_optional_qualifier_in_the_final_consequence
57
56
  skip
58
57
  chain = %w(nail shoe horse rider message battle kingdom)
@@ -66,7 +65,6 @@ class ProverbTest < Minitest::Test
66
65
  'And all for the want of a horseshoe nail.'
67
66
  assert_equal expected, proverb.to_s
68
67
  end
69
- # rubocop:enable Metrics/MethodLength
70
68
 
71
69
  def test_proverb_is_same_each_time
72
70
  skip
@@ -3,7 +3,9 @@ class Queens
3
3
  def initialize(positions = {})
4
4
  @white = positions.fetch(:white) { [0, 3] }
5
5
  @black = positions.fetch(:black) { [7, 3] }
6
- fail ArgumentError if white == black
6
+ fail ArgumentError, "Queens cannot be placed on the same spot" if white == black
7
+ fail ArgumentError, "Positions must be positive numbers" if (white + black).any? { |p| p < 0 }
8
+ fail ArgumentError, "Positions must have square on board" if (white + black).any? { |p| p > 7 }
7
9
  end
8
10
 
9
11
  def attack?
@@ -34,7 +34,35 @@ class QueensTest < Minitest::Test
34
34
  end
35
35
  end
36
36
 
37
- def test_string_representation # rubocop:disable Metrics/MethodLength
37
+ def test_queen_must_have_positive_row
38
+ skip
39
+ assert_raises ArgumentError do
40
+ Queens.new(white: [-2, 2])
41
+ end
42
+ end
43
+
44
+ def test_queen_must_have_positive_column
45
+ skip
46
+ assert_raises ArgumentError do
47
+ Queens.new(white: [2, -2])
48
+ end
49
+ end
50
+
51
+ def test_queen_must_have_row_on_board
52
+ skip
53
+ assert_raises ArgumentError do
54
+ Queens.new(white: [8, 4])
55
+ end
56
+ end
57
+
58
+ def test_queen_must_have_column_on_board
59
+ skip
60
+ assert_raises ArgumentError do
61
+ Queens.new(white: [4, 8])
62
+ end
63
+ end
64
+
65
+ def test_string_representation
38
66
  skip
39
67
  queens = Queens.new(white: [2, 4], black: [6, 6])
40
68
  board = <<-BOARD.chomp
@@ -50,7 +78,7 @@ _ _ _ _ _ _ _ _
50
78
  assert_equal board, queens.to_s
51
79
  end
52
80
 
53
- def test_another_string_representation # rubocop:disable Metrics/MethodLength
81
+ def test_another_string_representation
54
82
  skip
55
83
  queens = Queens.new(white: [7, 1], black: [0, 0])
56
84
  board = <<-BOARD.chomp
@@ -66,7 +94,6 @@ _ W _ _ _ _ _ _
66
94
  assert_equal board, queens.to_s
67
95
  end
68
96
 
69
- # rubocop:disable Metrics/MethodLength
70
97
  def test_yet_another_string_representation
71
98
  skip
72
99
  queens = Queens.new(white: [4, 3], black: [3, 4])
@@ -88,7 +115,6 @@ _ _ _ _ _ _ _ _
88
115
  queens = Queens.new(white: [2, 3], black: [4, 7])
89
116
  assert !queens.attack?
90
117
  end
91
- # rubocop:enable Metrics/MethodLength
92
118
 
93
119
  def test_can_attack_on_same_row
94
120
  skip
@@ -102,25 +128,25 @@ _ _ _ _ _ _ _ _
102
128
  assert queens.attack?
103
129
  end
104
130
 
105
- def test_can_attack_on_diagonal
131
+ def test_can_attack_on_first_diagonal
106
132
  skip
107
133
  queens = Queens.new(white: [1, 1], black: [6, 6])
108
134
  assert queens.attack?
109
135
  end
110
136
 
111
- def test_can_attack_on_other_diagonal
137
+ def test_can_attack_on_second_diagonal
112
138
  skip
113
139
  queens = Queens.new(white: [0, 6], black: [1, 7])
114
140
  assert queens.attack?
115
141
  end
116
142
 
117
- def test_can_attack_on_yet_another_diagonal
143
+ def test_can_attack_on_third_diagonal
118
144
  skip
119
145
  queens = Queens.new(white: [4, 1], black: [6, 3])
120
146
  assert queens.attack?
121
147
  end
122
148
 
123
- def test_can_attack_on_a_diagonal_slanted_the_other_way
149
+ def test_can_attack_on_fourth_diagonal
124
150
  skip
125
151
  queens = Queens.new(white: [6, 1], black: [1, 6])
126
152
  assert queens.attack?
@@ -160,7 +160,7 @@ class RobotSimulatorTest < Minitest::Test
160
160
  assert_equal :west, robot.bearing
161
161
  end
162
162
 
163
- def test_instruct_many_robots # rubocop:disable Metrics/MethodLength
163
+ def test_instruct_many_robots
164
164
  skip
165
165
  robot1 = Robot.new
166
166
  robot2 = Robot.new
@@ -30,7 +30,7 @@ class ArrayTest < Minitest::Test
30
30
  assert_equal %w(zebra zombies zelot), result
31
31
  end
32
32
 
33
- def test_keep_arrays # rubocop:disable Metrics/MethodLength
33
+ def test_keep_arrays
34
34
  skip
35
35
  rows = [
36
36
  [1, 2, 3],
@@ -72,7 +72,7 @@ class ArrayTest < Minitest::Test
72
72
  assert_equal %w(apple banana cherimoya), result
73
73
  end
74
74
 
75
- def test_discard_arrays # rubocop:disable Metrics/MethodLength
75
+ def test_discard_arrays
76
76
  skip
77
77
  rows = [
78
78
  [1, 2, 3],
@@ -0,0 +1,54 @@
1
+ module BookKeeping
2
+ VERSION = 1
3
+ end
4
+
5
+ class Tournament
6
+ def self.tally(input)
7
+ teams = Hash.new { |h, k| h[k] = Hash.new { |h, k| h[k] = 0 } }
8
+
9
+ input.split("\n").each do |line|
10
+ team_one, team_two, result = line.split(';')
11
+
12
+ case result
13
+ when "win"
14
+ teams[team_one][:won] += 1
15
+ teams[team_two][:loss] += 1
16
+ when "loss"
17
+ teams[team_one][:loss] += 1
18
+ teams[team_two][:won] += 1
19
+ when "draw"
20
+ teams[team_one][:draw] += 1
21
+ teams[team_two][:draw] += 1
22
+ end
23
+ end
24
+
25
+ teams.keys.each do |team_name|
26
+ team = teams[team_name]
27
+ team[:matches] = team[:won] + team[:loss] + team[:draw]
28
+ team[:points] = team[:won] * 3 + team[:draw]
29
+ end
30
+
31
+ team_order =
32
+ teams
33
+ .to_a
34
+ .sort_by { |team| [-team[1][:points], team[0]] }
35
+ .map(&:first)
36
+
37
+ result = ['Team | MP | W | D | L | P']
38
+
39
+ team_order.each do |team_name|
40
+ stats = teams[team_name]
41
+
42
+ result << [
43
+ team_name.ljust(30),
44
+ stats[:matches],
45
+ stats[:won],
46
+ stats[:draw],
47
+ stats[:loss],
48
+ stats[:points]
49
+ ].join(' | ')
50
+ end
51
+
52
+ result.join("\n") + "\n"
53
+ end
54
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ gem 'minitest', '>= 5.0.0'
3
+ require 'minitest/autorun'
4
+ require_relative 'tournament'
5
+
6
+ # Test data version:
7
+ # <%= sha1 %>
8
+ class TournamentTest < Minitest::Test
9
+ <% test_cases.each do |test_case| %>
10
+ def <%= test_case.test_name %>
11
+ <%= test_case.skipped %>
12
+ input = <%= test_case.input_text %>
13
+ actual = <%= test_case.workload %>
14
+ expected = <%= test_case.expect %>
15
+ assert_equal expected, actual
16
+ end
17
+ <% end %>
18
+ <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
19
+ def test_bookkeeping
20
+ skip
21
+ assert_equal <%= version.next %>, BookKeeping::VERSION
22
+ end
23
+ end
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+ gem 'minitest', '>= 5.0.0'
3
+ require 'minitest/autorun'
4
+ require_relative 'tournament'
5
+
6
+ # Test data version:
7
+ # 0a51cfc
8
+ class TournamentTest < Minitest::Test
9
+
10
+ def test_typical_input
11
+ # skip
12
+ input = <<-INPUT.gsub(/^ */, '')
13
+ Allegoric Alaskans;Blithering Badgers;win
14
+ Devastating Donkeys;Courageous Californians;draw
15
+ Devastating Donkeys;Allegoric Alaskans;win
16
+ Courageous Californians;Blithering Badgers;loss
17
+ Blithering Badgers;Devastating Donkeys;loss
18
+ Allegoric Alaskans;Courageous Californians;win
19
+ INPUT
20
+ actual = Tournament.tally(input)
21
+ expected = <<-TALLY.gsub(/^ */, '')
22
+ Team | MP | W | D | L | P
23
+ Devastating Donkeys | 3 | 2 | 1 | 0 | 7
24
+ Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
25
+ Blithering Badgers | 3 | 1 | 0 | 2 | 3
26
+ Courageous Californians | 3 | 0 | 1 | 2 | 1
27
+ TALLY
28
+ assert_equal expected, actual
29
+ end
30
+
31
+ def test_incomplete_competition_not_all_pairs_have_played
32
+ skip
33
+ input = <<-INPUT.gsub(/^ */, '')
34
+ Allegoric Alaskans;Blithering Badgers;loss
35
+ Devastating Donkeys;Allegoric Alaskans;loss
36
+ Courageous Californians;Blithering Badgers;draw
37
+ Allegoric Alaskans;Courageous Californians;win
38
+ INPUT
39
+ actual = Tournament.tally(input)
40
+ expected = <<-TALLY.gsub(/^ */, '')
41
+ Team | MP | W | D | L | P
42
+ Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
43
+ Blithering Badgers | 2 | 1 | 1 | 0 | 4
44
+ Courageous Californians | 2 | 0 | 1 | 1 | 1
45
+ Devastating Donkeys | 1 | 0 | 0 | 1 | 0
46
+ TALLY
47
+ assert_equal expected, actual
48
+ end
49
+
50
+ def test_ties_broken_alphabetically
51
+ skip
52
+ input = <<-INPUT.gsub(/^ */, '')
53
+ Courageous Californians;Devastating Donkeys;win
54
+ Allegoric Alaskans;Blithering Badgers;win
55
+ Devastating Donkeys;Allegoric Alaskans;loss
56
+ Courageous Californians;Blithering Badgers;win
57
+ Blithering Badgers;Devastating Donkeys;draw
58
+ Allegoric Alaskans;Courageous Californians;draw
59
+ INPUT
60
+ actual = Tournament.tally(input)
61
+ expected = <<-TALLY.gsub(/^ */, '')
62
+ Team | MP | W | D | L | P
63
+ Allegoric Alaskans | 3 | 2 | 1 | 0 | 7
64
+ Courageous Californians | 3 | 2 | 1 | 0 | 7
65
+ Blithering Badgers | 3 | 0 | 1 | 2 | 1
66
+ Devastating Donkeys | 3 | 0 | 1 | 2 | 1
67
+ TALLY
68
+ assert_equal expected, actual
69
+ end
70
+
71
+ # Problems in exercism evolve over time, as we find better ways to ask
72
+ # questions.
73
+ # The version number refers to the version of the problem you solved,
74
+ # not your solution.
75
+ #
76
+ # Define a constant named VERSION inside of the top level BookKeeping
77
+ # module, which may be placed near the end of your file.
78
+ #
79
+ # In your file, it will look like this:
80
+ #
81
+ # module BookKeeping
82
+ # VERSION = 1 # Where the version number matches the one in the test.
83
+ # end
84
+ #
85
+ # If you are curious, read more about constants on RubyDoc:
86
+ # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
87
+
88
+ def test_bookkeeping
89
+ skip
90
+ assert_equal 1, BookKeeping::VERSION
91
+ end
92
+ end
@@ -0,0 +1 @@
1
+ 1
@@ -0,0 +1,14 @@
1
+ module BookKeeping
2
+ VERSION = 1
3
+ end
4
+
5
+ class Transpose
6
+ def self.transpose(input)
7
+ lines = input.split("\n")
8
+ max_line_length = lines.map(&:length).max
9
+
10
+ lines
11
+ .map { |line| line.ljust(max_line_length).chars }
12
+ .transpose.map(&:join).join("\n").strip
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ gem 'minitest', '>= 5.0.0'
3
+ require 'minitest/autorun'
4
+ require_relative 'transpose'
5
+
6
+ # Test data version:
7
+ # <%= sha1 %>
8
+ class TransposeTest < Minitest::Test<% test_cases.each do |test_case| %>
9
+ def <%= test_case.test_name %>
10
+ <%= test_case.skipped %>
11
+ input = <%= test_case.input_text %>
12
+ actual = <%= test_case.workload %>
13
+ expected = <%= test_case.expect %>
14
+ assert_equal expected.strip, actual
15
+ end
16
+ <% end %>
17
+ <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
18
+ def test_bookkeeping
19
+ skip
20
+ assert_equal <%= version.next %>, BookKeeping::VERSION
21
+ end
22
+ end