FA-82101 / Poker hand evaluation / Open access
Ranks ordered alphabetically instead of by strength · case 01
Queen-ten is written "TQs" and ace-king "KAo".
ROOT CAUSE
The two ranks are sorted as characters, where T sorts after Q and K after A.
VERIFIED REPAIR
Sort by position in the rank table, highest first.
Unsuccessful approach: Sorting by rank strength ascending puts the lower card first.
Case contract
Input: two hole cards as strings (rank may be "10"; rank and suit case-insensitive). Return canonical hold'em notation: pairs "QQ", otherwise higher rank first with "s" for suited or "o" for offsuit (e.g. "AKs", "T9o"). Return "invalid" for duplicate cards or unknown ranks.
Why this case matters
Range tools, solvers and hand histories key statistics on this notation.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
def rank(c):
t=c[:-1].upper()
return 'T' if t=='10' else t
a,b=rank(x[0]),rank(x[1])
if a not in list(R) or b not in list(R): return 'invalid'
if a==b: return a+b
hi,lo=sorted([a,b], reverse=True)
return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
('exact duplicate', ['7c', '7c'], 'invalid'), ('empty rank', ['h', 'Kd'], 'invalid'),
('two-letter rank', ['KQh', '2d'], 'invalid'),
('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
('queen ten', ['Tc', 'Qc'], 'QTs'), ('empty rank', ['h', 'Kd'], 'invalid'),
('two-letter rank', ['KQh', '2d'], 'invalid'),
('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
[('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| ace king suited | KAs | AKs | Failed |
| king ace offsuit order | KAo | AKo | Failed |
| pair of queens | QQ | QQ | Passed |
| duplicate card case | invalid | invalid | Passed |
| exact duplicate | invalid | invalid | Passed |
| empty rank | invalid | invalid | Passed |
| two-letter rank | invalid | invalid | Passed |
| pair of tens mixed tokens | TT | TT | Passed |
SHA-256 / c44d999b1ca76e3556e0dbd721712d542db69dd181837cffe96c29e1a39ff5e8
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
def rank(c):
t=c[:-1].upper()
return 'T' if t=='10' else t
a,b=rank(x[0]),rank(x[1])
if a not in list(R) or b not in list(R): return 'invalid'
if a==b: return a+b
hi,lo=sorted([a,b], key=R.index)
return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
('exact duplicate', ['7c', '7c'], 'invalid'), ('empty rank', ['h', 'Kd'], 'invalid'),
('two-letter rank', ['KQh', '2d'], 'invalid'),
('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
('queen ten', ['Tc', 'Qc'], 'QTs'), ('empty rank', ['h', 'Kd'], 'invalid'),
('two-letter rank', ['KQh', '2d'], 'invalid'),
('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
[('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| ace king suited | KAs | AKs | Failed |
| king ace offsuit order | KAo | AKo | Failed |
| pair of queens | QQ | QQ | Passed |
| duplicate card case | invalid | invalid | Passed |
| exact duplicate | invalid | invalid | Passed |
| empty rank | invalid | invalid | Passed |
| two-letter rank | invalid | invalid | Passed |
| pair of tens mixed tokens | TT | TT | Passed |
SHA-256 / 4b35c062243345fb9f2080398f8cbe2c7e2071d2ad3fa0191f20b7f7d261872d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
def rank(c):
t=c[:-1].upper()
return 'T' if t=='10' else t
a,b=rank(x[0]),rank(x[1])
if a not in list(R) or b not in list(R): return 'invalid'
if a==b: return a+b
hi,lo=sorted([a,b], key=R.index, reverse=True)
return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
('exact duplicate', ['7c', '7c'], 'invalid'), ('empty rank', ['h', 'Kd'], 'invalid'),
('two-letter rank', ['KQh', '2d'], 'invalid'),
('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
('queen ten', ['Tc', 'Qc'], 'QTs'), ('empty rank', ['h', 'Kd'], 'invalid'),
('two-letter rank', ['KQh', '2d'], 'invalid'),
('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
[('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| ace king suited | AKs | AKs | Passed |
| king ace offsuit order | AKo | AKo | Passed |
| pair of queens | QQ | QQ | Passed |
| duplicate card case | invalid | invalid | Passed |
| exact duplicate | invalid | invalid | Passed |
| empty rank | invalid | invalid | Passed |
| two-letter rank | invalid | invalid | Passed |
| pair of tens mixed tokens | TT | TT | Passed |
SHA-256 / ef7338d2f6fa5dac3aa9abe12ae20e16835f393978814eb7b85ed257c4a22e01
Verification & scope
A deterministic toy model with an explicitly stated contract; card strings are rank+suit (for example "As", "Td"); 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:08.911830+00:00.
Case digest / 6678f2ba6b39d28ce30272e006c775de7516f8773bb53036c1b48d82527093fb