broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or vals==[14,5,4,3,2])
        flush=len({c[1] for c in h})==1
        if straight and flush: return (8,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka<kb else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1)],
 [('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1)],
 [('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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 collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or vals[0]-vals[4]==12)
        flush=len({c[1] for c in h})==1
        if straight and flush: return (8,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka<kb else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1)],
 [('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1)],
 [('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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-2-3-4-5 is scored as a straight, losing to king-high hands it should beat and never being compared as ace high.

Input: [hand_a, hand_b] five distinct cards each. Deuce-to-seven lowball: aces are always high, A-2-3-4-5 is not a straight, straights and flushes count against the hand, and the standard high-hand ordering is inverted so the weaker high hand wins. Return 1 if hand_a wins, -1 if hand_b wins, 0 for a tie.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and vals[0]-vals[4]==4
        flush=len({c[1] for c in h})==1
        if straight and flush: return (8,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka>kb else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0)],
 [('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1)],
 [('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and vals[0]-vals[4]==4
        flush=len({c[1] for c in h})==1
        if straight and flush: return (8,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka[0]<kb[0] else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0)],
 [('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1)],
 [('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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:
7-5-4-3-2 loses to a pair of deuces.

Input: [hand_a, hand_b] five distinct cards each. Deuce-to-seven lowball: aces are always high, A-2-3-4-5 is not a straight, straights and flushes count against the hand, and the standard high-hand ordering is inverted so the weaker high hand wins. Return 1 if hand_a wins, -1 if hand_b wins, 0 for a tie.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and vals[0]-vals[4]==4
        flush=len({c[1] for c in h})==1
        if straight and flush: return (4,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka<kb else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']],
   -1)],
 [('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1)],
 [('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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 collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and vals[0]-vals[4]==4
        flush=len({c[1] for c in h})==1
        if straight and flush: return (5,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka<kb else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']],
   -1)],
 [('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1)],
 [('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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:
2-3-4-5-6 suited beats a nine-low flush.

Input: [hand_a, hand_b] five distinct cards each. Deuce-to-seven lowball: aces are always high, A-2-3-4-5 is not a straight, straights and flushes count against the hand, and the standard high-hand ordering is inverted so the weaker high hand wins. Return 1 if hand_a wins, -1 if hand_b wins, 0 for a tie.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((1 if c[0]=='A' else R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and vals[0]-vals[4]==4
        flush=len({c[1] for c in h})==1
        if straight and flush: return (8,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka<kb else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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 collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=sorted((R.index(c[0])+2 for c in h))
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        straight=len(cnt)==5 and vals[0]-vals[4]==4
        flush=len({c[1] for c in h})==1
        if straight and flush: return (8,vals)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,vals)
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)
    ka,kb=key(x[0]),key(x[1])
    if ka==kb: return 0
    return 1 if ka<kb else -1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('tie', [['7h', '5d', '4c', '3s', '2h'], ['7c', '5h', '4d', '3c', '2d']], 0),
  ('ace high vs pair', [['Ah', 'Qd', '9c', '7s', '5h'], ['3h', '3d', '6c', '5s', '4h']], 1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1)],
 [('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('both pairs lower pair wins', [['4h', '4d', 'Kc', 'Qs', 'Jh'], ['5h', '5d', '2c', '3s', '7h']],
   1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace-deuce span vs pair', [['Ah', 'Jd', '8c', '6s', '2h'], ['4h', '4d', '6d', '8d', '9s']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('second tie', [['Kh', 'Jd', '9c', '6s', '3h'], ['Kc', 'Jh', '9d', '6c', '3d']], 0)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('wheel is ace high', [['Ah', '2d', '3c', '4s', '5h'], ['Kh', 'Qd', 'Jc', '9s', '8h']], -1),
  ('straight counts against', [['3h', '4d', '5c', '6s', '7h'], ['Kh', 'Qd', 'Jc', '9s', '7c']], -1),
  ('ace-king gap hand', [['Ah', 'Kd', '7c', '4s', '2h'], ['Qh', 'Jd', 'Tc', '8s', '6h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 1)],
 [('number one vs wheel', [['7h', '5d', '4c', '3s', '2h'], ['Ah', '2d', '3c', '4s', '5h']], 1),
  ('seven low vs eight low', [['8h', '6d', '4c', '3s', '2h'], ['7c', '6h', '4d', '3c', '2d']], -1),
  ('flush counts against', [['2h', '4h', '5h', '6h', '8h'], ['9c', '6d', '4d', '3c', '2d']], -1),
  ('pair loses to king high', [['2h', '2d', '4c', '5s', '7h'], ['Kh', '8d', '6c', '4s', '3h']], -1),
  ('straight flush vs flush', [['2c', '3c', '4c', '5c', '6c'], ['9d', '7d', '5d', '3d', '2d']], -1),
  ('wheel vs pair', [['Ah', '2d', '3c', '4s', '5h'], ['3h', '3d', '6c', '8s', '9h']], 1),
  ('ace high vs king high', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '8c']], -1),
  ('nine vs ten', [['9h', '7d', '5c', '3s', '2h'], ['Th', '4d', '3c', '6s', '2c']], 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:
Ace-high hands are scored as strong lows and beat seven-lows or king-lows.

Input: [hand_a, hand_b] five distinct cards each. Deuce-to-seven lowball: aces are always high, A-2-3-4-5 is not a straight, straights and flushes count against the hand, and the standard high-hand ordering is inverted so the weaker high hand wins. Return 1 if hand_a wins, -1 if hand_b wins, 0 for a tie.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    if len(x)!=2 or x[0]==x[1]: return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('empty rank', ['h', 'Kd'], 'invalid')],
 [('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')]]
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'
    if len(x)!=2 or x[0][:-1]==x[1][:-1]: return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('empty rank', ['h', 'Kd'], 'invalid')],
 [('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')]]
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:
"Ah" with "aH" is notated "AA" instead of being rejected.

Input: two hole cards as strings (rank may be "10"; rank and suit case-insensitive). Return canonical hold'em notation: pairs "QQ", otherwise higher rank first with "s" for suited or "o" for offsuit (e.g. "AKs", "T9o"). Return "invalid" for duplicate cards or unknown ranks.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], reverse=True)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], key=R.index)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Queen-ten is written "TQs" and ace-king "KAo".

Input: two hole cards as strings (rank may be "10"; rank and suit case-insensitive). Return canonical hold'em notation: pairs "QQ", otherwise higher rank first with "s" for suited or "o" for offsuit (e.g. "AKs", "T9o"). Return "invalid" for duplicate cards or unknown ranks.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if a==b: return a+b+'o'
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('pair of queens', ['Qh', 'Qs'], 'QQ'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')]]
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'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if x[0]==x[1]: return a+b
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('pair of queens', ['Qh', 'Qs'], 'QQ'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')]]
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 queens are written "QQo" and do not match range keys.

Input: two hole cards as strings (rank may be "10"; rank and suit case-insensitive). Return canonical hold'em notation: pairs "QQ", otherwise higher rank first with "s" for suited or "o" for offsuit (e.g. "AKs", "T9o"). Return "invalid" for duplicate cards or unknown ranks.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][1]==x[1][1] else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
 [('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
 [('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')]]
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'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in list(R) or b not in list(R): return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
 [('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')],
 [('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('ten first suited', ['10h', 'Jh'], 'JTs')]]
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:
"10h" with "Jh" is written "JTo".

Input: two hole cards as strings (rank may be "10"; rank and suit case-insensitive). Return canonical hold'em notation: pairs "QQ", otherwise higher rank first with "s" for suited or "o" for offsuit (e.g. "AKs", "T9o"). Return "invalid" for duplicate cards or unknown ranks.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if a not in R or b not in R: return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid')],
 [('exact duplicate', ['7c', '7c'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')]]
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'
    if len(x)!=2 or x[0].upper()==x[1].upper(): return 'invalid'
    def rank(c):
        t=c[:-1].upper()
        return 'T' if t=='10' else t
    a,b=rank(x[0]),rank(x[1])
    if not a or not b: return 'invalid'
    if a==b: return a+b
    hi,lo=sorted([a,b], key=R.index, reverse=True)
    return hi+lo+('s' if x[0][-1].lower()==x[1][-1].lower() else 'o')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('duplicate card case', ['Ah', 'aH'], 'invalid'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid')],
 [('nine ten mixed', ['9c', '10d'], 'T9o'), ('pair of queens', ['Qh', 'Qs'], 'QQ'),
  ('duplicate card case', ['Ah', 'aH'], 'invalid'), ('exact duplicate', ['7c', '7c'], 'invalid'),
  ('queen ten', ['Tc', 'Qc'], 'QTs'), ('lower case ranks', ['kd', 'js'], 'KJo'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid')],
 [('exact duplicate', ['7c', '7c'], 'invalid'), ('queen ten', ['Tc', 'Qc'], 'QTs'),
  ('lower case ranks', ['kd', 'js'], 'KJo'), ('suit case differs', ['Jh', 'TH'], 'JTs'),
  ('empty rank', ['h', 'Kd'], 'invalid'), ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('ten first suited', ['10h', 'Jh'], 'JTs'), ('deuce seven', ['2d', '7s'], '72o')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('suit case differs', ['Jh', 'TH'], 'JTs'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'), ('ten first suited', ['10h', 'Jh'], 'JTs'),
  ('deuce seven', ['2d', '7s'], '72o'), ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')],
 [('ace king suited', ['Ah', 'Kh'], 'AKs'), ('king ace offsuit order', ['Kd', 'Ah'], 'AKo'),
  ('ten nine suited with 10', ['10s', '9s'], 'T9s'), ('nine ten mixed', ['9c', '10d'], 'T9o'),
  ('pair of queens', ['Qh', 'Qs'], 'QQ'), ('empty rank', ['h', 'Kd'], 'invalid'),
  ('two-letter rank', ['KQh', '2d'], 'invalid'),
  ('pair of tens mixed tokens', ['10h', 'Td'], 'TT')]]
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 card with no rank or a rank token "KQ" produces a hand label instead of "invalid".

Input: two hole cards as strings (rank may be "10"; rank and suit case-insensitive). Return canonical hold'em notation: pairs "QQ", otherwise higher rank first with "s" for suited or "o" for offsuit (e.g. "AKs", "T9o"). Return "invalid" for duplicate cards or unknown ranks.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    classes=set()
    def add(h, suf):
        if h[0]==h[1]: classes.add(h)
        elif suf: classes.add(h+suf)
        else:
            classes.add(h+'s'); classes.add(h+'o')
    for tok in x.split(','):
        tok=tok.strip()
        if not tok: continue
        plus=tok.endswith('+')
        t=tok.rstrip('+')
        if '-' in t:
            a,b=t.split('-')
            if a[0]==a[1]:
                lo,hi=sorted([R.index(a[0]),R.index(b[0])])
                for i in range(lo,hi+1): add(R[i]*2,'')
            else:
                lo,hi=sorted([R.index(a[1]),R.index(b[1])])
                for i in range(lo,hi+1): add(a[0]+R[i],a[2:])
            continue
        if t[0]==t[1]:
            start=R.index(t[0])
            stop=len(R)-2 if plus else start
            for i in range(start,stop+1): add(R[i]*2,'')
        else:
            top=R.index(t[0]); k=R.index(t[1])
            stop=top-1 if plus else k
            for i in range(k,stop+1): add(t[0]+R[i],t[2:])
    total=0
    for c in classes:
        if c[0]==c[1]: total+=6
        elif c.endswith('s'): total+=4
        else: total+=12
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('reversed dash pairs', '77-TT', 24)],
 [('queens plus', 'QQ+', 18), ('dash kicker range', 'A9s-A6s', 16),
  ('dash pair range', 'TT-77', 24), ('reversed dash pairs', '77-TT', 24),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('aces only', 'AA', 6)],
 [('pairs plus', '77+', 48), ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16),
  ('single pair', '22', 6), ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6),
  ('suited connector plus', 'T9s+', 4), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('spaced tokens', 'QQ+, AKs', 22), ('mixed', 'JJ+,AQs+,KQo', 44),
  ('suited connector plus', 'T9s+', 4), ('trailing comma', 'KK+,', 12),
  ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('spaced tokens', 'QQ+, AKs', 22), ('mixed', 'JJ+,AQs+,KQo', 44),
  ('trailing comma', 'KK+,', 12)]]
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'
    classes=set()
    def add(h, suf):
        if h[0]==h[1]: classes.add(h)
        elif suf: classes.add(h+suf)
        else:
            classes.add(h+'s'); classes.add(h+'o')
    for tok in x.split(','):
        tok=tok.strip()
        if not tok: continue
        plus=tok.endswith('+')
        t=tok.rstrip('+')
        if '-' in t:
            a,b=t.split('-')
            if a[0]==a[1]:
                lo,hi=sorted([R.index(a[0]),R.index(b[0])])
                for i in range(lo,hi+1): add(R[i]*2,'')
            else:
                lo,hi=sorted([R.index(a[1]),R.index(b[1])])
                for i in range(lo,hi+1): add(a[0]+R[i],a[2:])
            continue
        if t[0]==t[1]:
            start=R.index(t[0])
            stop=len(R) if plus else start
            for i in range(start,stop+1): add(R[i]*2,'')
        else:
            top=R.index(t[0]); k=R.index(t[1])
            stop=top-1 if plus else k
            for i in range(k,stop+1): add(t[0]+R[i],t[2:])
    total=0
    for c in classes:
        if c[0]==c[1]: total+=6
        elif c.endswith('s'): total+=4
        else: total+=12
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('reversed dash pairs', '77-TT', 24)],
 [('queens plus', 'QQ+', 18), ('dash kicker range', 'A9s-A6s', 16),
  ('dash pair range', 'TT-77', 24), ('reversed dash pairs', '77-TT', 24),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('aces only', 'AA', 6)],
 [('pairs plus', '77+', 48), ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16),
  ('single pair', '22', 6), ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6),
  ('suited connector plus', 'T9s+', 4), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('spaced tokens', 'QQ+, AKs', 22), ('mixed', 'JJ+,AQs+,KQo', 44),
  ('suited connector plus', 'T9s+', 4), ('trailing comma', 'KK+,', 12),
  ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('spaced tokens', 'QQ+, AKs', 22), ('mixed', 'JJ+,AQs+,KQo', 44),
  ('trailing comma', 'KK+,', 12)]]
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:
"QQ+" counts 12 combos (QQ, KK) and "77+" misses pocket aces.

Input: a comma-separated hold'em range string. Tokens: pairs "77", "77+" (up to AA), "TT-77"; non-pairs "AKs"/"AKo"/"AK" (no suffix means both suited and offsuit), "A9s+" (kicker rises to one below the top card), "A9s-A6s" (inclusive). Whitespace around tokens is ignored. Duplicated classes count once. Return total combos: pair 6, suited 4, offsuit 12.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    classes=set()
    def add(h, suf):
        if h[0]==h[1]: classes.add(h)
        elif suf: classes.add(h+suf)
        else:
            classes.add(h+'s'); classes.add(h+'o')
    for tok in x.split(','):
        tok=tok.strip()
        if not tok: continue
        plus=tok.endswith('+')
        t=tok.rstrip('+')
        if '-' in t:
            a,b=t.split('-')
            if a[0]==a[1]:
                lo,hi=sorted([R.index(a[0]),R.index(b[0])])
                for i in range(lo,hi+1): add(R[i]*2,'')
            else:
                lo,hi=sorted([R.index(a[1]),R.index(b[1])])
                for i in range(lo,hi+1): add(a[0]+R[i],a[2:])
            continue
        if t[0]==t[1]:
            start=R.index(t[0])
            stop=len(R)-1 if plus else start
            for i in range(start,stop+1): add(R[i]*2,'')
        else:
            top=R.index(t[0]); k=R.index(t[1])
            stop=top if plus else k
            for i in range(k,stop+1): add(t[0]+R[i],t[2:])
    total=0
    for c in classes:
        if c[0]==c[1]: total+=6
        elif c.endswith('s'): total+=4
        else: total+=12
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('suited connector plus', 'T9s+', 4)],
 [('offsuit king plus', 'KTo+', 36), ('dash kicker range', 'A9s-A6s', 16),
  ('dash pair range', 'TT-77', 24), ('reversed dash pairs', '77-TT', 24),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('suited connector plus', 'T9s+', 4)],
 [('suited ace plus', 'A9s+', 20), ('offsuit king plus', 'KTo+', 36),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('suited connector plus', 'T9s+', 4)],
 [('pairs plus', '77+', 48), ('suited ace plus', 'A9s+', 20), ('offsuit king plus', 'KTo+', 36),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('suited connector plus', 'T9s+', 4),
  ('trailing comma', 'KK+,', 12), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('suited connector plus', 'T9s+', 4),
  ('reversed kicker dash', 'K6o-K9o', 48)]]
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'
    classes=set()
    def add(h, suf):
        if h[0]==h[1]: classes.add(h)
        elif suf: classes.add(h+suf)
        else:
            classes.add(h+'s'); classes.add(h+'o')
    for tok in x.split(','):
        tok=tok.strip()
        if not tok: continue
        plus=tok.endswith('+')
        t=tok.rstrip('+')
        if '-' in t:
            a,b=t.split('-')
            if a[0]==a[1]:
                lo,hi=sorted([R.index(a[0]),R.index(b[0])])
                for i in range(lo,hi+1): add(R[i]*2,'')
            else:
                lo,hi=sorted([R.index(a[1]),R.index(b[1])])
                for i in range(lo,hi+1): add(a[0]+R[i],a[2:])
            continue
        if t[0]==t[1]:
            start=R.index(t[0])
            stop=len(R)-1 if plus else start
            for i in range(start,stop+1): add(R[i]*2,'')
        else:
            top=R.index(t[0]); k=R.index(t[1])
            stop=len(R)-2 if plus else k
            for i in range(k,stop+1): add(t[0]+R[i],t[2:])
    total=0
    for c in classes:
        if c[0]==c[1]: total+=6
        elif c.endswith('s'): total+=4
        else: total+=12
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('suited connector plus', 'T9s+', 4)],
 [('offsuit king plus', 'KTo+', 36), ('dash kicker range', 'A9s-A6s', 16),
  ('dash pair range', 'TT-77', 24), ('reversed dash pairs', '77-TT', 24),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('suited connector plus', 'T9s+', 4)],
 [('suited ace plus', 'A9s+', 20), ('offsuit king plus', 'KTo+', 36),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('suited connector plus', 'T9s+', 4)],
 [('pairs plus', '77+', 48), ('suited ace plus', 'A9s+', 20), ('offsuit king plus', 'KTo+', 36),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('suited connector plus', 'T9s+', 4),
  ('trailing comma', 'KK+,', 12), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('suited connector plus', 'T9s+', 4),
  ('reversed kicker dash', 'K6o-K9o', 48)]]
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:
"A9s+" includes an "AAs" class counted as a pocket pair and "KTo+" includes AK-type classes.

Input: a comma-separated hold'em range string. Tokens: pairs "77", "77+" (up to AA), "TT-77"; non-pairs "AKs"/"AKo"/"AK" (no suffix means both suited and offsuit), "A9s+" (kicker rises to one below the top card), "A9s-A6s" (inclusive). Whitespace around tokens is ignored. Duplicated classes count once. Return total combos: pair 6, suited 4, offsuit 12.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    classes=set()
    def add(h, suf):
        if h[0]==h[1]: classes.add(h)
        elif suf: classes.add(h+suf)
        else:
            classes.add(h+'s'); classes.add(h+'o')
    for tok in x.split(','):
        tok=tok.strip()
        if not tok: continue
        plus=tok.endswith('+')
        t=tok.rstrip('+')
        if '-' in t:
            a,b=t.split('-')
            if a[0]==a[1]:
                lo,hi=sorted([R.index(a[0]),R.index(b[0])])
                for i in range(lo,hi+1): add(R[i]*2,'')
            else:
                lo,hi=sorted([R.index(a[1]),R.index(b[1])])
                for i in range(lo,hi): add(a[0]+R[i],a[2:])
            continue
        if t[0]==t[1]:
            start=R.index(t[0])
            stop=len(R)-1 if plus else start
            for i in range(start,stop+1): add(R[i]*2,'')
        else:
            top=R.index(t[0]); k=R.index(t[1])
            stop=top-1 if plus else k
            for i in range(k,stop+1): add(t[0]+R[i],t[2:])
    total=0
    for c in classes:
        if c[0]==c[1]: total+=6
        elif c.endswith('s'): total+=4
        else: total+=12
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('reversed kicker dash', 'K6o-K9o', 48)],
 [('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('reversed dash pairs', '77-TT', 24), ('spaced tokens', 'QQ+, AKs', 22),
  ('overlap dedupe', 'AKs,AK', 16), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('dash kicker range', 'A9s-A6s', 16), ('reversed dash pairs', '77-TT', 24),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('dash kicker range', 'A9s-A6s', 16), ('single pair', '22', 6),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('suited connector plus', 'T9s+', 4),
  ('trailing comma', 'KK+,', 12), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('dash kicker range', 'A9s-A6s', 16),
  ('suited connector plus', 'T9s+', 4), ('trailing comma', 'KK+,', 12),
  ('reversed kicker dash', 'K6o-K9o', 48)]]
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'
    classes=set()
    def add(h, suf):
        if h[0]==h[1]: classes.add(h)
        elif suf: classes.add(h+suf)
        else:
            classes.add(h+'s'); classes.add(h+'o')
    for tok in x.split(','):
        tok=tok.strip()
        if not tok: continue
        plus=tok.endswith('+')
        t=tok.rstrip('+')
        if '-' in t:
            a,b=t.split('-')
            if a[0]==a[1]:
                lo,hi=sorted([R.index(a[0]),R.index(b[0])])
                for i in range(lo,hi+1): add(R[i]*2,'')
            else:
                lo,hi=sorted([R.index(a[1]),R.index(b[1])])
                for i in range(lo+1,hi+1): add(a[0]+R[i],a[2:])
            continue
        if t[0]==t[1]:
            start=R.index(t[0])
            stop=len(R)-1 if plus else start
            for i in range(start,stop+1): add(R[i]*2,'')
        else:
            top=R.index(t[0]); k=R.index(t[1])
            stop=top-1 if plus else k
            for i in range(k,stop+1): add(t[0]+R[i],t[2:])
    total=0
    for c in classes:
        if c[0]==c[1]: total+=6
        elif c.endswith('s'): total+=4
        else: total+=12
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('reversed kicker dash', 'K6o-K9o', 48)],
 [('offsuit king plus', 'KTo+', 36), ('unsuffixed class', 'AK', 16),
  ('dash kicker range', 'A9s-A6s', 16), ('dash pair range', 'TT-77', 24),
  ('reversed dash pairs', '77-TT', 24), ('spaced tokens', 'QQ+, AKs', 22),
  ('overlap dedupe', 'AKs,AK', 16), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('dash kicker range', 'A9s-A6s', 16), ('reversed dash pairs', '77-TT', 24),
  ('spaced tokens', 'QQ+, AKs', 22), ('overlap dedupe', 'AKs,AK', 16), ('single pair', '22', 6),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('dash kicker range', 'A9s-A6s', 16), ('single pair', '22', 6),
  ('mixed', 'JJ+,AQs+,KQo', 44), ('aces only', 'AA', 6), ('suited connector plus', 'T9s+', 4),
  ('trailing comma', 'KK+,', 12), ('reversed kicker dash', 'K6o-K9o', 48)],
 [('pairs plus', '77+', 48), ('queens plus', 'QQ+', 18), ('suited ace plus', 'A9s+', 20),
  ('offsuit king plus', 'KTo+', 36), ('dash kicker range', 'A9s-A6s', 16),
  ('suited connector plus', 'T9s+', 4), ('trailing comma', 'KK+,', 12),
  ('reversed kicker dash', 'K6o-K9o', 48)]]
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:
"A9s-A6s" counts three classes instead of four.

Input: a comma-separated hold'em range string. Tokens: pairs "77", "77+" (up to AA), "TT-77"; non-pairs "AKs"/"AKo"/"AK" (no suffix means both suited and offsuit), "A9s+" (kicker rises to one below the top card), "A9s-A6s" (inclusive). Whitespace around tokens is ignored. Duplicated classes count once. Return total combos: pair 6, suited 4, offsuit 12.

split: open-access