This kata is based on the Poker Hands Kata, but it is much simpler. I’ve come across this version multiple times but I could not find it anywhere on the web yet, so I’ll share it here:
You shall write a simple algorithm to parse a poker hand (a deck consisting of some cards) and report the highest card combination from the hand.
A card is represented as a simple string like H10
for the Ten of
Hearts or SA
for the ace of Spades.
A hand is represented as a space-separated string of cards:
C5 S1 H5 CK HQ
The card ranks are:
- numbers
2
to10
J
JackQ
QueenK
KingA
Ace
The card suits are:
S
SpadesH
HeartsD
DiamondsC
Clubs
To make this simple, you should only care about single cards (High Card) and Pairs, where any pair is higher than any single card.
Cards ranks are ordered as shown above (2
is lowest, A
is
highest).
Card suits are not relevant for scoring.
- given input
D8 H3 S9 CJ D2
=> expected outputCJ
- given input
S3 D5 CJ D3 S7
=> expected outputS3 D3