In this question: Name the poker hand you had to take a five card poker hand and identify it. This question is similar, with two twists:
First, the output will be in all lower case. This allows for more golfing, as you don't have to worry about the capitalization of
high card one pair two pair three of a kind straight flush full house four of a kind straight flush royal flush
Secondly, with the popularity of Texas Hold'em and 7 card stud, we here at code golf should be able to score a seven card poker hand am I right? When scoring a seven card hand, use the five best cards for your hand and ignore the two you don't need.
List of poker hands: http://en.wikipedia.org/wiki/List_of_poker_hands
Input (lifted directly from the previous thread)
7 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
9 (number cards),
The suits are
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 AH QS => one pair JH 4C 2C 9S 4H JD 2H => two pair 7H 3S 7S 7D AC QH 7C => four of a kind 8C 3H 8S 8H 3S 2C 5D => full house AS KC KD KH QH TS JC => straight
Notice in the second example there are actually three pairs, but you can only use five cards, so it's
two pair. In the fifth example, there are both a
three of a kind and a
straight possible, but a
straight is better, so output
This is code-golf, so shortest code wins!
- You may not use external resources.
- Ace is both high and low for straights.