FA-82256 / Poker hand evaluation / Open access
Equal boards resolved alphabetically · case 01
With identical boards, the player whose name sorts first acts, not the earliest seat.
ROOT CAUSE
Players are scanned in name order, so the strict comparison keeps the alphabetically first tie.
VERIFIED REPAIR
Scan in seat order and replace the leader only on a strictly better board.
Unsuccessful approach: Scanning seats in reverse keeps the latest seat on ties.
Case contract
Input: {"seats": [clockwise order from the dealer's left], "hands": {player: {"up": [...], "down": [...]}}, "folded": [...]}. On fourth street and later the live player with the best exposed hand acts first. Exposed hands rank by group shape (quads > trips > two pair > pair > no pair), then by group ranks; only up cards count. Exact ties go to the player earliest in seat order.
Why this case matters
Acting order on later stud streets follows the best board, not position.
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'
def show(cards):
vals=sorted((R.index(c[0])+2 for c in cards), reverse=True)
cnt=collections.Counter(vals)
order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
shape=sorted(cnt.values(), reverse=True)
return (shape, order)
best=None; who=None
for p in sorted(x['hands']):
if p in x['folded']: continue
k=show(x['hands'][p]['up'])
if best is None or k>best: best, who = k, p
return who
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('higher pair wins',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['8h', '8d', 'Ac']},
'b': {'down': ['2d', '3d'], 'up': ['9h', '9d', '2s']}},
'seats': ['a', 'b']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('high cards only',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', '9d', '4c']},
'b': {'down': ['2d', '4d'], 'up': ['Kc', 'Td', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('high cards only',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', '9d', '4c']},
'b': {'down': ['2d', '4d'], 'up': ['Kc', 'Td', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('higher pair wins',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['8h', '8d', 'Ac']},
'b': {'down': ['2d', '3d'], 'up': ['9h', '9d', '2s']}},
'seats': ['a', 'b']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')]]
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 |
|---|---|---|---|
| pair beats ace king | b | b | Passed |
| hidden pair ignored | a | a | Passed |
| hidden trips ignored | b | b | Passed |
| tie goes to earlier seat | a | a | Passed |
| tie seat order not name | a | b | Failed |
| folded best board | b | b | Passed |
| two pair beats pair | b | b | Passed |
| three-way tie later seat | a | b | Failed |
SHA-256 / 54b8650c0a2e38c86c12ed90f75ff83c09fb9b9c6009b76f9bba494e1c635b87
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'
def show(cards):
vals=sorted((R.index(c[0])+2 for c in cards), reverse=True)
cnt=collections.Counter(vals)
order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
shape=sorted(cnt.values(), reverse=True)
return (shape, order)
best=None; who=None
for p in reversed(x['seats']):
if p in x['folded']: continue
k=show(x['hands'][p]['up'])
if best is None or k>best: best, who = k, p
return who
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('higher pair wins',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['8h', '8d', 'Ac']},
'b': {'down': ['2d', '3d'], 'up': ['9h', '9d', '2s']}},
'seats': ['a', 'b']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('high cards only',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', '9d', '4c']},
'b': {'down': ['2d', '4d'], 'up': ['Kc', 'Td', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('high cards only',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', '9d', '4c']},
'b': {'down': ['2d', '4d'], 'up': ['Kc', 'Td', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('higher pair wins',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['8h', '8d', 'Ac']},
'b': {'down': ['2d', '3d'], 'up': ['9h', '9d', '2s']}},
'seats': ['a', 'b']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')]]
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 |
|---|---|---|---|
| pair beats ace king | b | b | Passed |
| hidden pair ignored | a | a | Passed |
| hidden trips ignored | b | b | Passed |
| tie goes to earlier seat | b | a | Failed |
| tie seat order not name | a | b | Failed |
| folded best board | b | b | Passed |
| two pair beats pair | b | b | Passed |
| three-way tie later seat | a | b | Failed |
SHA-256 / c9b9e8ac6d448793c256601f79b1ff6e70311844a4818f7c3224046bfeb230df
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'
def show(cards):
vals=sorted((R.index(c[0])+2 for c in cards), reverse=True)
cnt=collections.Counter(vals)
order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
shape=sorted(cnt.values(), reverse=True)
return (shape, order)
best=None; who=None
for p in x['seats']:
if p in x['folded']: continue
k=show(x['hands'][p]['up'])
if best is None or k>best: best, who = k, p
return who
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('higher pair wins',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['8h', '8d', 'Ac']},
'b': {'down': ['2d', '3d'], 'up': ['9h', '9d', '2s']}},
'seats': ['a', 'b']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('high cards only',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', '9d', '4c']},
'b': {'down': ['2d', '4d'], 'up': ['Kc', 'Td', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('high cards only',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', '9d', '4c']},
'b': {'down': ['2d', '4d'], 'up': ['Kc', 'Td', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('pair beats ace king',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['7h', '7d']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['a', 'b', 'c']},
'b'),
('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie goes to earlier seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['As', 'Kc']},
'c': {'down': ['2h', '3h'], 'up': ['9h', '4d']}},
'seats': ['c', 'a', 'b']},
'a'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')],
[('hidden pair ignored',
{'folded': [],
'hands': {'a': {'down': ['Ac', 'Kc'], 'up': ['Ah', 'Kd']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'a'),
('hidden trips ignored',
{'folded': [],
'hands': {'a': {'down': ['9c', '9s'], 'up': ['9h', '4d']},
'b': {'down': ['5d', '3d'], 'up': ['Th', '2d']}},
'seats': ['a', 'b']},
'b'),
('tie seat order not name',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Qh', 'Qd']},
'b': {'down': ['2d', '3d'], 'up': ['Qs', 'Qc']}},
'seats': ['b', 'a']},
'b'),
('folded best board',
{'folded': ['a'],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad']},
'b': {'down': ['2d', '3d'], 'up': ['Qh', 'Jd']}},
'seats': ['a', 'b']},
'b'),
('two pair beats pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Ah', 'Ad', 'Kc']},
'b': {'down': ['2d', '3d'], 'up': ['5h', '5d', '4c', '4s']}},
'seats': ['a', 'b']},
'b'),
('higher pair wins',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['8h', '8d', 'Ac']},
'b': {'down': ['2d', '3d'], 'up': ['9h', '9d', '2s']}},
'seats': ['a', 'b']},
'b'),
('trips beat two pair',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Kh', 'Kd', 'Qc', 'Qs']},
'b': {'down': ['2d', '4d'], 'up': ['3h', '3d', '3s', '2s']}},
'seats': ['a', 'b']},
'b'),
('three-way tie later seat',
{'folded': [],
'hands': {'a': {'down': ['2c', '3c'], 'up': ['Jh', '7d']},
'b': {'down': ['2d', '4d'], 'up': ['Jc', '7h']},
'c': {'down': ['2h', '4h'], 'up': ['Js', '7c']}},
'seats': ['b', 'c', 'a']},
'b')]]
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 |
|---|---|---|---|
| pair beats ace king | b | b | Passed |
| hidden pair ignored | a | a | Passed |
| hidden trips ignored | b | b | Passed |
| tie goes to earlier seat | a | a | Passed |
| tie seat order not name | b | b | Passed |
| folded best board | b | b | Passed |
| two pair beats pair | b | b | Passed |
| three-way tie later seat | b | b | Passed |
SHA-256 / df8fa969e06b4cc0fe2602ba3574ab0000395f1e6084184ebda011b9c4a6145d
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:10.449594+00:00.
Case digest / ec731004595c1b2b8bae26647befddaaccb3b72a3e3a9661b6d0d4bcffab9ec2