broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    NAME={2:'Two',3:'Three',4:'Four',5:'Five',6:'Six',7:'Seven',8:'Eight',9:'Nine',10:'Ten',11:'Jack',12:'Queen',13:'King',14:'Ace'}
    def pl(v): return {2:'Deuces',6:'Sixes'}.get(v, NAME[v]+'s')
    vals=sorted((R.index(c[0])+2 for c in x), reverse=True)
    cnt=collections.Counter(vals)
    groups=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
    shape=sorted(cnt.values(), reverse=True)
    flush=len({c[1] for c in x})==1
    wheel=vals==[14,5,4,3,2]
    straight=len(cnt)==5 and (vals[0]-vals[4]==4 or wheel)
    top=5 if wheel else vals[0]
    if straight and flush: return 'Royal Flush' if top==14 else 'Straight Flush, %s high' % NAME[top]
    if shape==[4,1]: return 'Four %s' % pl(groups[0])
    if shape==[3,2]: return 'Full House, %s full of %s' % (pl(groups[0]), pl(groups[1]))
    if flush: return 'Flush, %s high' % NAME[vals[0]]
    if straight: return 'Straight, %s high' % NAME[top]
    if shape==[3,1,1]: return 'Three %s' % pl(groups[0])
    if shape==[2,2,1]: return 'Two Pair, %s and %s' % (pl(groups[0]), pl(groups[-1]))
    if shape==[2,1,1,1]: return 'Pair of %s' % pl(groups[0])
    return 'High Card, %s' % NAME[vals[0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens')],
 [('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives')],
 [('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')]]
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'
    NAME={2:'Two',3:'Three',4:'Four',5:'Five',6:'Six',7:'Seven',8:'Eight',9:'Nine',10:'Ten',11:'Jack',12:'Queen',13:'King',14:'Ace'}
    def pl(v): return {2:'Deuces',6:'Sixes'}.get(v, NAME[v]+'s')
    vals=sorted((R.index(c[0])+2 for c in x), reverse=True)
    cnt=collections.Counter(vals)
    groups=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
    shape=sorted(cnt.values(), reverse=True)
    flush=len({c[1] for c in x})==1
    wheel=vals==[14,5,4,3,2]
    straight=len(cnt)==5 and (vals[0]-vals[4]==4 or wheel)
    top=5 if wheel else vals[0]
    if straight and flush: return 'Royal Flush' if top==14 else 'Straight Flush, %s high' % NAME[top]
    if shape==[4,1]: return 'Four %s' % pl(groups[0])
    if shape==[3,2]: return 'Full House, %s full of %s' % (pl(groups[0]), pl(groups[1]))
    if flush: return 'Flush, %s high' % NAME[vals[0]]
    if straight: return 'Straight, %s high' % NAME[top]
    if shape==[3,1,1]: return 'Three %s' % pl(groups[0])
    if shape==[2,2,1]: return 'Two Pair, %s and %s' % (pl(vals[0]), pl(vals[2]))
    if shape==[2,1,1,1]: return 'Pair of %s' % pl(groups[0])
    return 'High Card, %s' % NAME[vals[0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens')],
 [('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives')],
 [('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')]]
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:
Kings and sevens with a deuce kicker is announced "Two Pair, Kings and Deuces".

Input: five distinct cards. Return the showdown announcement: "Royal Flush", "Straight Flush, <top> high", "Four <plural>", "Full House, <trips plural> full of <pair plural>", "Flush, <top> high", "Straight, <top> high" (wheel is Five high), "Three <plural>", "Two Pair, <higher plural> and <lower plural>", "Pair of <plural>", "High Card, <top>". Rank names Two..Ace; plurals add "s" except Deuces and Sixes.

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'
    NAME={2:'Two',3:'Three',4:'Four',5:'Five',6:'Six',7:'Seven',8:'Eight',9:'Nine',10:'Ten',11:'Jack',12:'Queen',13:'King',14:'Ace'}
    def pl(v): return {2:'Deuces',6:'Sixes'}.get(v, NAME[v]+'s')
    vals=sorted((R.index(c[0])+2 for c in x), reverse=True)
    cnt=collections.Counter(vals)
    groups=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
    shape=sorted(cnt.values(), reverse=True)
    flush=len({c[1] for c in x})==1
    wheel=vals==[14,5,4,3,2]
    straight=len(cnt)==5 and (vals[0]-vals[4]==4 or wheel)
    top=5 if wheel else vals[0]
    if straight and flush: return 'Royal Flush' if top==14 else 'Straight Flush, %s high' % NAME[top]
    if shape==[4,1]: return 'Four %s' % pl(groups[0])
    if shape==[3,2]: return 'Full House, %s full of %s' % (pl(groups[0]), pl(groups[1]))
    if flush: return 'Flush, %s high' % NAME[vals[0]]
    if straight: return 'Straight, %s high' % NAME[top]
    if shape==[3,1,1]: return 'Three %s' % pl(groups[0])
    if shape==[2,2,1]: return 'Two Pair, %s and %s' % (pl(groups[0]), pl(groups[1]))
    if shape==[2,1,1,1]: return 'Pair of %s' % pl(vals[0])
    return 'High Card, %s' % NAME[vals[0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes')],
 [('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')]]
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'
    NAME={2:'Two',3:'Three',4:'Four',5:'Five',6:'Six',7:'Seven',8:'Eight',9:'Nine',10:'Ten',11:'Jack',12:'Queen',13:'King',14:'Ace'}
    def pl(v): return {2:'Deuces',6:'Sixes'}.get(v, NAME[v]+'s')
    vals=sorted((R.index(c[0])+2 for c in x), reverse=True)
    cnt=collections.Counter(vals)
    groups=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
    shape=sorted(cnt.values(), reverse=True)
    flush=len({c[1] for c in x})==1
    wheel=vals==[14,5,4,3,2]
    straight=len(cnt)==5 and (vals[0]-vals[4]==4 or wheel)
    top=5 if wheel else vals[0]
    if straight and flush: return 'Royal Flush' if top==14 else 'Straight Flush, %s high' % NAME[top]
    if shape==[4,1]: return 'Four %s' % pl(groups[0])
    if shape==[3,2]: return 'Full House, %s full of %s' % (pl(groups[0]), pl(groups[1]))
    if flush: return 'Flush, %s high' % NAME[vals[0]]
    if straight: return 'Straight, %s high' % NAME[top]
    if shape==[3,1,1]: return 'Three %s' % pl(groups[0])
    if shape==[2,2,1]: return 'Two Pair, %s and %s' % (pl(groups[0]), pl(groups[1]))
    if shape==[2,1,1,1]: return 'Pair of %s' % pl(vals[1])
    return 'High Card, %s' % NAME[vals[0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes')],
 [('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('threes full of kings', ['3h', '3d', '3c', 'Ks', 'Kh'], 'Full House, Threes full of Kings'),
  ('kings full of threes', ['Kh', 'Kd', 'Kc', '3s', '3h'], 'Full House, Kings full of Threes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('two pair ace kicker', ['Ah', 'Kd', 'Kc', '7s', '7h'], 'Two Pair, Kings and Sevens'),
  ('two pair low kicker', ['Kh', 'Kd', '7c', '7s', '2h'], 'Two Pair, Kings and Sevens'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('high card', ['Ah', 'Jd', '8c', '5s', '3h'], 'High Card, Ace'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('four nines', ['9h', '9d', '9c', '9s', '2h'], 'Four Nines'),
  ('flush', ['2c', '7c', '9c', 'Jc', 'Qc'], 'Flush, Queen high'),
  ('six-high straight', ['2h', '3d', '4c', '5s', '6h'], 'Straight, Six high'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')],
 [('pair of sixes', ['6h', '6d', 'Kc', '9s', '2h'], 'Pair of Sixes'),
  ('pair of deuces', ['2h', '2d', 'Kc', '9s', '5h'], 'Pair of Deuces'),
  ('wheel', ['Ah', '2d', '3c', '4s', '5h'], 'Straight, Five high'),
  ('steel wheel', ['As', '2s', '3s', '4s', '5s'], 'Straight Flush, Five high'),
  ('royal', ['Th', 'Jh', 'Qh', 'Kh', 'Ah'], 'Royal Flush'),
  ('king-high straight flush', ['9d', 'Td', 'Jd', 'Qd', 'Kd'], 'Straight Flush, King high'),
  ('pair below high cards', ['Ah', 'Kd', '5c', '5s', '9h'], 'Pair of Fives'),
  ('three sixes', ['6h', '6d', '6c', 'Ks', '2h'], 'Three Sixes')]]
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 pair of fives with an ace is announced "Pair of Aces".

Input: five distinct cards. Return the showdown announcement: "Royal Flush", "Straight Flush, <top> high", "Four <plural>", "Full House, <trips plural> full of <pair plural>", "Flush, <top> high", "Straight, <top> high" (wheel is Five high), "Three <plural>", "Two Pair, <higher plural> and <lower plural>", "Pair of <plural>", "High Card, <top>". Rank names Two..Ace; plurals add "s" except Deuces and Sixes.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,5,4,3,2]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals[1:]==[9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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-6-7-8-9 is scored as ace high and loses to trips.

Input: [hand_a, hand_b], five cards each from a 36-card deck (ranks 6-A). Short-deck ranking: straight flush > quads > flush > full house > straight > trips > two pair > pair > high card. A-6-7-8-9 is the lowest straight (nine high). A card below 6 in either hand makes the result "invalid". Return 1, -1, 0 or "invalid".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (5,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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:
Kings full of sevens beats an ace-high flush.

Input: [hand_a, hand_b], five cards each from a 36-card deck (ranks 6-A). Short-deck ranking: straight flush > quads > flush > full house > straight > trips > two pair > pair > high card. A-6-7-8-9 is the lowest straight (nine high). A card below 6 in either hand makes the result "invalid". Return 1, -1, 0 or "invalid".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+5 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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:
The ace scores as 10, so the A-6-7-8-9 pattern never matches.

Input: [hand_a, hand_b], five cards each from a 36-card deck (ranks 6-A). Short-deck ranking: straight flush > quads > flush > full house > straight > trips > two pair > pair > high card. A-6-7-8-9 is the lowest straight (nine high). A card below 6 in either hand makes the result "invalid". Return 1, -1, 0 or "invalid".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='6789TJQKA'
    for c in x[0]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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='6789TJQKA'
    for c in x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[9 if low else vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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 five in hand_b is evaluated instead of reported invalid.

Input: [hand_a, hand_b], five cards each from a 36-card deck (ranks 6-A). Short-deck ranking: straight flush > quads > flush > full house > straight > trips > two pair > pair > high card. A-6-7-8-9 is the lowest straight (nine high). A card below 6 in either hand makes the result "invalid". Return 1, -1, 0 or "invalid".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=[vals[0]]
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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='6789TJQKA'
    for c in x[0]+x[1]:
        if c[0] not in R: return 'invalid'
    def key(h):
        vals=sorted((R.index(c[0])+6 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)
        flush=len({c[1] for c in h})==1
        low=vals==[14,9,8,7,6]
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or low)
        if straight: order=vals
        if straight and flush: return (8,order)
        if shape==[4,1]: return (7,order)
        if flush: return (6,vals)
        if shape==[3,2]: return (5,order)
        if straight: return (4,order)
        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)
    a,b=key(x[0]),key(x[1])
    return (a>b)-(a<b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1)],
 [('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('pair vs pair kicker', [['Kh', 'Kd', 'Qc', '7s', '6h'], ['Ks', 'Kc', 'Jc', 'Ts', '9h']], 1),
  ('tie straights', [['6h', '7d', '8c', '9s', 'Th'], ['6c', '7h', '8d', '9h', 'Tc']], 0),
  ('quads beat flush', [['9h', '9d', '9c', '9s', '6h'], ['6d', '8d', 'Td', 'Jd', 'Ad']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', 'As', 'Kh'], ['Ah', 'Ad', 'Kc', 'Ks', 'Qh']], 1)],
 [('flush beats full house', [['6h', '9h', 'Jh', 'Qh', 'Ah'], ['Kh', 'Kd', 'Kc', '7s', '7h']], 1),
  ('full house loses to flush', [['Ks', 'Kd', 'Kc', '7s', '7c'], ['6d', '8d', 'Td', 'Jd', 'Qd']],
   -1),
  ('short wheel is a straight', [['Ah', '6d', '7c', '8s', '9h'], ['Qh', 'Qd', 'Qc', '7s', '6h']],
   1),
  ('short wheel vs six-ten', [['Ah', '6d', '7c', '8s', '9h'], ['6h', '7d', '8c', '9s', 'Th']], -1),
  ('jack-nine gap not a straight', [['Jh', '6d', '7c', '8s', '9h'], ['Ah', 'Ad', '7s', '8h', 'Tc']],
   -1),
  ('low card in hand b', [['Ah', 'Kd', 'Qc', 'Js', '9h'], ['5h', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('low card in hand a', [['2h', 'Kd', 'Qc', 'Js', '9h'], ['Th', '6d', '7c', '8s', '9s']],
   'invalid'),
  ('broadway vs short wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['Ad', '6c', '7d', '8h', '9c']], 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:
The short-deck wheel beats broadway and six-to-ten straights.

Input: [hand_a, hand_b], five cards each from a 36-card deck (ranks 6-A). Short-deck ranking: straight flush > quads > flush > full house > straight > trips > two pair > pair > high card. A-6-7-8-9 is the lowest straight (nine high). A card below 6 in either hand makes the result "invalid". Return 1, -1, 0 or "invalid".

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'; S='shdc'
    razz=x['variant']=='razz'
    def rv(c):
        if razz and c[0]=='A': return 1
        return R.index(c[0])+2
    def k(p):
        c=x['up'][p]
        return (rv(c), S.index(c[1]))
    players=sorted(x['up'])
    return max(players, key=k) if razz else min(players, key=k)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b')],
 [('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'; S='dchs'
    razz=x['variant']=='razz'
    def rv(c):
        if razz and c[0]=='A': return 1
        return R.index(c[0])+2
    def k(p):
        c=x['up'][p]
        return (rv(c), S.index(c[1]))
    players=sorted(x['up'])
    return max(players, key=k) if razz else min(players, key=k)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b')],
 [('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
With two deuces showing, the deuce of hearts brings in instead of the deuce of clubs.

Input: {"variant": "stud", "stud8" or "razz", "up": {player: door card}}. In stud and stud8 the lowest door card brings in (ace high); ties are broken by suit with clubs lowest, then diamonds, hearts, spades. In razz the highest door card brings in (ace low), ties going to the highest suit. Return the bring-in player.

split: open-access


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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'; S='cdhs'
    razz=x['variant']=='razz'
    def rv(c):
        if c[0]=='A' and not razz: return 1
        return R.index(c[0])+2
    def k(p):
        c=x['up'][p]
        return (rv(c), S.index(c[1]))
    players=sorted(x['up'])
    return max(players, key=k) if razz else min(players, key=k)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b')],
 [('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b')],
 [('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    R='23456789TJQKA'; S='cdhs'
    razz=x['variant']=='razz'
    def rv(c):
        if c[0]=='A': return 1
        return R.index(c[0])+2
    def k(p):
        c=x['up'][p]
        return (rv(c), S.index(c[1]))
    players=sorted(x['up'])
    return max(players, key=k) if razz else min(players, key=k)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b')],
 [('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('razz heart vs diamond', {'up': {'a': 'Qd', 'b': 'Qh', 'c': '2s'}, 'variant': 'razz'}, 'b')],
 [('lowest deuce', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace vs deuce', {'up': {'a': 'Ah', 'b': '2d', 'c': '5s'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b')],
 [('deuce suit tie', {'up': {'a': '2h', 'b': '2c', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('ace is high in stud', {'up': {'a': 'Ah', 'b': '3d', 'c': '9s'}, 'variant': 'stud'}, 'b'),
  ('razz ace low', {'up': {'a': 'Ah', 'b': '3d', 'c': 'Ks'}, 'variant': 'razz'}, 'c'),
  ('razz suit tie', {'up': {'a': 'Kc', 'b': 'Ks', 'c': '5s'}, 'variant': 'razz'}, 'b'),
  ('stud8 uses stud rule', {'up': {'a': 'Kh', 'b': '2d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('stud8 ace high', {'up': {'a': 'Ad', 'b': '4d', 'c': '9s'}, 'variant': 'stud8'}, 'b'),
  ('spade vs heart tie stud', {'up': {'a': '4s', 'b': '4h', 'c': 'Js'}, 'variant': 'stud'}, 'b'),
  ('diamond vs club tie stud', {'up': {'a': '5d', 'b': '5c'}, 'variant': 'stud'}, 'b')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An ace door card brings in in seven-card stud, and a king does not bring in against an ace in razz.

Input: {"variant": "stud", "stud8" or "razz", "up": {player: door card}}. In stud and stud8 the lowest door card brings in (ace high); ties are broken by suit with clubs lowest, then diamonds, hearts, spades. In razz the highest door card brings in (ace low), ties going to the highest suit. Return the bring-in player.

split: open-access