broken_source:
"""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)

source:
"""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)

prompt:
A-K showing acts before 7-7 showing.

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.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    known=x['cards']+x.get('dead',[])
    ranks={R.index(c[0])+2 for c in x['cards']}
    def has(rs):
        rs=set(rs)
        if 14 in rs: rs.add(0)
        return any(all(t-i in rs for i in range(5)) for t in range(5,15))
    if has(ranks): return 0
    outs=0
    for r in range(2,15):
        if has(ranks|{r}):
            outs+=4-sum(1 for c in known if R.index(c[0])+2==r)
    return outs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3)],
 [('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3)]]
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    known=x['cards']+x.get('dead',[])
    ranks={R.index(c[0])+2 for c in x['cards']}
    def has(rs):
        rs=set(rs)
        if 13 in rs: rs.add(1)
        return any(all(t-i in rs for i in range(5)) for t in range(5,15))
    if has(ranks): return 0
    outs=0
    for r in range(2,15):
        if has(ranks|{r}):
            outs+=4-sum(1 for c in known if R.index(c[0])+2==r)
    return outs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3)],
 [('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3)]]
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)

prompt:
A-2-3-4 is reported as having no straight outs.

Input: {"cards": known hole and board cards (4 to 6, no straight yet), "dead": other seen cards}. Return how many unseen cards would give the player a five-card straight (ace plays high or low): for every rank that completes a straight, count its four cards minus those already seen in cards or dead.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    known=x['cards']+x.get('dead',[])
    ranks={R.index(c[0])+2 for c in x['cards']}
    def has(rs):
        rs=set(rs)
        if 14 in rs: rs.add(1)
        return any(all(t-i in rs for i in range(4)) for t in range(5,15))
    if has(ranks): return 0
    outs=0
    for r in range(2,15):
        if has(ranks|{r}):
            outs+=4-sum(1 for c in known if R.index(c[0])+2==r)
    return outs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8)],
 [('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    known=x['cards']+x.get('dead',[])
    ranks={R.index(c[0])+2 for c in x['cards']}
    def has(rs):
        rs=set(rs)
        if 14 in rs: rs.add(1)
        return any(sum(t-i in rs for i in range(5))>=4 for t in range(5,15))
    if has(ranks): return 0
    outs=0
    for r in range(2,15):
        if has(ranks|{r}):
            outs+=4-sum(1 for c in known if R.index(c[0])+2==r)
    return outs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8)],
 [('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)]]
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)

prompt:
Open-ended draws report zero outs because the draw is already counted as a straight.

Input: {"cards": known hole and board cards (4 to 6, no straight yet), "dead": other seen cards}. Return how many unseen cards would give the player a five-card straight (ace plays high or low): for every rank that completes a straight, count its four cards minus those already seen in cards or dead.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    known=x['cards']+x.get('dead',[])
    ranks={R.index(c[0])+2 for c in x['cards']}
    def has(rs):
        rs=set(rs)
        if 14 in rs: rs.add(1)
        return any(all(t-i in rs for i in range(5)) for t in range(5,15))
    if has(ranks): return 0
    outs=0
    for r in range(2,15):
        if has(ranks|{r}):
            outs+=4-sum(1 for c in x['cards'] if R.index(c[0])+2==r)
    return outs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    known=x['cards']+x.get('dead',[])
    ranks={R.index(c[0])+2 for c in x['cards']}
    def has(rs):
        rs=set(rs)
        if 14 in rs: rs.add(1)
        return any(all(t-i in rs for i in range(5)) for t in range(5,15))
    if has(ranks): return 0
    outs=0
    for r in range(2,15):
        if has(ranks|{r}):
            outs+=4-(1 if any(R.index(c[0])+2==r for c in known) else 0)
    return outs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('no draw', {'cards': ['2h', '7d', 'Tc', 'Ks', '4h'], 'dead': []}, 0),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('double gutshot', {'cards': ['7h', '9d', 'Tc', 'Js', 'Kh', '2c'], 'dead': []}, 8),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('three to straight only', {'cards': ['8h', '9d', 'Tc', '2s', '3h'], 'dead': []}, 0),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 5),
  ('open ender with seen nine', {'cards': ['5h', '6d', '7c', '8s', '8h'], 'dead': ['9c', '4d']},
   6)],
 [('open ended', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': []}, 8),
  ('gutshot', {'cards': ['8h', '9d', 'Jc', 'Qs', '2h'], 'dead': []}, 4),
  ('ace-low draw', {'cards': ['Ah', '2d', '3c', '4s', 'Kh'], 'dead': []}, 4),
  ('ace-high draw', {'cards': ['Ah', 'Kd', 'Qc', 'Js', '2h'], 'dead': []}, 4),
  ('open ended with dead', {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', 'Qd', 'Qs']},
   5),
  ('paired board seen out', {'cards': ['8h', '9d', 'Tc', 'Js', 'Qh'], 'dead': []}, 0),
  ('wheel gutshot with dead', {'cards': ['Ah', '2d', '4c', '5s', 'Jh'], 'dead': ['3h']}, 3),
  ('two dead copies of an out',
   {'cards': ['8h', '9d', 'Tc', 'Js', '2h'], 'dead': ['7c', '7d', 'Qd']}, 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)

prompt:
Outs exposed in other players' hands are counted as live.

Input: {"cards": known hole and board cards (4 to 6, no straight yet), "dead": other seen cards}. Return how many unseen cards would give the player a five-card straight (ace plays high or low): for every rank that completes a straight, count its four cards minus those already seen in cards or dead.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a//2)
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('nine five offsuit', ['9c', '5d'], 1)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)],
 [('nine seven offsuit', ['9h', '7d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, round(a/2))
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('nine five offsuit', ['9c', '5d'], 1)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)],
 [('nine seven offsuit', ['9h', '7d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7)]]
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)

prompt:
Nine-high, seven-high and five-high hands score a point lower than they should.

Input: two hole cards. Chen score: highest card points A=10, K=8, Q=7, J=6, else half its rank (2..10). Pairs double the points with a minimum of 5. Suited adds 2. Gap between ranks (cards strictly between) subtracts 0, 1, 2, 4 for gaps 0-3 and 5 for 4+. Add 1 for gap 0 or 1 when both cards are below a queen. Round the final score up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=s*2
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
 [('pocket deuces', ['2h', '2d'], 5), ('pocket fives', ['5h', '5d'], 5),
  ('nine seven offsuit', ['9h', '7d'], 5), ('queen jack suited', ['Qs', 'Js'], 9),
  ('ace five offsuit', ['Ah', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('pocket sevens', ['7h', '7s'], 7)],
 [('pocket deuces', ['2h', '2d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('pocket sevens', ['7h', '7s'], 7)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=max(s,5)*2
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
 [('pocket deuces', ['2h', '2d'], 5), ('pocket fives', ['5h', '5d'], 5),
  ('nine seven offsuit', ['9h', '7d'], 5), ('queen jack suited', ['Qs', 'Js'], 9),
  ('ace five offsuit', ['Ah', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('pocket sevens', ['7h', '7s'], 7)],
 [('pocket deuces', ['2h', '2d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('pocket sevens', ['7h', '7s'], 7)]]
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)

prompt:
Pocket deuces score 2 instead of 5.

Input: two hole cards. Chen score: highest card points A=10, K=8, Q=7, J=6, else half its rank (2..10). Pairs double the points with a minimum of 5. Suited adds 2. Gap between ranks (cards strictly between) subtracts 0, 1, 2, 4 for gaps 0-3 and 5 for 4+. Add 1 for gap 0 or 1 when both cards are below a queen. Round the final score up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('ace five offsuit', ['Ah', '5d'], 5), ('pocket sevens', ['7h', '7s'], 7)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('seven six suited', ['7h', '6h'], 7),
  ('nine seven offsuit', ['9h', '7d'], 5), ('queen jack suited', ['Qs', 'Js'], 9),
  ('ace five offsuit', ['Ah', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('pocket sevens', ['7h', '7s'], 7)],
 [('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('eight six suited', ['8d', '6d'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('queen jack suited', ['Qs', 'Js'], 9),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('nine five offsuit', ['9c', '5d'], 1),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-2
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('ace five offsuit', ['Ah', '5d'], 5), ('pocket sevens', ['7h', '7s'], 7)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('seven six suited', ['7h', '6h'], 7),
  ('nine seven offsuit', ['9h', '7d'], 5), ('queen jack suited', ['Qs', 'Js'], 9),
  ('ace five offsuit', ['Ah', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('pocket sevens', ['7h', '7s'], 7)],
 [('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('eight six suited', ['8d', '6d'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('queen jack suited', ['Qs', 'Js'], 9),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('nine five offsuit', ['9c', '5d'], 1),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)]]
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)

prompt:
Seven-six suited loses a point and the connector bonus logic misfires.

Input: two hole cards. Chen score: highest card points A=10, K=8, Q=7, J=6, else half its rank (2..10). Pairs double the points with a minimum of 5. Suited adds 2. Gap between ranks (cards strictly between) subtracts 0, 1, 2, 4 for gaps 0-3 and 5 for 4+. Add 1 for gap 0 or 1 when both cards are below a queen. Round the final score up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('seven six suited', ['7h', '6h'], 7),
  ('nine seven offsuit', ['9h', '7d'], 5), ('queen jack suited', ['Qs', 'Js'], 9),
  ('ace five offsuit', ['Ah', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('queen jack suited', ['Qs', 'Js'], 9),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1),
  ('pocket sevens', ['7h', '7s'], 7), ('eight six suited', ['8d', '6d'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('ace king suited', ['Ah', 'Kh'], 12), ('queen jack suited', ['Qs', 'Js'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('jack nine offsuit', ['Jh', '9c'], 6)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and b<12: s+=1
    return math.ceil(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('seven six suited', ['7h', '6h'], 7),
  ('nine seven offsuit', ['9h', '7d'], 5), ('queen jack suited', ['Qs', 'Js'], 9),
  ('ace five offsuit', ['Ah', '5d'], 5), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('queen jack suited', ['Qs', 'Js'], 9),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1),
  ('pocket sevens', ['7h', '7s'], 7), ('eight six suited', ['8d', '6d'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('ace king suited', ['Ah', 'Kh'], 12), ('queen jack suited', ['Qs', 'Js'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('jack nine offsuit', ['Jh', '9c'], 6)]]
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)

prompt:
Queen-jack and ace-king receive the low-connector bonus point.

Input: two hole cards. Chen score: highest card points A=10, K=8, Q=7, J=6, else half its rank (2..10). Pairs double the points with a minimum of 5. Suited adds 2. Gap between ranks (cards strictly between) subtracts 0, 1, 2, 4 for gaps 0-3 and 5 for 4+. Add 1 for gap 0 or 1 when both cards are below a queen. Round the final score up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return round(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1)],
 [('seven six suited', ['7h', '6h'], 7), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('nine five offsuit', ['9c', '5d'], 1)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    pts={14:10,13:8,12:7,11:6}
    a,b=sorted((R.index(c[0])+2 for c in x), reverse=True)
    s=pts.get(a, a/2)
    if a==b:
        s=max(s*2,5)
    else:
        if x[0][1]==x[1][1]: s+=2
        gap=a-b-1
        s-={0:0,1:1,2:2,3:4}.get(gap,5)
        if gap<=1 and a<12: s+=1
    return int(s)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5)],
 [('ace king suited', ['Ah', 'Kh'], 12), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('ace five offsuit', ['Ah', '5d'], 5),
  ('king nine suited', ['Kc', '9c'], 6), ('ten nine offsuit', ['Th', '9d'], 6),
  ('jack ten suited', ['Js', 'Ts'], 9), ('nine five offsuit', ['9c', '5d'], 1)],
 [('seven six suited', ['7h', '6h'], 7), ('king nine suited', ['Kc', '9c'], 6),
  ('ten nine offsuit', ['Th', '9d'], 6), ('jack ten suited', ['Js', 'Ts'], 9),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('nine five offsuit', ['9c', '5d'], 1), ('pocket sevens', ['7h', '7s'], 7),
  ('eight six suited', ['8d', '6d'], 6), ('jack nine offsuit', ['Jh', '9c'], 6)],
 [('pocket aces', ['Ah', 'Ad'], 20), ('pocket deuces', ['2h', '2d'], 5),
  ('pocket fives', ['5h', '5d'], 5), ('ace king suited', ['Ah', 'Kh'], 12),
  ('seven six suited', ['7h', '6h'], 7), ('nine seven offsuit', ['9h', '7d'], 5),
  ('queen jack suited', ['Qs', 'Js'], 9), ('nine five offsuit', ['9c', '5d'], 1)]]
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)

prompt:
Nine-seven offsuit scores 2 instead of 3.

Input: two hole cards. Chen score: highest card points A=10, K=8, Q=7, J=6, else half its rank (2..10). Pairs double the points with a minimum of 5. Suited adds 2. Gap between ranks (cards strictly between) subtracts 0, 1, 2, 4 for gaps 0-3 and 5 for 4+. Add 1 for gap 0 or 1 when both cards are below a queen. Round the final score up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(x):
    R='A23456789TJQK'
    def best(h):
        for n in range(4,0,-1):
            cands=[]
            for sub in itertools.combinations(h,n):
                if len({c[1] for c in sub})==n:
                    cands.append(sorted((R.index(c[0])+1 for c in sub), reverse=True))
            if cands: return (n, min(cands))
    a,b=best(x[0]),best(x[1])
    if a[0]!=b[0]: return 1 if a[0]>b[0] else -1
    if a[1]==b[1]: return 0
    return 1 if a[1]<b[1] else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(x):
    R='A23456789TJQK'
    def best(h):
        for n in range(4,0,-1):
            cands=[]
            for sub in itertools.combinations(h,n):
                if len({c[0] for c in sub})>=n-1 and len({c[1] for c in sub})==n:
                    cands.append(sorted((R.index(c[0])+1 for c in sub), reverse=True))
            if cands: return (n, min(cands))
    a,b=best(x[0]),best(x[1])
    if a[0]!=b[0]: return 1 if a[0]>b[0] else -1
    if a[1]==b[1]: return 0
    return 1 if a[1]<b[1] else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)]]
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)

prompt:
A-A-3-4 in four suits beats a genuine king-high badugi.

Input: [hand_a, hand_b], four distinct cards each. A hand's value is its best subset with all ranks distinct and all suits distinct: more cards beat fewer; among equal sizes the lower subset (compared from its highest card down, ace low = 1) wins. Return 1, -1 or 0.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(x):
    R='A23456789TJQK'
    def best(h):
        for n in range(4,0,-1):
            cands=[]
            for sub in itertools.combinations(h,n):
                if len({c[0] for c in sub})==n and len({c[1] for c in sub})==n:
                    cands.append(sorted((R.index(c[0])+1 for c in sub), reverse=True))
            if cands: return (n, max(cands))
    a,b=best(x[0]),best(x[1])
    if a[0]!=b[0]: return 1 if a[0]>b[0] else -1
    if a[1]==b[1]: return 0
    return 1 if a[1]<b[1] else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(x):
    R='A23456789TJQK'
    def best(h):
        for n in range(4,0,-1):
            cands=[]
            for sub in itertools.combinations(h,n):
                if len({c[0] for c in sub})==n and len({c[1] for c in sub})==n:
                    cands.append(sorted((R.index(c[0])+1 for c in sub), reverse=True))
            if cands: return (n, cands[0])
    a,b=best(x[0]),best(x[1])
    if a[0]!=b[0]: return 1 if a[0]>b[0] else -1
    if a[1]==b[1]: return 0
    return 1 if a[1]<b[1] else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)],
 [('four-card badugi vs three', [['Ac', '2d', '3h', '4s'], ['Ac', '2c', '3h', '4s']], 1),
  ('paired rank different suits', [['Ac', 'Ad', '3h', '4s'], ['5c', '6d', '7h', 'Ks']], -1),
  ('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1)],
 [('lower badugi wins', [['Ac', '2d', '3h', '8s'], ['Ac', '2d', '4h', '7s']], -1),
  ('equal badugis', [['Ac', '2d', '3h', '4s'], ['Ad', '2c', '3s', '4h']], 0),
  ('best three-card subset', [['Kc', '2c', '3h', '4s'], ['5c', '6c', '7h', '8s']], 1),
  ('two-card hands', [['Ac', '2c', '3c', 'Kd'], ['4h', '5h', '6h', '7s']], -1),
  ('king high badugi vs three', [['Kc', 'Qd', 'Jh', 'Ts'], ['Ac', '2c', '3d', '4h']], 1),
  ('lowest card trap', [['Ac', '5d', '6h', '7s'], ['2c', '3d', '4h', '8s']], 1),
  ('one-card hands', [['Ac', '2c', '3c', '4c'], ['5d', '6d', '7d', '8d']], 1),
  ('suit pair plus rank pair', [['2c', '2d', '5c', '9h'], ['3c', '4c', '6d', 'Th']], 1)]]
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)

prompt:
A three-card hand is valued by its highest valid subset rather than its lowest.

Input: [hand_a, hand_b], four distinct cards each. A hand's value is its best subset with all ranks distinct and all suits distinct: more cards beat fewer; among equal sizes the lower subset (compared from its highest card down, ace low = 1) wins. Return 1, -1 or 0.

split: open-access