Primary Menu

Algorithm Problem: Ranking a Poker Hand

This was a fun problem: create a program to rank a 5-card poker hand, e.g. “Royal Flush”. Given two poker hands, be able to determine which one is the winner.

My first implementation took about an hour, but failed to include code for tie-breaking hands with equal rankings. It wasn’t difficult to modify my original method to return a 2-tuple that also contained a list of card values that could be compared for breaking a tie.

The result is a nice library for ranking a poker hand, including test cases to cover all of the logic.