Your question is Simplified Poker Winner. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Samba TV's audience measurement pipelines may need deterministic ranking logic when multiple candidate records receive the same score. Implement a simplified poker evaluator that compares five-card hands and identifies the winning hand or hands.
Each card is represented by an integer rank from 2 through 14, where 14 represents an ace. Suits are irrelevant. Rank hands using these categories, from strongest to weakest: four of a kind, full house, three of a kind, two pair, one pair, and high card. A hand's category is determined by the frequency of its ranks.
Return a list containing the zero-based indices of every hand tied for the best result. Within the same category, compare the relevant repeated ranks first, then compare remaining cards in descending order. For example, a higher four-of-a-kind wins, and equal four-of-a-kind hands compare their kicker cards. Return the tied indices in ascending order.
Input hands is a list of at least two five-element integer lists. Output is a list of integer indices. All hands are valid, and no hand contains duplicate physical cards. Suits are omitted, so identical ranks may appear in different hands.
def winning_hands(hands):