Poker Hand Comparison With Custom Ranking

Asked at Rippling · Coding Questions · Difficulty: Medium · Last asked May 29, 2026

You are writing the referee for a small card game. Each player is dealt a hand of four cards written as a string of digits `'1'` to `'9'`, where `'9'` is the highest card. A hand has a type, and the stronger type wins; if the types are equal, the cards are compared position by position. The rules differ from normal poker, so follow the ones below exactly.

Loading the problem…