Challenge:
Given two five-card hands, determine which one wins by the standard ranking of poker hands.
Input:
Ten cards separated by spaces from stdin or as command line arguments, whichever you prefer. The first five cards are Player 1's hand while the last five are Player 2's hand. Each card will be a two letter string of the form RS where R is rank and S is suit. The ranks range from 2-9, T for ten, and J, Q, K, and A for Jack, Queen, King, and Ace respectively. The suits are H, D, C, S for Hearts, Diamonds, Clubs, and Spades respectively. You must output the number of the player that wins: '1' or '2'.
Examples of Cards:
AS - the Ace of Spades
QD - the Queen of Diamonds
2C - the Two of Clubs
TH - the Ten of Hearts
Input to Output Examples:
5H 5C 6S 7S KD 2C 3S 8S 8D TD -> 2
Explanation: Player 1 has a Pair of Fives while Player 2 has a Pair of Eights.
5D 8C 9S JS AC 2C 5C 7D 8S QH -> 1
Explanation: Neither Player has anything special, but Player 1's high card is an Ace while Player 2's high card is a Queen.
2D 9C AS AH AC 3D 6D 7D TD QD -> 2
Explanation: Player 1 has Three Aces, Player 2 has a Flush of Diamonds.
4D 6S 9H QH QC 3D 6D 7H QD QS -> 1
Explanation: Both players have a Pair of Queens, but Player 1's second highest card is a Nine whereas Player 2's is a Seven.
Rules and Clarifications:
- Refer to the standard ranking of poker hands for the details of comparing hands.
- You may assume that there are no repeated cards in each pair of hands.
- You may assume that there is a definite winner in each case.
- Suit does not factor into the ranking of a hand. For example, two royal flushes of different suits are equal (therefore any input where both players have a royal flush is invalid by the preceding rule).
- As this is code golf, the shortest answer wins.
Notes:
- Related to this question and this one.
- Based on Project Euler Problem 54