Poker is usually played with a standard deck of 52 cards. Each card is marked with one of 13 face values and one of 4 suits. In a common version of poker, a player receives a hand of five cards. Hands that match certain combinations, or patterns, have specific names like "FULL HOUSE" or "ROYAL FLUSH". The less likely it is that a particular hand will be dealt, the better that hand is.
You want to play poker with some friends, but your little sister has been using all the cards in the house to perform magic tricks. It seems the only trick she has perfected is a disappearing act which makes it impossible to find a complete deck of cards. You and your friends gather as many cards as you are able to find and put them into a single deck. This, however, might change the probability of getting certain poker hands. Given a String[] decks that lists the contents of the partial decks that were gathered, calculate the odds of getting each poker hand from the new combined deck. Return a String[] containing the names of each poker hand in order of increasing probability so that the best hand is listed first. Hands that have an equal chance of being dealt should be listed in alphabetical order. Hands that have no chance of being dealt should be excluded from the results.
Each element in decks is a list of cards separated by spaces. Each card will be in the format <face><suit> where <face> is one of the 13 face values, listed in increasing consecutive order ( 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A ) and <suit> is one of ( C, D, H, S ).
The possible hands from a combined deck are:
"ONE PAIR" - two of the five cards have the same face value (2C 4S 5H 8C 8D)
"TWO PAIR" - two of one face value and two of a different face value (4H 4S 5H 8C 8D)
"THREE OF A KIND" - three cards of the same face value (2C 4S 8H 8C 8D)
"FOUR OF A KIND" - four cards of the same face value (2C 8S 8H 8C 8D)
"FULL HOUSE" - three of one face value and two of a different face value (8H 8C 8D 4C 4S)
"FLUSH" - five cards of the same suit (2C 5C 7C QC AC)
"STRAIGHT" - five cards with consecutive face values (8C 9S 10C JH QD)
The ace may be used as the low card in a straight (AD 2C 3S 4C 5H)
However, wrapping is not allowed (QC KC AC 2D 3C)
"STRAIGHT FLUSH" - matches both a FLUSH and a STRAIGHT (7H 8H 9H 10H JH)
"ROYAL FLUSH" - ten, jack, queen, king, ace of the same suit (10S JS QS KS AS)
"FIVE OF A KIND" - all five cards with the same face value (6C 6D 6C 6S 6H)
"NOTHING" - a hand that does not match any of these combinations (2C 7D 8H 10C AS)
Since the order in which cards are dealt does not matter, a hand containing ( QD 9S JH 8C 10C ) is identical to ( 8C 9S 10C JH QD ) and both would be classified as a "STRAIGHT". A hand that matches more than one of the descriptions listed above is classified with the name that appears lowest. For instance, the hand ( 3C 3D 3H KC KD ) would be classified as a "FULL HOUSE" even though it also matches the descriptions for "THREE OF A KIND" and "ONE PAIR".
|