Name the poker hand
Given five cards, output the name of the poker hand, which will be one of:
High card
One pair
Two pair
Three of a kind
Straight
Flush
Full house
Four of a kind
Straight flush
Royal Flush
If in doubt, refer to the rules at http://en.wikipedia.org/wiki/List_of_poker_hands.
Input
5 cards from either stdin or commandline arguments.
A card is a two letter string on the form RS
, where R is rank and S is suit.
The ranks are 2
- 9
(number cards), T
(ten), J
(Jack), Q
(Queen), K
(King), A
(Ace).
The suits are S
, D
, H
, C
for spades, diamonds, hearts and clubs respectively.
Example of cards
5H - five of hearts
TS - ten of spades
AD - ace of diamonds
Example of input => desired output
3H 5D JS 3C 7C => One pair
JH 4C 2C JD 2H => Two pair
7H 3S 7S 7D 7C => Four of a kind
8C 3H 8S 8H 3S => Full house
Rules
Shortest code wins
Edit
Looking great so far! I can't really verify all the answers, since I don't know these languages very well and don't have compilers/interpreters for all of them, but I suspect that not everyone have thought about that Aces can be both the highest and the lowest cards of a Straight (flush).