Poker game good algorithm for solving ties between two pairs

sshou14

New Member
Joined
Oct 14, 2014
Messages
1
This is the Poker problem in one of previous year's final. See question here
I attempted most questions in the problem and have attached my worksheets, and here's my question:
Does anyone have any good idea how to best solve ties between two pairs?
8C 8D 7S 5S 5C
9C 8S 8H 5H 5D

Here's my idea:
step 1: rank the five cards (solved in part 1)
step 2: Since there're two pairs in five cards, there must be a pair in the first three cards, and another pair in the last three cards. We can use the Mode function to find the two pairs
step 3: if both pairs are equal, we can just do a high card rank for all the cards in order to break ties.

What do you think is the best way to do it?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi sshoul14,
Was puzzling over this one for some time. You can't just find the high card if both pairs are equal because the high card could be part of one of the pairs. You have to find the one that isn't a pair or the one that occurs least frequently and rank them. I assume during your sorting process you separated the numbers and suits. For me, this was in row 9. I found this on another site but it worked great to find the single card for player 1.

=INDEX($D$9:$H$9, MATCH(MIN(INDEX(COUNTIF($D$9:$H$9,$D$9:$H$9),0)), INDEX(COUNTIF($D$9:$H$9,$D$9:$H$9), 0),0))

Use the same format for player 2 and then rank them. I hate really long formulas so I made a little table for high pair/low pair/single for each player using Mode as you suggested in step 2 and the above for the single.
Once I found that line it was easy.
 
Upvote 0
You can't just find the high card if both pairs are equal because the high card could be part of one of the pairs. You have to find the one that isn't a pair or the one that occurs least frequently and rank them.
Welcome to the MrExcel board!

The blue part is right. The red part might work but I don't agree with the underlined part.

I'm guessing to some extent but I don't think sshou14 was suggesting "just find the high card". Considering the particular example shown and given it is already established that there are two equal pairs then I think the underlined part below meant:

Hand1: 8+8+7+5+5=33
Hand2: 9+8+8+5+5=35
Hand2 wins

Does anyone have any good idea how to best solve ties between two pairs?
8C 8D 7S 5S 5C
9C 8S 8H 5H 5D

Here's my idea:
step 1: rank the five cards (solved in part 1)
step 2: Since there're two pairs in five cards, there must be a pair in the first three cards, and another pair in the last three cards. We can use the Mode function to find the two pairs
step 3: if both pairs are equal, we can just do a high card rank for all the cards in order to break ties.
 
Upvote 0
Peter,
Well that is much less complicated and works equally well. Just out of curiosity though, I think my method might be necessary to determine tie breaks for a full house since the total could be vastly different. The problem assigns a value of 14 to an ace. Therefore, a full house of AA222 is beaten by 44333 but the first hand would total 34 while the second hand only totals 17.
I believe I have solved the problem, so I am just interested if you would have a different method of solving that tie break.
Thanks,
Ed
 
Upvote 0
I think my method might be necessary to determine tie breaks for a full house ..
As far as my knowledge of poker hands goes it is not possible to get a tie with two full house hands so a tie breaker would be unnecessary.
 
Upvote 0
Ah, true. its part of the steps of the original problem.
First you identify each player's hand. If both players have the same hand, (a full house, straight, 2 pair, etc), then you have to determine which is better. My use of the words "tie breaks" was the verbiage used in the problem and not necessarily in the context of poker.
 
Upvote 0
Hi edopts, Peter,

Actually, the blue part highlighted is incorrect, in the context that shhou14 was using it, I think. The high card rule should work its way down both hands, see that both high cards tie, and move to the next highest card. This is required to solve one of the other parts of the problem, to break ties when there are no hand combinations available.

So if we had two hands with the following cards, we should have the following results:

H1 : 8, 8, 7, 5, 5
H2 : 8, 8, 5, 5, 4
Win: T, T, 1, -, -

... thus identifying that Hand 1 is the winner.

sshou14, your approach is basically the way that we solved the 'two pairs' problem in the official Corality Worked Solution, except we took a different approach to determining the value of the two pairs, rather than using the MODE function as you have.
 
Upvote 0
In the case there are 2 pairs, after solving step 1, the higher pair is the 2nd card and the lower pair is the 4th card.
If both pairs are equal, we can just do a high card rank for all the cards in order to break ties.

For ranking high card, since all the card are ranked then you can find the winner by comparing the two sums: Sum1 of player1 = Card1*10^4 + Card2*10^3 +Card3*10^2 +Card4*10 + Card5. Similar for Player2.
If sum1 = sum2 then it's a tie, if sum1 > sum 2 then player 1 wins.


 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,037
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top