trackler 1.0.4.0 → 1.0.4.1
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.
- checksums.yaml +4 -4
- data/common/CONTRIBUTING.md +17 -2
- data/common/exercises/anagram/canonical-data.json +0 -14
- data/common/exercises/pig-latin/canonical-data.json +6 -1
- data/common/exercises/raindrops/description.md +4 -4
- data/common/exercises/raindrops/metadata.yml +1 -1
- data/common/exercises/roman-numerals/metadata.yml +1 -1
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/config.json +12 -1
- data/tracks/c/exercises/roman-numerals/makefile +16 -0
- data/tracks/c/exercises/roman-numerals/src/example.c +43 -0
- data/tracks/c/exercises/roman-numerals/src/example.h +6 -0
- data/tracks/c/exercises/roman-numerals/test/test_roman_numerals.c +126 -0
- data/tracks/c/exercises/roman-numerals/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/roman-numerals/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/roman-numerals/test/vendor/unity_internals.h +701 -0
- data/tracks/clojure/exercises/flatten-array/project.clj +4 -0
- data/tracks/csharp/exercises/protein-translation/ProteinTranslationTest.cs +1 -1
- data/tracks/elixir/exercises/bowling/bowling_test.exs +157 -62
- data/tracks/elixir/exercises/bowling/example.exs +33 -4
- data/tracks/erlang/config.json +176 -36
- data/tracks/go/.travis.yml +7 -1
- data/tracks/go/bin/test-without-stubs +29 -0
- data/tracks/go/exercises/robot-simulator/defs.go +1 -1
- data/tracks/go/exercises/variable-length-quantity/variable_length_quantity_test.go +31 -25
- data/tracks/haskell/.travis.yml +9 -5
- data/tracks/haskell/config.json +127 -121
- data/tracks/haskell/exercises/leap/src/LeapYear.hs +1 -1
- data/tracks/haskell/exercises/space-age/HINTS.md +14 -2
- data/tracks/haskell/exercises/space-age/{src/Example.hs → examples/success-double/SpaceAge.hs} +0 -0
- data/tracks/haskell/exercises/space-age/examples/success-double/package.yaml +19 -0
- data/tracks/haskell/exercises/space-age/examples/success-rational/SpaceAge.hs +24 -0
- data/tracks/haskell/exercises/space-age/examples/success-rational/package.yaml +19 -0
- data/tracks/haskell/exercises/space-age/src/SpaceAge.hs +4 -1
- data/tracks/haskell/exercises/space-age/test/Tests.hs +12 -5
- data/tracks/haskell/exercises/word-count/HINTS.md +21 -0
- data/tracks/haskell/exercises/word-count/examples/success-newtype/WordCount.hs +31 -0
- data/tracks/haskell/exercises/word-count/examples/success-newtype/package.yaml +21 -0
- data/tracks/haskell/exercises/word-count/examples/success-simple/WordCount.hs +13 -0
- data/tracks/haskell/exercises/word-count/examples/success-simple/package.yaml +20 -0
- data/tracks/haskell/exercises/word-count/package.yaml +0 -2
- data/tracks/haskell/exercises/word-count/src/WordCount.hs +2 -1
- data/tracks/haskell/exercises/word-count/test/Tests.hs +15 -6
- data/tracks/haskell/exercises/zebra-puzzle/package.yaml +19 -0
- data/tracks/haskell/exercises/zebra-puzzle/src/Example.hs +113 -0
- data/tracks/haskell/exercises/zebra-puzzle/src/ZebraPuzzle.hs +12 -0
- data/tracks/haskell/exercises/zebra-puzzle/stack.yaml +1 -0
- data/tracks/haskell/exercises/zebra-puzzle/test/Tests.hs +13 -0
- data/tracks/javascript/exercises/beer-song/beer-song.spec.js +5 -0
- data/tracks/lisp/config.json +147 -0
- data/tracks/ocaml/config.json +12 -0
- data/tracks/ocaml/exercises/atbash-cipher/.merlin +5 -0
- data/tracks/ocaml/exercises/atbash-cipher/HINTS.md +17 -0
- data/tracks/ocaml/exercises/atbash-cipher/Makefile +11 -0
- data/tracks/ocaml/exercises/atbash-cipher/atbash_cipher.mli +5 -0
- data/tracks/ocaml/exercises/atbash-cipher/example.ml +47 -0
- data/tracks/ocaml/exercises/atbash-cipher/test.ml +37 -0
- data/tracks/ocaml/exercises/meetup/.merlin +5 -0
- data/tracks/ocaml/exercises/meetup/Makefile +11 -0
- data/tracks/ocaml/exercises/meetup/example.ml +63 -0
- data/tracks/ocaml/exercises/meetup/meetup.mli +7 -0
- data/tracks/ocaml/exercises/meetup/test.ml +786 -0
- data/tracks/php/exercises/bowling/bowling_test.php +233 -10
- data/tracks/php/exercises/bowling/example.php +49 -6
- data/tracks/python/.travis.yml +5 -0
- data/tracks/python/config.json +33 -1
- data/tracks/python/exercises/flatten-array/example.py +18 -0
- data/tracks/python/exercises/flatten-array/flatten_array_test.py +40 -0
- data/tracks/python/exercises/robot-name/robot_name_test.py +8 -2
- data/tracks/r/config.json +32 -8
- data/tracks/ruby/bin/enable-executable +9 -5
- data/tracks/ruby/bin/executable-tests-check +7 -3
- data/tracks/ruby/bin/local-status-check +4 -4
- data/tracks/ruby/config.json +8 -1
- data/tracks/ruby/exercises/acronym/acronym_test.rb +0 -1
- data/tracks/ruby/exercises/anagram/.version +1 -0
- data/tracks/ruby/exercises/anagram/anagram_test.rb +101 -31
- data/tracks/ruby/exercises/anagram/example.rb +4 -0
- data/tracks/ruby/exercises/anagram/example.tt +19 -0
- data/tracks/ruby/exercises/gigasecond/.version +1 -1
- data/tracks/ruby/exercises/gigasecond/example.rb +1 -1
- data/tracks/ruby/exercises/gigasecond/gigasecond_test.rb +2 -2
- data/tracks/ruby/exercises/isogram/.version +1 -0
- data/tracks/ruby/exercises/isogram/example.rb +10 -0
- data/tracks/ruby/exercises/isogram/example.tt +20 -0
- data/tracks/ruby/exercises/isogram/isogram_test.rb +90 -0
- data/tracks/ruby/exercises/poker/example.rb +97 -39
- data/tracks/ruby/exercises/poker/poker_test.rb +67 -36
- data/tracks/ruby/exercises/sieve/.version +1 -0
- data/tracks/ruby/exercises/sieve/example.rb +4 -0
- data/tracks/ruby/exercises/sieve/example.tt +21 -0
- data/tracks/ruby/exercises/sieve/sieve_test.rb +36 -13
- data/tracks/ruby/exercises/word-count/example.tt +4 -3
- data/tracks/ruby/exercises/word-count/word_count_test.rb +38 -48
- data/tracks/ruby/lib/anagram_cases.rb +42 -0
- data/tracks/ruby/lib/isogram_cases.rb +24 -0
- data/tracks/ruby/lib/sieve_cases.rb +33 -0
- data/tracks/ruby/lib/word_count_cases.rb +19 -0
- data/tracks/scala/config.json +21 -0
- data/tracks/scala/docs/RESOURCES.md +1 -0
- data/tracks/scala/exercises/bracket-push/build.sbt +4 -0
- data/tracks/scala/exercises/bracket-push/example.scala +23 -0
- data/tracks/scala/exercises/bracket-push/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/bracket-push/src/test/scala/BracketsTest.scala +68 -0
- data/tracks/scala/exercises/change/src/test/scala/ChangeTest.scala +7 -0
- data/tracks/scala/exercises/sgf-parsing/build.sbt +7 -0
- data/tracks/scala/exercises/sgf-parsing/example.scala +66 -0
- data/tracks/scala/exercises/sgf-parsing/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/sgf-parsing/src/main/scala/Sgf.scala +17 -0
- data/tracks/scala/exercises/sgf-parsing/src/test/scala/SgfTest.scala +66 -0
- data/tracks/scala/exercises/zebra-puzzle/build.sbt +3 -0
- data/tracks/scala/exercises/zebra-puzzle/example.scala +152 -0
- data/tracks/scala/exercises/zebra-puzzle/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/zebra-puzzle/src/main/scala/ZebraPuzzle.scala +14 -0
- data/tracks/scala/exercises/zebra-puzzle/src/test/scala/ZebraPuzzleTest.scala +11 -0
- data/tracks/scala/testgen/src/main/scala/BracketPushTestGenerator.scala +44 -0
- metadata +63 -3
- data/tracks/haskell/exercises/word-count/src/Example.hs +0 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'minitest/autorun'
|
|
2
2
|
require_relative 'gigasecond'
|
|
3
3
|
|
|
4
|
-
# Test data version:
|
|
4
|
+
# Test data version: 9049dc7
|
|
5
5
|
|
|
6
6
|
class GigasecondTest < Minitest::Test
|
|
7
7
|
def test_2011_04_25
|
|
@@ -56,6 +56,6 @@ class GigasecondTest < Minitest::Test
|
|
|
56
56
|
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
|
|
57
57
|
|
|
58
58
|
def test_bookkeeping
|
|
59
|
-
assert_equal
|
|
59
|
+
assert_equal 5, BookKeeping::VERSION
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
gem 'minitest', '>= 5.0.0'
|
|
4
|
+
require 'minitest/autorun'
|
|
5
|
+
require_relative 'isogram'
|
|
6
|
+
|
|
7
|
+
# Common test data version: <%= sha1 %>
|
|
8
|
+
class IsogramTest < Minitest::Test<% test_cases.each do |test_case| %>
|
|
9
|
+
def <%= test_case.name %>
|
|
10
|
+
<%= test_case.skip %>
|
|
11
|
+
string = '<%= test_case.input %>'
|
|
12
|
+
<%= test_case.assertion %> Isogram.is_isogram?(string)
|
|
13
|
+
end
|
|
14
|
+
<% end %>
|
|
15
|
+
<%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
|
|
16
|
+
def test_bookkeeping
|
|
17
|
+
skip
|
|
18
|
+
assert_equal <%= version.next %>, BookKeeping::VERSION
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
gem 'minitest', '>= 5.0.0'
|
|
4
|
+
require 'minitest/autorun'
|
|
5
|
+
require_relative 'isogram'
|
|
6
|
+
|
|
7
|
+
# Common test data version: 3dfde31
|
|
8
|
+
class IsogramTest < Minitest::Test
|
|
9
|
+
def test_duplicates
|
|
10
|
+
|
|
11
|
+
string = 'duplicates'
|
|
12
|
+
assert Isogram.is_isogram?(string)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_eleven
|
|
16
|
+
skip
|
|
17
|
+
string = 'eleven'
|
|
18
|
+
refute Isogram.is_isogram?(string)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_subdermatoglyphic
|
|
22
|
+
skip
|
|
23
|
+
string = 'subdermatoglyphic'
|
|
24
|
+
assert Isogram.is_isogram?(string)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_alphabet
|
|
28
|
+
skip
|
|
29
|
+
string = 'Alphabet'
|
|
30
|
+
refute Isogram.is_isogram?(string)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_thumbscrew_japingly
|
|
34
|
+
skip
|
|
35
|
+
string = 'thumbscrew-japingly'
|
|
36
|
+
assert Isogram.is_isogram?(string)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_hjelmqvist_gryb_zock_pfund_wax
|
|
40
|
+
skip
|
|
41
|
+
string = 'Hjelmqvist-Gryb-Zock-Pfund-Wax'
|
|
42
|
+
assert Isogram.is_isogram?(string)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_heizölrückstoßabdämpfung
|
|
46
|
+
skip
|
|
47
|
+
string = 'Heizölrückstoßabdämpfung'
|
|
48
|
+
assert Isogram.is_isogram?(string)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_the_quick_brown_fox
|
|
52
|
+
skip
|
|
53
|
+
string = 'the quick brown fox'
|
|
54
|
+
refute Isogram.is_isogram?(string)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_emily_jung_schwartzkopf
|
|
58
|
+
skip
|
|
59
|
+
string = 'Emily Jung Schwartzkopf'
|
|
60
|
+
assert Isogram.is_isogram?(string)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_éléphant
|
|
64
|
+
skip
|
|
65
|
+
string = 'éléphant'
|
|
66
|
+
refute Isogram.is_isogram?(string)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Problems in exercism evolve over time, as we find better ways to ask
|
|
70
|
+
# questions.
|
|
71
|
+
# The version number refers to the version of the problem you solved,
|
|
72
|
+
# not your solution.
|
|
73
|
+
#
|
|
74
|
+
# Define a constant named VERSION inside of the top level BookKeeping
|
|
75
|
+
# module, which may be placed near the end of your file.
|
|
76
|
+
#
|
|
77
|
+
# In your file, it will look like this:
|
|
78
|
+
#
|
|
79
|
+
# module BookKeeping
|
|
80
|
+
# VERSION = 1 # Where the version number matches the one in the test.
|
|
81
|
+
# end
|
|
82
|
+
#
|
|
83
|
+
# If you are curious, read more about constants on RubyDoc:
|
|
84
|
+
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
|
|
85
|
+
|
|
86
|
+
def test_bookkeeping
|
|
87
|
+
skip
|
|
88
|
+
assert_equal 1, BookKeeping::VERSION
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -1,80 +1,138 @@
|
|
|
1
1
|
module BookKeeping
|
|
2
|
-
VERSION =
|
|
2
|
+
VERSION = 2
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
class Poker
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
def initialize(hand_arrays)
|
|
8
|
+
@hands = hand_arrays.map { |hand_array| Hand.new(hand_array) }
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def best_hand
|
|
11
|
-
|
|
12
|
-
@hands.select { |hand| hand_rank(hand) == best_score }
|
|
12
|
+
hands.select { |hand| hand.score == highest_score }.map(&:to_a)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
private
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
attr_reader :hands
|
|
18
|
+
|
|
19
|
+
def highest_score
|
|
20
|
+
hands.map(&:score).max
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Hand
|
|
26
|
+
|
|
27
|
+
def initialize(hand_array)
|
|
28
|
+
@hand_array = hand_array
|
|
29
|
+
@cards = hand_array.map { |rank_and_suit| Card.new(rank_and_suit) }
|
|
27
30
|
end
|
|
28
31
|
|
|
29
|
-
def
|
|
30
|
-
|
|
32
|
+
def to_a
|
|
33
|
+
hand_array
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
def
|
|
34
|
-
|
|
36
|
+
def score
|
|
37
|
+
[hand_score, card_score].flatten
|
|
35
38
|
end
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
attr_reader :hand_array, :cards
|
|
43
|
+
|
|
44
|
+
def hand_score
|
|
45
|
+
scoring_hands.map.with_index { |scoring_hand, i| i if scoring_hand }.compact.max
|
|
39
46
|
end
|
|
40
47
|
|
|
41
|
-
def
|
|
42
|
-
|
|
48
|
+
def card_score
|
|
49
|
+
five_high_straight? ? [5, 4, 3, 2, 1] : card_score_array
|
|
43
50
|
end
|
|
44
51
|
|
|
45
|
-
def
|
|
46
|
-
|
|
52
|
+
def card_score_array
|
|
53
|
+
rank_count_hash
|
|
54
|
+
.sort_by { |rank, count| [-count, -rank] }
|
|
55
|
+
.map { |count_rank_array| count_rank_array[0] }
|
|
47
56
|
end
|
|
48
57
|
|
|
49
|
-
def
|
|
50
|
-
|
|
58
|
+
def scoring_hands
|
|
59
|
+
[high_card?, one_pair?, two_pair?, three_of_a_kind?, five_high_straight?,
|
|
60
|
+
straight?, flush?, full_house?, four_of_a_kind?, straight_flush?]
|
|
51
61
|
end
|
|
52
62
|
|
|
53
|
-
def
|
|
54
|
-
|
|
63
|
+
def high_card?
|
|
64
|
+
rank_count_totals.max == 1
|
|
55
65
|
end
|
|
56
66
|
|
|
57
|
-
def
|
|
58
|
-
|
|
67
|
+
def one_pair?
|
|
68
|
+
rank_count_totals.max == 2
|
|
59
69
|
end
|
|
60
70
|
|
|
61
|
-
def
|
|
62
|
-
|
|
63
|
-
@card_split.delete(@card_split.key(1))
|
|
64
|
-
return 200 + @card_split.max_by { |k| k }[0]
|
|
65
|
-
end
|
|
71
|
+
def two_pair?
|
|
72
|
+
rank_count_totals == [1, 2, 2]
|
|
66
73
|
end
|
|
67
74
|
|
|
68
|
-
def
|
|
69
|
-
|
|
75
|
+
def three_of_a_kind?
|
|
76
|
+
rank_count_totals.max == 3
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def five_high_straight?
|
|
80
|
+
rank_values == [2, 3, 4, 5, 14]
|
|
70
81
|
end
|
|
71
82
|
|
|
72
83
|
def straight?
|
|
73
|
-
|
|
74
|
-
@card_ranks.uniq.length == 5 && @card_ranks.max - @card_ranks.min == 4
|
|
84
|
+
rank_values.each_cons(2).all? { |a, b| a + 1 == b }
|
|
75
85
|
end
|
|
76
86
|
|
|
77
87
|
def flush?
|
|
78
|
-
|
|
88
|
+
suits.uniq.count == 1
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def full_house?
|
|
92
|
+
rank_count_totals == [2, 3]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def four_of_a_kind?
|
|
96
|
+
rank_count_totals.max == 4
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def straight_flush?
|
|
100
|
+
straight? && flush?
|
|
79
101
|
end
|
|
102
|
+
|
|
103
|
+
def rank_count_totals
|
|
104
|
+
rank_count_hash.values.sort
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def rank_count_hash
|
|
108
|
+
rank_values.each_with_object(Hash.new(0)) { |value, count| count[value] += 1 }
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def rank_values
|
|
112
|
+
cards.map(&:rank_value).sort
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def suits
|
|
116
|
+
cards.map(&:suit)
|
|
117
|
+
end
|
|
118
|
+
|
|
80
119
|
end
|
|
120
|
+
|
|
121
|
+
class Card
|
|
122
|
+
|
|
123
|
+
RANK_VALUES = {'2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6,
|
|
124
|
+
'7' => 7, '8' => 8, '9' => 9, '10' => 10,
|
|
125
|
+
'J' => 11, 'Q' => 12, 'K' => 13, 'A' => 14}
|
|
126
|
+
|
|
127
|
+
attr_reader :rank, :suit
|
|
128
|
+
|
|
129
|
+
def initialize(rank_and_suit)
|
|
130
|
+
@rank = rank_and_suit[0..-2]
|
|
131
|
+
@suit = rank_and_suit[-1]
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def rank_value
|
|
135
|
+
RANK_VALUES[rank]
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
@@ -5,7 +5,6 @@ require_relative 'poker'
|
|
|
5
5
|
|
|
6
6
|
class PokerTest < Minitest::Test
|
|
7
7
|
def test_one_hand
|
|
8
|
-
# skip
|
|
9
8
|
high_of_jack = %w(4S 5S 7H 8D JC)
|
|
10
9
|
game = Poker.new([high_of_jack])
|
|
11
10
|
assert_equal [high_of_jack], game.best_hand
|
|
@@ -14,14 +13,22 @@ class PokerTest < Minitest::Test
|
|
|
14
13
|
def test_highest_card
|
|
15
14
|
skip
|
|
16
15
|
high_of_8 = %w(4S 5H 6S 8D 2H)
|
|
17
|
-
high_of_queen = %w(2S 4H
|
|
16
|
+
high_of_queen = %w(2S 4H 6C 9D QH)
|
|
18
17
|
game = Poker.new([high_of_8, high_of_queen])
|
|
19
18
|
assert_equal [high_of_queen], game.best_hand
|
|
20
19
|
end
|
|
21
20
|
|
|
21
|
+
def test_highest_card_10
|
|
22
|
+
skip
|
|
23
|
+
high_of_8 = %w(4D 5S 6S 8D 3C)
|
|
24
|
+
high_of_10 = %w(2S 4C 7S 9H 10H)
|
|
25
|
+
game = Poker.new([high_of_8, high_of_10])
|
|
26
|
+
assert_equal [high_of_10], game.best_hand
|
|
27
|
+
end
|
|
28
|
+
|
|
22
29
|
def test_nothing_vs_one_pair
|
|
23
30
|
skip
|
|
24
|
-
high_of_king = %w(4S 5H
|
|
31
|
+
high_of_king = %w(4S 5H 6C 8D KH)
|
|
25
32
|
pair_of_4 = %w(2S 4H 6S 4D JH)
|
|
26
33
|
game = Poker.new([high_of_king, pair_of_4])
|
|
27
34
|
assert_equal [pair_of_4], game.best_hand
|
|
@@ -30,7 +37,7 @@ class PokerTest < Minitest::Test
|
|
|
30
37
|
def test_two_pair
|
|
31
38
|
skip
|
|
32
39
|
pair_of_2 = %w(4S 2H 6S 2D JH)
|
|
33
|
-
pair_of_4 = %w(2S 4H
|
|
40
|
+
pair_of_4 = %w(2S 4H 6C 4D JD)
|
|
34
41
|
game = Poker.new([pair_of_2, pair_of_4])
|
|
35
42
|
assert_equal [pair_of_4], game.best_hand
|
|
36
43
|
end
|
|
@@ -38,62 +45,78 @@ class PokerTest < Minitest::Test
|
|
|
38
45
|
def test_one_pair_vs_double_pair
|
|
39
46
|
skip
|
|
40
47
|
pair_of_8 = %w(2S 8H 6S 8D JH)
|
|
41
|
-
|
|
42
|
-
game = Poker.new([pair_of_8,
|
|
43
|
-
assert_equal [
|
|
48
|
+
fives_and_fours = %w(4S 5H 4C 8C 5C)
|
|
49
|
+
game = Poker.new([pair_of_8, fives_and_fours])
|
|
50
|
+
assert_equal [fives_and_fours], game.best_hand
|
|
44
51
|
end
|
|
45
52
|
|
|
46
53
|
def test_two_double_pair
|
|
47
54
|
skip
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
game = Poker.new([
|
|
51
|
-
assert_equal [
|
|
55
|
+
eights_and_twos = %w(2S 8H 2D 8D 3H)
|
|
56
|
+
fives_and_fours = %w(4S 5H 4C 8S 5D)
|
|
57
|
+
game = Poker.new([eights_and_twos, fives_and_fours])
|
|
58
|
+
assert_equal [eights_and_twos], game.best_hand
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_another_two_double_pair
|
|
62
|
+
skip
|
|
63
|
+
aces_and_twos = %w(2S AH 2C AD JH)
|
|
64
|
+
queens_and_jacks = %w(JD QH JS 8D QC)
|
|
65
|
+
game = Poker.new([aces_and_twos, queens_and_jacks])
|
|
66
|
+
assert_equal [aces_and_twos], game.best_hand
|
|
52
67
|
end
|
|
53
68
|
|
|
54
69
|
def test_double_pair_vs_three
|
|
55
70
|
skip
|
|
56
|
-
|
|
57
|
-
three_of_4 = %w(4S 5H
|
|
58
|
-
game = Poker.new([
|
|
71
|
+
eights_and_twos = %w(2S 8H 2H 8D JH)
|
|
72
|
+
three_of_4 = %w(4S 5H 4C 8S 4H)
|
|
73
|
+
game = Poker.new([eights_and_twos, three_of_4])
|
|
59
74
|
assert_equal [three_of_4], game.best_hand
|
|
60
75
|
end
|
|
61
76
|
|
|
62
77
|
def test_two_three
|
|
63
78
|
skip
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
game = Poker.new([
|
|
67
|
-
assert_equal [
|
|
79
|
+
three_twos = %w(2S 2H 2C 8D JH)
|
|
80
|
+
three_aces = %w(4S AH AS 8C AD)
|
|
81
|
+
game = Poker.new([three_twos, three_aces])
|
|
82
|
+
assert_equal [three_aces], game.best_hand
|
|
68
83
|
end
|
|
69
84
|
|
|
70
85
|
def test_three_vs_straight
|
|
71
86
|
skip
|
|
72
|
-
three_of_4 = %w(4S 5H
|
|
73
|
-
straight = %w(3S
|
|
87
|
+
three_of_4 = %w(4S 5H 4C 8D 4H)
|
|
88
|
+
straight = %w(3S 4D 2S 6D 5C)
|
|
74
89
|
game = Poker.new([three_of_4, straight])
|
|
75
90
|
assert_equal [straight], game.best_hand
|
|
76
91
|
end
|
|
77
92
|
|
|
78
|
-
def
|
|
93
|
+
def test_a_5_high_straight
|
|
79
94
|
skip
|
|
80
|
-
three_of_4 = %w(4S 5H
|
|
81
|
-
straight_to_5 = %w(
|
|
95
|
+
three_of_4 = %w(4S 5H 4C 8D 4H)
|
|
96
|
+
straight_to_5 = %w(4D AH 3S 2D 5C)
|
|
82
97
|
game = Poker.new([three_of_4, straight_to_5])
|
|
83
98
|
assert_equal [straight_to_5], game.best_hand
|
|
84
99
|
end
|
|
85
100
|
|
|
86
101
|
def test_two_straights
|
|
87
102
|
skip
|
|
88
|
-
straight_to_8 = %w(4S
|
|
103
|
+
straight_to_8 = %w(4S 6C 7S 8D 5H)
|
|
89
104
|
straight_to_9 = %w(5S 7H 8S 9D 6H)
|
|
90
105
|
game = Poker.new([straight_to_8, straight_to_9])
|
|
91
106
|
assert_equal [straight_to_9], game.best_hand
|
|
92
107
|
end
|
|
93
108
|
|
|
109
|
+
def test_5_high_straight_vs_other_straight
|
|
110
|
+
skip
|
|
111
|
+
straight_to_jack = %w(8H 7C 10D 9D JH)
|
|
112
|
+
straight_to_5 = %w(4S AH 3S 2D 5H)
|
|
113
|
+
game = Poker.new([straight_to_jack, straight_to_5])
|
|
114
|
+
assert_equal [straight_to_jack], game.best_hand
|
|
115
|
+
end
|
|
116
|
+
|
|
94
117
|
def test_straight_vs_flush
|
|
95
118
|
skip
|
|
96
|
-
straight_to_8 = %w(
|
|
119
|
+
straight_to_8 = %w(4C 6H 7D 8D 5H)
|
|
97
120
|
flush_to_7 = %w(2S 4S 5S 6S 7S)
|
|
98
121
|
game = Poker.new([straight_to_8, flush_to_7])
|
|
99
122
|
assert_equal [flush_to_7], game.best_hand
|
|
@@ -109,8 +132,8 @@ class PokerTest < Minitest::Test
|
|
|
109
132
|
|
|
110
133
|
def test_flush_vs_full
|
|
111
134
|
skip
|
|
112
|
-
flush_to_8 = %w(3H 6H 7H 8H
|
|
113
|
-
full = %w(4S 5H
|
|
135
|
+
flush_to_8 = %w(3H 6H 7H 8H 5C)
|
|
136
|
+
full = %w(4S 5H 4C 5D 4H)
|
|
114
137
|
game = Poker.new([flush_to_8, full])
|
|
115
138
|
assert_equal [full], game.best_hand
|
|
116
139
|
end
|
|
@@ -125,26 +148,26 @@ class PokerTest < Minitest::Test
|
|
|
125
148
|
|
|
126
149
|
def test_full_vs_square
|
|
127
150
|
skip
|
|
128
|
-
full = %w(4S 5H
|
|
129
|
-
square_of_3 = %w(3S 3H 2S 3D
|
|
151
|
+
full = %w(4S 5H 4D 5D 4H)
|
|
152
|
+
square_of_3 = %w(3S 3H 2S 3D 3C)
|
|
130
153
|
game = Poker.new([square_of_3, full])
|
|
131
154
|
assert_equal [square_of_3], game.best_hand
|
|
132
155
|
end
|
|
133
156
|
|
|
134
157
|
def test_two_square
|
|
135
158
|
skip
|
|
136
|
-
square_of_2 = %w(2S 2H
|
|
137
|
-
square_of_5 = %w(4S 5H 5S 5D
|
|
159
|
+
square_of_2 = %w(2S 2H 2C 8D 2D)
|
|
160
|
+
square_of_5 = %w(4S 5H 5S 5D 5C)
|
|
138
161
|
game = Poker.new([square_of_2, square_of_5])
|
|
139
162
|
assert_equal [square_of_5], game.best_hand
|
|
140
163
|
end
|
|
141
164
|
|
|
142
165
|
def test_square_vs_straight_flush
|
|
143
166
|
skip
|
|
144
|
-
square_of_5 = %w(4S 5H 5S 5D
|
|
145
|
-
|
|
146
|
-
game = Poker.new([square_of_5,
|
|
147
|
-
assert_equal [
|
|
167
|
+
square_of_5 = %w(4S 5H 5S 5D 5C)
|
|
168
|
+
straight_flush_to_10 = %w(7S 8S 9S 6S 10S)
|
|
169
|
+
game = Poker.new([square_of_5, straight_flush_to_10])
|
|
170
|
+
assert_equal [straight_flush_to_10], game.best_hand
|
|
148
171
|
end
|
|
149
172
|
|
|
150
173
|
def test_two_straight_flushes
|
|
@@ -155,6 +178,14 @@ class PokerTest < Minitest::Test
|
|
|
155
178
|
assert_equal [straight_flush_to_9], game.best_hand
|
|
156
179
|
end
|
|
157
180
|
|
|
181
|
+
def test_highest_card_down_to_fifth_card
|
|
182
|
+
skip
|
|
183
|
+
high_of_8_low_of_3 = %w(3S 5H 6S 8D 7H)
|
|
184
|
+
high_of_8_low_of_2 = %w(2S 5D 6D 8C 7S)
|
|
185
|
+
game = Poker.new([high_of_8_low_of_3, high_of_8_low_of_2])
|
|
186
|
+
assert_equal [high_of_8_low_of_3], game.best_hand
|
|
187
|
+
end
|
|
188
|
+
|
|
158
189
|
def test_three_hand_with_tie
|
|
159
190
|
skip
|
|
160
191
|
spade_straight_to_9 = %w(9S 8S 7S 6S 5S)
|
|
@@ -166,6 +197,6 @@ class PokerTest < Minitest::Test
|
|
|
166
197
|
end
|
|
167
198
|
|
|
168
199
|
def test_bookkeeping
|
|
169
|
-
assert_equal
|
|
200
|
+
assert_equal 2, BookKeeping::VERSION
|
|
170
201
|
end
|
|
171
202
|
end
|