Algorithm · Rippling · Hard
Two players each receive a five-card hand. Every card is a single digit character from '1' through '9', and duplicate digits are allowed. Implement compare_hands(hand1, hand2), returning 1 if hand1 is stronger, 2 if hand2 is stronger, and 0 if the hands are exactly equal. Hands are ranked only by how many times each digit appears. From strongest to weakest, the categories are: five of a kind four of a kind full house two pair three of a kind one pair high card There are no…
Checking your access…