FAILURE MAP
← Case archive

FA-81871 / Poker hand evaluation / Open access

Four-flush draw counted as a made flush · case 01

Four hearts and a spade are reported as a flush.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The flush test counts at least four cards of the first suit, the threshold of a flush draw rather than a made flush.

THE FAILURE

The flush test counts at least four cards of the first suit, the threshold of a flush draw rather than a made flush.

Unsuccessful approach: Comparing only the first and last suits misses a mismatched middle card.

Case contract

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

Why this case matters

Poker engines settle real money pots from these comparisons; a single misranked hand pays the wrong seat.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=suits.count(suits[0])>=4
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
wheel straightstraightstraightPassed
wheel straight flushstraight flushstraight flushPassed
four to wheel plus ninehigh cardhigh cardPassed
plain flushflushflushPassed
full housefull housefull housePassed
lower-case rankstwo pairtwo pairPassed
mixed-case suits flushflushflushPassed
four-flush onlyflushhigh cardFailed

SHA-256 / 2c92266d1169eb067d9e374cc130b7018568096fc42162cd4cbb6320c08f7512

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=suits[0]==suits[-1]
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
wheel straightstraight flushstraightFailed
wheel straight flushstraight flushstraight flushPassed
four to wheel plus nineflushhigh cardFailed
plain flushflushflushPassed
full housefull housefull housePassed
lower-case rankstwo pairtwo pairPassed
mixed-case suits flushflushflushPassed
four-flush onlyhigh cardhigh cardPassed

SHA-256 / 1394f463fdf28579f8ac7b4b6d08918cf590d1cbd43b17be9e2bce7b09be9fba

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic toy model with an explicitly stated contract; card strings are rank+suit (for example "As", "Td", "10h"); no claim of conformance to any casino or tournament rulebook. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:50:06.971356+00:00.

Case digest / 7aebbdf0adbbf4ba30596373a8a5525427be73f14fede2a89eb650b4af014a17