FAILURE MAP
← Case archive

FA-81861 / Poker hand evaluation / Open access

Two-character ten token crashes rank parsing · case 01

Hands containing "10h" fail to evaluate while "Th" works.

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

ROOT CAUSE

The rank is read from the first character only, so "10h" yields rank "1", which is not in the rank table.

VERIFIED REPAIR

Take everything before the suit character as the rank token and map "10" to T before upper-casing.

Unsuccessful approach: Handling "10" but dropping the upper-case normalization breaks lower-case rank letters such as "kd".

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(c[0].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=len(set(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'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('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'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('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'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('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
four to wheel plus kinghigh cardhigh cardPassed
plain flushflushflushPassed
ten written as 10error:ValueErrorstraightFailed
lower-case rankstwo pairtwo pairPassed
ten flush with 10 tokenerror:ValueErrorflushFailed

SHA-256 / ca11981cba2e313577814b7dc8ccad5c7154ea47d2f7786529437e8a898e4953

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])+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(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'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('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'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('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'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('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
four to wheel plus kinghigh cardhigh cardPassed
plain flushflushflushPassed
ten written as 10straightstraightPassed
lower-case rankserror:ValueErrortwo pairFailed
ten flush with 10 tokenflushflushPassed

SHA-256 / a39424da02e0583033e9e85eb0e96096c90af7777f212916aed1f5639ec569c2

3 / The verified repair

Exit 0
"""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=len(set(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'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('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'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('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'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('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
four to wheel plus kinghigh cardhigh cardPassed
plain flushflushflushPassed
ten written as 10straightstraightPassed
lower-case rankstwo pairtwo pairPassed
ten flush with 10 tokenflushflushPassed

SHA-256 / 4958e27c7c47080eb601c450065614d022aa008e457592dfaa7c89ef4944d36b

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.926996+00:00.

Case digest / b6bd542898734a72484f0b77c6c673e44467378f87335f583de64f70ec9afe69