FA-81946 / Poker hand evaluation / Open access
Four-card run accepted as a straight · case 01
9-T-J-Q with no eight or king is reported as a queen-high straight.
ROOT CAUSE
The window mask has four bits set, so any four consecutive ranks match.
VERIFIED REPAIR
Use a five-bit window 0b11111 shifted so its top bit is the candidate top rank.
Unsuccessful approach: Keeping five bits but shifting by top-5 reports each straight one rank low.
Case contract
Input: 5 to 7 distinct cards "Rs". Build a rank bitmask (bit r for rank value r, 2..14; the ace also sets bit 1). Return the top rank of the highest five-card straight contained in the ranks (5 for the wheel), or 0 if none.
Why this case matters
Bitmask evaluators are the standard fast path for seven-card hold'em straights.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
m=0
for c in x:
m|=1<<(R.index(c[0])+2)
if m & (1<<14): m|=1<<1
for top in range(14,4,-1):
need=0b1111<<(top-3)
if m & need == need: return top
return 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel in seven', ['Ah', '2d', '3c', '4s', '5h', 'Kd', 'Kc'], 5),
('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah', '2c', '2d'], 14),
('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('no straight', ['2h', '5d', '7c', '9s', 'Jh', 'Kd', 'Ac'], 0),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('no straight low cards', ['2h', '3d', '4c', '8s', '9h', 'Qd', 'Qc'], 0)],
[('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah', '2c', '2d'], 14),
('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0)],
[('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('five cards straight', ['6h', '7d', '8c', '9s', 'Th'], 10),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0),
('king with low run', ['Kh', '2d', '3c', '4s', '5h', '9d'], 0)],
[('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('five cards straight', ['6h', '7d', '8c', '9s', 'Th'], 10),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0),
('pair of fours with straight', ['3h', '4d', '4c', '5s', '6h', '7d', 'Ac'], 7),
('king with low run', ['Kh', '2d', '3c', '4s', '5h', '9d'], 0)],
[('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('pair of fours with straight', ['3h', '4d', '4c', '5s', '6h', '7d', 'Ac'], 7),
('two pair inside straight', ['8h', '8d', '9c', '9s', 'Th', 'Jd', 'Qc'], 12),
('king-high straight', ['9h', 'Td', 'Jc', 'Qs', 'Kh', '3d', '2c'], 13),
('wheel without king', ['Ah', '2d', '3c', '4s', '5h', '9d', 'Jc'], 5)]]
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 |
|---|---|---|---|
| wheel in seven | 5 | 5 | Passed |
| broadway | 14 | 14 | Passed |
| six-high over wheel | 6 | 6 | Passed |
| four-straight only | 12 | 0 | Failed |
| paired straight | 9 | 9 | Passed |
| no straight | 0 | 0 | Passed |
| gap straight | 9 | 0 | Failed |
| no straight low cards | 0 | 0 | Passed |
SHA-256 / 991507c896de77e97072deed3c4dce54f93490aeb70eb8fbd08406e761802e25
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
m=0
for c in x:
m|=1<<(R.index(c[0])+2)
if m & (1<<14): m|=1<<1
for top in range(14,4,-1):
need=0b11111<<(top-5)
if m & need == need: return top
return 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel in seven', ['Ah', '2d', '3c', '4s', '5h', 'Kd', 'Kc'], 5),
('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah', '2c', '2d'], 14),
('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('no straight', ['2h', '5d', '7c', '9s', 'Jh', 'Kd', 'Ac'], 0),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('no straight low cards', ['2h', '3d', '4c', '8s', '9h', 'Qd', 'Qc'], 0)],
[('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah', '2c', '2d'], 14),
('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0)],
[('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('five cards straight', ['6h', '7d', '8c', '9s', 'Th'], 10),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0),
('king with low run', ['Kh', '2d', '3c', '4s', '5h', '9d'], 0)],
[('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('five cards straight', ['6h', '7d', '8c', '9s', 'Th'], 10),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0),
('pair of fours with straight', ['3h', '4d', '4c', '5s', '6h', '7d', 'Ac'], 7),
('king with low run', ['Kh', '2d', '3c', '4s', '5h', '9d'], 0)],
[('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('pair of fours with straight', ['3h', '4d', '4c', '5s', '6h', '7d', 'Ac'], 7),
('two pair inside straight', ['8h', '8d', '9c', '9s', 'Th', 'Jd', 'Qc'], 12),
('king-high straight', ['9h', 'Td', 'Jc', 'Qs', 'Kh', '3d', '2c'], 13),
('wheel without king', ['Ah', '2d', '3c', '4s', '5h', '9d', 'Jc'], 5)]]
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 |
|---|---|---|---|
| wheel in seven | 6 | 5 | Failed |
| broadway | 0 | 14 | Failed |
| six-high over wheel | 7 | 6 | Failed |
| four-straight only | 0 | 0 | Passed |
| paired straight | 10 | 9 | Failed |
| no straight | 0 | 0 | Passed |
| gap straight | 0 | 0 | Passed |
| no straight low cards | 0 | 0 | Passed |
SHA-256 / 96085c0a3505a9669d7fa50c488755d636839202eb2ff0cf8e859bf8471b745d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
R='23456789TJQKA'
m=0
for c in x:
m|=1<<(R.index(c[0])+2)
if m & (1<<14): m|=1<<1
for top in range(14,4,-1):
need=0b11111<<(top-4)
if m & need == need: return top
return 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel in seven', ['Ah', '2d', '3c', '4s', '5h', 'Kd', 'Kc'], 5),
('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah', '2c', '2d'], 14),
('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('no straight', ['2h', '5d', '7c', '9s', 'Jh', 'Kd', 'Ac'], 0),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('no straight low cards', ['2h', '3d', '4c', '8s', '9h', 'Qd', 'Qc'], 0)],
[('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah', '2c', '2d'], 14),
('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0)],
[('six-high over wheel', ['Ah', '2d', '3c', '4s', '5h', '6d', 'Jc'], 6),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('five cards straight', ['6h', '7d', '8c', '9s', 'Th'], 10),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0),
('king with low run', ['Kh', '2d', '3c', '4s', '5h', '9d'], 0)],
[('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('paired straight', ['5h', '5d', '6c', '7s', '8h', '9d', 'Kc'], 9),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('five cards straight', ['6h', '7d', '8c', '9s', 'Th'], 10),
('ace-king-queen-jack only', ['Ah', 'Kd', 'Qc', 'Js', '9h'], 0),
('pair of fours with straight', ['3h', '4d', '4c', '5s', '6h', '7d', 'Ac'], 7),
('king with low run', ['Kh', '2d', '3c', '4s', '5h', '9d'], 0)],
[('four-straight only', ['9h', 'Td', 'Jc', 'Qs', '2h', '2d', '3c'], 0),
('trips inside straight', ['5h', '5d', '5c', '6s', '7h', '8d', '9c'], 9),
('seven-card long straight', ['4h', '5d', '6c', '7s', '8h', '9d', 'Tc'], 10),
('gap straight', ['2h', '3d', '4c', '6s', '7h', '8d', '9c'], 0),
('pair of fours with straight', ['3h', '4d', '4c', '5s', '6h', '7d', 'Ac'], 7),
('two pair inside straight', ['8h', '8d', '9c', '9s', 'Th', 'Jd', 'Qc'], 12),
('king-high straight', ['9h', 'Td', 'Jc', 'Qs', 'Kh', '3d', '2c'], 13),
('wheel without king', ['Ah', '2d', '3c', '4s', '5h', '9d', 'Jc'], 5)]]
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 |
|---|---|---|---|
| wheel in seven | 5 | 5 | Passed |
| broadway | 14 | 14 | Passed |
| six-high over wheel | 6 | 6 | Passed |
| four-straight only | 0 | 0 | Passed |
| paired straight | 9 | 9 | Passed |
| no straight | 0 | 0 | Passed |
| gap straight | 0 | 0 | Passed |
| no straight low cards | 0 | 0 | Passed |
SHA-256 / e3d3f3aee0ed9c03973e84436c263408b9e9fa8bd09850c74d2d464a161d19e0
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:07.620500+00:00.
Case digest / 9d4f550dacaf82c515b45a70f7a4d1a9e4b8b5be0199e560eb432df7e1eca0b4