408220: GYM103059 A Alaska Don't Release Them
Description
Cheyenne is playing a fish-themed variant of the poker game Texas Hold 'Em called Alaska Don't Release Them. Just like in a round of Texas Hold 'Em, each player in Alaska Don't Release Them gets dealt a private two-card hand at the beginning of the round that they will ultimately combine with five community cards that get flipped over one at a time. Once all five community cards are revealed, each player that has not yet folded (and thus remains in the betting by the end of the round) looks at their two private cards and the five community cards and then plays the highest-ranking five-card hand that they can make from amongst those seven cards.
In Alaska Don't Release Them, there are twelve possible ranked hands, listed below in order from highest to lowest value.
- Rockfish Flush – an Ace, 2, 3, 4, and 5, all of the same suit
- Fisherman's Five – five cards of the same rank
- Harpoon Flush – five cards of the same suit, in consecutive sequence, and not including an Ace card
- Four of a Species – four cards of the same rank
- Full Net – three cards of the same rank, along with a pair of cards of another rank
- Riverbed – any five cards of the same suit
- Harpoon – five cards in consequence sequence, not all of the same suit, and not including an Ace card
- Three of a Species – three cards of the same rank
- Double Pacific – two unique pairs of cards of the same rank, where the two pairs differ in their ranks
- Pacific Duo – two cards of the same rank
- Fish Bait – any hand containing an Ace card
- Garbage – a hand not qualifying as any of the above-ranked hands
Additionally, an important rule in this variant of poker is that Queen cards are considered wild and can be used to represent any card in the deck as part of forming a ranked hand. And whoever can create the highest ranked hand wins the pot!
Cheyenne wants to get better at Alaskan poker by quickly determining the ranked value of her poker hand. Help Cheyenne achieve her goals by computing the highest-ranking hand that she could possibly produce out of the five community cards and the two cards in her private hand. Given $$$N$$$ sets of seven known cards, output the highest-ranking hand possible for each one.
InputThe first line of input contains an integer $$$N$$$ ($$$1 \leq N \leq 10^6$$$), the number of card sets to follow. Then $$$N$$$ lines follow, each beginning with an integer $$$i$$$ ($$$1 \leq i \leq N$$$) denoting the index of that card set. The rest of the $$$i^{th}$$$ line contains seven card specifier strings, each formatted with the card's rank followed by its suit. A card rank can be any of A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, where A, J, Q, K represent Ace, Jack, Queen, and King respectively. Then the card's suit can be any of H, D, S, C, where these represent each of the four suits—Hearts, Diamonds, Spades, and Clubs, respectively.
OutputFor each set of cards, output the index of the set, followed by the name of the highest-ranking hand that Cheyenne could possibly produce using its cards.
ExampleInput12 1 QS QH 5C QD JH 4D 4C 2 AH 9H QS QC 9S JS 9D 3 6D QC KC 6S 4S 5S QD 4 AH QD 5S 2S AC QC 3H 5 KS 2S AC 3D 3S 3C 2D 6 2C 8D QC QH AD 5D 10C 7 6H 8H QC KH 10C 9S JS 8 10H 7H 5D QH AH 3S 10C 9 5C KH 7D JH 3H 3C JC 10 2H 7C 6C 8C 10C 5S 8D 11 2C 8D 10S 3H 5S AH 6C 12 10S 3D 8D JD 2S 9S 6COutput
1 Rockfish Flush 2 Fisherman's Five 3 Harpoon Flush 4 Four of a Species 5 Full Net 6 Riverbed 7 Harpoon 8 Three of a Species 9 Double Pacific 10 Pacific Duo 11 Fish Bait 12 Garbage