Proposal: Add a test case for full houses where the triplet outranks the pair

Hi everyone!

While mentoring the poker exercise, I ran into a bug in a student’s solution that the current test suite doesn’t catch: full houses are only detected correctly when the three-of-a-kind ranks lower than the pair. A full house where the triplet outranks the pair (e.g. three Tens and a pair of Twos) gets misclassified as a weaker hand.

Why this is worth a test

This is an easy trap to fall into with any solution that derives hand shape by counting ranks and reading off the counts in some fixed order. In the solution I reviewed, cards were sorted by rank ascending, then run through a rank counter; the resulting count sequence was checked against a fixed pattern like [3, 2]. That pattern only appears when the triplet’s rank is lower than the pair’s rank — because sorting the cards first means the lower rank’s count always comes first in iteration order. A full house with the triplet on the high end (e.g. 10H 10S 10D 2S 2D) produces [2, 3] instead, fails the pattern check, and falls through to being scored as three-of-a-kind with kickers.

Looking at the current canonical tests for full house:

  • the “full house beats a straight” style tests and the full-house-vs-full-house tie-break test all happen to use hands where the triplet rank is lower than the pair rank

None of them exercise the reverse ordering, so a solution built around a fixed count-pattern assumption can pass the whole suite while silently misclassifying roughly half of all real full houses.

Suggested test

{
  "uuid": "to-be-defined",
  "description": "full house beats three of a kind, triplet outranks pair",
  "property": "bestHands",
  "input": {
    "hands": ["10H 10S 10D 2S 2D", "AH AS AD KC QD"]
  },
  "expected": ["10H 10S 10D 2S 2D"]
}

This pairs a full house with the triplet on the high end against a three-of-a-kind, so any solution relying on a fixed low-then-high (or high-then-low) count pattern rather than checking counts independent of rank order would fail it, while a correct implementation passes trivially.

Happy to tweak the hand values, description, or naming to better match existing conventions if there’s a better fit. Curious whether this seems worth folding into the canonical tests.

1 Like

+1 from me, and :+1: for the great description of the test gap finding.

@stefanrothermel did you use an LLM to help you write this description?

Anyway, I agree with adding the test.

@senekor: As I’m not a native English speaker, I often draft my thoughts and use an LLM to proofread and refine my grammar, spelling, and phrasing. I did that for my initial post—I hope I didn’t violate any forum rules or break any expectations!