Swept coding challenge allowing you to showcase your logic handling and code structuring abilities.
Write a simple app that can take two 5-card poker hands, classify each hand, and determine which hand would win. For this problem suits are ignored, so a flush will not be possible.
Each card can be represented by a single character:
A
for aceK
for kingQ
for queenJ
for jackT
for ten2-9
for the remaining*
for a wild card (max of 1 per hand)
Hand classifications are as follows (highest to lowest):
- four-of-a-kind (4 cards of the same value:
AAAA5
) - full house (3 of one, and 2 of another:
KKKQQ
) - straight (all 5 in sequential order:
6789T
) - three-of-a-kind (3 cards of the same value:
KKK23
) - two pair (
AA33J
) - pair (
44KQA
) - high card (nothing else:
A267J
)
When comparing two pair hands, compare the highest pair first, then the next pair (i.e. AA223 > KKQQT
, since AA > KK
). When the highest pair is a tie, move on to the next pair (i.e. AA993 > AA88K
).
Similarly, when comparing full house hands, the three-card group is compared first (i.e. AAA22 > KKKQQ
).
In the case of ties, determine a winner by comparing the next highest card in the hand (i.e. AA234 < AA235
because AA
s tie, 2
s tie, 3
s tie, but 4 < 5
).
Straights are compared by the highest card in the hand, except for A2345
, in which case the 5 is considered the highest card in the straight.
When there is a wild card (*
), the final hand has to be a valid 5-card poker hand (no five-of-a-kind!)
For each comparison, display the classification and indicate which hand would win or that the result is a tie.
Examples:
AAAKT
vs22233
: AAAKT three-of-a-kind < 22233 full house2345*
vsKKJJ2
: 2345* straight > KKJJ2 two pairAAKKT
vsAAKKT
: AAKKT two pair == AAKKT two pairKKKKA
vsKKKK*
: KKKKA four-of-a-kind == KKKK* four-of-a-kind
Don't worry about the visuals. Plain text inputs are totally fine. We're just looking for clean code.
- Ease of understanding code structure and logic
- Ease of running module and testing specific hands
- Proper handling of inputs, edge cases and wild cards
- Well documented README.md
- Bonus points for including some unit Tests for core logic
- Go through the requirements and let us know if you have any questions
- Come up with a realistic estimate of how long it will take you to get this done
- Share your GitHub repo for the take-home with us