← Back to Upcase

Ruby Challenges - Ranking Poker Hands


(Upcase ) #1

This topic is for the [Ranking Poker Hands][] exercise in the [Ruby Challenges][] trail. Post any questions, corrections, or pointers you have to share with other Upcase subscribers.
[Ranking Poker Hands]: https://exercises.upcase.com/exercises/ranking-poker-hands
[Ruby Challenges]: https://thoughtbot.com/upcase/ruby-challenges


(thedanotto) #2

In the spec/hand_evaluator_spec.rb, what does expect_higher mean? —> Nevermind, I see it defined at the bottom of the spec. Well played.


(DiSalvio) #3

How should we handle ties (two straight flushes of different suits, same high card - two hands with same two pairs - different suits, same high card, etc.)?

Also the spec below has three 2 of diamonds in the second example, which makes me wonder: are we expecting that there are multiple decks in play? And should our evaluator work for community games like texas hold 'em where cards can be shared between different hands. Just wondering because that adds extra contingencies that couldn’t occur with one deck in standard 5 card poker (i.e. you’d never have to check the kicker of 4 of a kind, 3 of a kind, or a full house). It would be nice to have this info included in the exercise description so we can take it into account up front before we dive into the code.

it “breaks ties in a full house using the three of a kind, then pair” do
expect_higher “2D 2C 4D 4C 4H”, "2H 2S 3D 3C 3H"
expect_higher “2D 2C 2D 4C 4H”, "2H 2S 2D 3C 3H"
end

…but maybe I’m just nitpicking here…


(Oren Kanner) #4

FYI, the following test (/spec/hand_evaluator_spec.rb:39) is actually testing a straight flush against a straight:

it "scores a flush higher than a straight" do
  expect_higher "2H 3H 4H 5H 6H", "TD JD QH KH AS"
end