#K93827. Poker Hand Ranking
Poker Hand Ranking
Poker Hand Ranking
You are given a collection of poker hands. Each hand contains exactly five cards. Each card is represented by a two-character string, where the first character denotes the rank and the second character the suit. For example, '2H' stands for the 2 of Hearts and 'TH' stands for the Ten of Hearts.
Your task is to determine the ranking of each hand. The ranking categories are defined as follows:
- Straight Flush: All cards are of the same suit and the cards form a consecutive sequence.
- Four of a Kind: Four cards with the same rank.
- Full House: Three cards of one rank and two cards of another rank.
- Flush: All cards are of the same suit.
- Straight: The cards form a consecutive sequence.
- Three of a Kind: Three cards with the same rank.
- Two Pair: Two different pairs.
- One Pair: Two cards with the same rank.
- High Card: None of the above conditions are met.
It is guaranteed that the input hands are valid. Use the following rank conversion: \(2-9\) represent their respective numeric value, \(T = 10\), \(J = 11\), \(Q = 12\), \(K = 13\) and \(A = 14\).
inputFormat
The input is read from stdin and has the following format:
n hand1 hand2 ... handn
Here, n is an integer representing the number of poker hands, and each hand consists of exactly five cards separated by spaces.
outputFormat
For each hand provided in the input, output its ranking on a separate line to stdout.
## sample1
2H 3D 5S 9C KD
High Card
</p>