FAILURE MAP
← Case archive

FA-82266 / Poker hand evaluation / Open access

High cards outrank an exposed pair · case 01

A-K showing acts before 7-7 showing.

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

ROOT CAUSE

The comparison key places group ranks before group shape.

VERIFIED REPAIR

Compare group shape first, then group ranks.

Unsuccessful approach: Keeping only the largest group size and sorting ranks plainly ties two pair with one pair and orders by highest card.

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 (order, shape)
    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'),
  ('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')],
 [('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'),
  ('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'),
  ('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')],
 [('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'),
  ('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')],
 [('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'),
  ('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')]]
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
pair beats ace kingabFailed
hidden pair ignoredaaPassed
hidden trips ignoredbbPassed
tie goes to earlier seataaPassed
tie seat order not namebbPassed
folded best boardbbPassed
two pair beats pairabFailed
higher pair winsbbPassed

SHA-256 / cab13b796d5c43cfaaf68047fbbc7727b89cb25e452ea24a62e602e99b1f6338

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[:1], sorted(order, reverse=True))
    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'),
  ('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')],
 [('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'),
  ('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'),
  ('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')],
 [('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'),
  ('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')],
 [('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'),
  ('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')]]
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
pair beats ace kingbbPassed
hidden pair ignoredaaPassed
hidden trips ignoredbbPassed
tie goes to earlier seataaPassed
tie seat order not namebbPassed
folded best boardbbPassed
two pair beats pairabFailed
higher pair winsabFailed

SHA-256 / 5e6787306ae4da665b81689235bdab31e55ad4818d0e6b6dca4aa83626463dba

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'),
  ('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')],
 [('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'),
  ('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'),
  ('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')],
 [('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'),
  ('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')],
 [('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'),
  ('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')]]
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
pair beats ace kingbbPassed
hidden pair ignoredaaPassed
hidden trips ignoredbbPassed
tie goes to earlier seataaPassed
tie seat order not namebbPassed
folded best boardbbPassed
two pair beats pairbbPassed
higher pair winsbbPassed

SHA-256 / a92056bbb3ffb3c2228e233fa73452b547d1644867a20ba7b61aa94c4824470d

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

Case digest / 3ff01c05e5534b20dc052f6de05c09e1592f8cf541cacacae6f83e53f9c195ee