D - Texas Hold'em Poker Solitaire |
John Anthony Good usually meets his friends on Fridays to have a poker night. They play Texas Hold'em poker which is, nowadays, the most popular poker game. In Texas Hold'em, each player may use any combination of his two face-down cards and the five face-up community cards to make a poker hand. The player can use his two cards, just one, or none of them to make the best hand.
A poker deck is comprised of 52 cards, organized in four suits ("Spades", "Hearts", "Diamonds", and "Clubs") and 13 values ('2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', and 'A', ordered from lowest to highest).
The hands that a player can make are the following ones (from highest to lowest):
John Anthony and his friends bet 5 euros each night and he always loses his money, sometimes because he thinks that he has a lower hand than he actually has. Particularly, he has serious problems when his hand is a straight.
In order to improve his poker skills, John Anthony has made up a solitaire card game. He shuffles the deck and puts 49 cards from the 52-card deck faced-up on the table compounding a 7x7-card square. For example, you can have the following case:
2C KC 3D 7S 7H 5D 6D 2H 7D 4H 4S TS 3H 8S 3S 5H AD 5S 6S 3C 9C 9S JC QC KD JH KS QS 6C 8H AC 2S 6H AH KH TC AS 9H QD 7C 4C 8C TH 2D JS 9D 8D 5C JD
Then, he checks the seven rows (starting from top to bottom), the seven columns (starting from left to right), and the two diagonals (first, the one starting in the top-left corner and, then, the diagonal starting in the bottom-left corner). For each one of these sixteen sets of seven cards he tries to select the combination of five cards that comprise the highest possible hand (as in Texas Hold'em).
Now, he is asking you to write a program that helps him to check if the hand that he finds is the highest one.
The input consists of a first line with a number indicating the number of test cases. Then the test cases are separated by a new line. Each test case consists of seven lines with seven cards each one separated by blank spaces. Each card is represented by his value (first) and his suit (second) without spaces between them.
For each input case, you must print a line with the following information. First, the line with the seven cards that include the best hand in the same order that they appear (rows and diagonals from left to right, and columns from top to bottom). Then two blank spaces, and the five cards that give the highest hand in the same order that they appear in the line. Finally, two blank spaces more and the name of the hand ("High Cards", "One Pair", "Two Pair", "Three of a Kind", "Straight", "Flush", "Full House", "Four of a Kind", "Straight Flush"). In case of two hands with the same score, the hand that should be printed is the first one in the order in which the square and the cards are checked by John Anthony.
4 9H 4H TD 5H QC 7H KC 7S TS JS 8S 6D 2C 5C QD 5S 7D KH 4S 8D 2H TH AD QH 3D KD 9C 4D 5D 9S 8H JH AH 3S 6C JC 7C AS 6H TC KS 8C 6S QS 2S 4C 9D AC JD 2C KC 3D 7S 7H 5D 6D 2H 7D 4H 4S TS 3H 8S 3S 5H AD 5S 6S 3C 9C 9S JC QC KD JH KS QS 6C 8H AC 2S 6H AH KH TC AS 9H QD 7C 4C 8C TH 2D JS 9D 8D 5C JD 9D AS KS KD AC 8D TH AH JS 9H TC 2C QH 5S 7D JH 8C 3H 7C 5H 6H 5C 8S TS 2D QC KH 2H JC 4H 4D 8H 2S 4C 3S 9C TD 9S 3C 7H 3D QS KC 4S AD JD 6S 7S QD 6H JH 4H AC 5H TS 7D AH 6S 5S 6C 4C 5D 8S JC 8H AD 9S TC 9D 4D 8D 7C 6D 3D 8C KC 7H 4S TD 5C JD QD KD QS 9C TH 3C 2S AS QC 3H 2C 9H 3S 2D JS 7S KS
TH AD QH 3D KD 9C 4D TH AD QH KD 9C High Cards 6C 8H AC 2S 6H AH KH 6C AC 6H AH KH Two Pair JC 4H 4D 8H 2S 4C 3S JC 4H 4D 8H 4C Three of a Kind JH 6S 8H 7C TD TH 9H JH 8H 7C TD 9H Straight
OMP'10
Facultad de Informatica
Universidad de Murcia (SPAIN)