broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[1,2,3,4,5]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq[:4]==[2,3,4,5]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A-2-3-4-5 is reported as high card and the steel wheel as a plain flush.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight or flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush')],
 [('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if flush and len(uniq)==5: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush')],
 [('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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:
Plain flushes and plain straights are both labelled straight flush.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt[0]==3: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt[0]==3 and len(cnt)<=3: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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:
Three sevens with two unpaired kickers are labelled full house.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt[0]==2 and len(cnt)<=4: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if 2 in cnt: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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 single pair of nines with three unpaired cards is labelled two pair.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

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'
    vals=sorted((R.index(c[0].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1])+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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:
Hands containing "10h" fail to evaluate while "Th" works.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1] for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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:
Five hearts written as "2H" and "7h" are reported as high card.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=suits.count(suits[0])>=4
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=suits[0]==suits[-1]
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]==4: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush')],
 [('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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:
Four hearts and a spade are reported as a flush.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]>=3 and len(cnt)==2: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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'
    vals=sorted((R.index('T' if c[:-1]=='10' else c[:-1].upper())+2 for c in x), reverse=True)
    suits=[c[-1].lower() for c in x]
    cnt=sorted(collections.Counter(vals).values(), reverse=True)
    flush=len(set(suits))==1
    uniq=sorted(set(vals))
    straight=False
    if len(uniq)==5:
        if uniq[4]-uniq[0]==4: straight=True
        elif uniq==[2,3,4,5,14]: straight=True
    if straight and flush: return 'straight flush'
    if cnt[0]>=3 and cnt[-1]<=2: return 'four of a kind'
    if cnt==[3,2]: return 'full house'
    if flush: return 'flush'
    if straight: return 'straight'
    if cnt[0]==3: return 'three of a kind'
    if cnt==[2,2,1]: return 'two pair'
    if cnt[0]==2: return 'one pair'
    return 'high card'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('wheel straight flush', ['As', '2s', '3s', '4s', '5s'], 'straight flush'),
  ('four to wheel plus nine', ['2h', '3d', '4c', '5s', '9h'], 'high card'),
  ('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house')],
 [('four to wheel plus king', ['2h', '3d', '4c', '5s', 'Kh'], 'high card'),
  ('plain flush', ['2h', '7h', '9h', 'Jh', 'Kh'], 'flush'),
  ('broadway', ['Th', 'Jd', 'Qc', 'Ks', 'Ah'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('one pair', ['9h', '9d', '4c', 'Ks', '2h'], 'one pair'),
  ('two pair', ['9h', '9d', '4c', '4s', '2h'], 'two pair'),
  ('ten written as 10', ['10h', 'Jd', 'Qc', 'Ks', '9h'], 'straight'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card')],
 [('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('lower-case ranks', ['kd', 'kh', '3c', '3s', '8h'], 'two pair'),
  ('mixed-case suits flush', ['2H', '7h', '9h', 'JH', 'Kh'], 'flush'),
  ('four-flush only', ['2h', '7h', '9h', 'Jh', 'Ks'], 'high card'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush')],
 [('wheel straight', ['Ah', '2d', '3c', '4s', '5h'], 'straight'),
  ('trips', ['7h', '7d', '7c', 'Ks', '2h'], 'three of a kind'),
  ('full house', ['7h', '7d', '7c', 'Ks', 'Kh'], 'full house'),
  ('quads', ['6h', '6d', '6c', '6s', '2h'], 'four of a kind'),
  ('high card', ['2h', '7d', '9c', 'Js', 'Kh'], 'high card'),
  ('straight flush middle', ['5d', '6d', '7d', '8d', '9d'], 'straight flush'),
  ('ten flush with 10 token', ['10c', '2c', '5c', '8c', 'Qc'], 'flush'),
  ('flush ends match only', ['2h', '7d', '9h', 'Jc', 'Kh'], 'high card')]]
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:
Sevens full of kings is labelled four of a kind.

Input: five distinct cards as rank+suit strings; ranks 2-9, T or 10, J, Q, K, A (case-insensitive), suits c/d/h/s (case-insensitive). Return the standard five-card category name in lower case; A-2-3-4-5 is a straight; royal flush is reported as "straight flush".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=[R.index(c[0])+2 for c in h]
        cnt=collections.Counter(vals)
        groups=sorted(cnt.items(), key=lambda kv:(kv[1],kv[0]), reverse=True)
        ranks=[v for v,n in groups]
        shape=[n for v,n in groups]
        flush=len({c[1] for c in h})==1
        straight=len(cnt)==5 and (max(vals)-min(vals)==4 or sorted(vals)==[2,3,4,5,14])
        if straight:
            ranks=[max(vals)]
        if straight and flush: cat=8
        elif shape==[4,1]: cat=7
        elif shape==[3,2]: cat=6
        elif flush: cat=5
        elif straight: cat=4
        elif shape==[3,1,1]: cat=3
        elif shape==[2,2,1]: cat=2
        elif shape==[2,1,1,1]: cat=1
        else: cat=0
        return (cat, ranks)
    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 = [[('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']],
   -1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']], -1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('two pair vs paired span', [['Jh', 'Jd', '2c', '2s', 'Kh'], ['8h', '8d', '6c', '7s', '9h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', '2s', '3h'], ['Ah', 'Ad', 'Kc', 'Ks', '2h']], 1),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=[R.index(c[0])+2 for c in h]
        cnt=collections.Counter(vals)
        groups=sorted(cnt.items(), key=lambda kv:(kv[1],kv[0]), reverse=True)
        ranks=[v for v,n in groups]
        shape=[n for v,n in groups]
        flush=len({c[1] for c in h})==1
        straight=len(cnt)==5 and (max(vals)-min(vals)==4 or sorted(vals)==[2,3,4,5,14])
        if straight:
            ranks=sorted(vals, reverse=True)
        if straight and flush: cat=8
        elif shape==[4,1]: cat=7
        elif shape==[3,2]: cat=6
        elif flush: cat=5
        elif straight: cat=4
        elif shape==[3,1,1]: cat=3
        elif shape==[2,2,1]: cat=2
        elif shape==[2,1,1,1]: cat=1
        else: cat=0
        return (cat, ranks)
    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 = [[('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']],
   -1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']], -1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('two pair vs paired span', [['Jh', 'Jd', '2c', '2s', 'Kh'], ['8h', '8d', '6c', '7s', '9h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', '2s', '3h'], ['Ah', 'Ad', 'Kc', 'Ks', '2h']], 1),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A-2-3-4-5 beats 2-3-4-5-6 at showdown.

Input: [hand_a, hand_b], each five distinct cards "Rs" (ranks 23456789TJQKA, suits cdhs). Return 1 if hand_a wins, -1 if hand_b wins, 0 for a split. Categories rank in the standard order; within a category compare rank groups by (group size, rank) descending; a wheel straight is five-high; suits never break ties.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=[R.index(c[0])+2 for c in h]
        cnt=collections.Counter(vals)
        groups=sorted(cnt.items(), key=lambda kv:kv[0], reverse=True)
        ranks=[v for v,n in groups]
        shape=[n for v,n in groups]
        flush=len({c[1] for c in h})==1
        straight=len(cnt)==5 and (max(vals)-min(vals)==4 or sorted(vals)==[2,3,4,5,14])
        if straight:
            ranks=[5] if sorted(vals)==[2,3,4,5,14] else [max(vals)]
        if straight and flush: cat=8
        elif shape==[4,1]: cat=7
        elif shape==[3,2]: cat=6
        elif flush: cat=5
        elif straight: cat=4
        elif shape==[3,1,1]: cat=3
        elif shape==[2,2,1]: cat=2
        elif shape==[2,1,1,1]: cat=1
        else: cat=0
        return (cat, ranks)
    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 = [[('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1)],
 [('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']], -1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('two pair vs paired span', [['Jh', 'Jd', '2c', '2s', 'Kh'], ['8h', '8d', '6c', '7s', '9h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']],
   1)],
 [('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']], -1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('two pair vs paired span', [['Jh', 'Jd', '2c', '2s', 'Kh'], ['8h', '8d', '6c', '7s', '9h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', '2s', '3h'], ['Ah', 'Ad', 'Kc', 'Ks', '2h']], 1),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1)],
 [('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', '2s', '3h'], ['Ah', 'Ad', 'Kc', 'Ks', '2h']], 1),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key(h):
        vals=[R.index(c[0])+2 for c in h]
        cnt=collections.Counter(vals)
        groups=sorted(cnt.items(), key=lambda kv:(kv[0],kv[1]), reverse=True)
        ranks=[v for v,n in groups]
        shape=[n for v,n in groups]
        flush=len({c[1] for c in h})==1
        straight=len(cnt)==5 and (max(vals)-min(vals)==4 or sorted(vals)==[2,3,4,5,14])
        if straight:
            ranks=[5] if sorted(vals)==[2,3,4,5,14] else [max(vals)]
        if straight and flush: cat=8
        elif shape==[4,1]: cat=7
        elif shape==[3,2]: cat=6
        elif flush: cat=5
        elif straight: cat=4
        elif shape==[3,1,1]: cat=3
        elif shape==[2,2,1]: cat=2
        elif shape==[2,1,1,1]: cat=1
        else: cat=0
        return (cat, ranks)
    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 = [[('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1)],
 [('identical ranks different suits',
   [['Ah', 'Kd', '9c', '7s', '4h'], ['As', 'Kc', '9d', '7h', '4d']], 0),
  ('split straights', [['9h', 'Td', 'Jc', 'Qs', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 0),
  ('flush beats straight', [['2h', '7h', '9h', 'Jh', 'Kh'], ['9s', 'Tc', 'Jd', 'Qh', 'Kd']], 1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']], -1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('two pair vs paired span', [['Jh', 'Jd', '2c', '2s', 'Kh'], ['8h', '8d', '6c', '7s', '9h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']],
   1)],
 [('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('straight loses to flush', [['9s', 'Tc', 'Jd', 'Qh', 'Kd'], ['2c', '5c', '8c', 'Tc', 'Qc']], -1),
  ('paired span vs two pair', [['5h', '5d', '6c', '7s', '9h'], ['3h', '3d', '2c', '2s', 'Kh']], -1),
  ('two pair vs paired span', [['Jh', 'Jd', '2c', '2s', 'Kh'], ['8h', '8d', '6c', '7s', '9h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', '2s', '3h'], ['Ah', 'Ad', 'Kc', 'Ks', '2h']], 1),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1)],
 [('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('kicker decides pair', [['Qh', 'Qd', 'Ac', '4s', '2h'], ['Qs', 'Qc', 'Kc', '9s', '8h']], 1),
  ('trips vs two pair', [['7h', '7d', '7c', '2s', '3h'], ['Ah', 'Ad', 'Kc', 'Ks', '2h']], 1),
  ('quads vs full house', [['4h', '4d', '4c', '4s', '2h'], ['Ah', 'Ad', 'Ac', 'Ks', 'Kh']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)],
 [('wheel vs six-high straight', [['Ah', '2d', '3c', '4s', '5h'], ['2h', '3d', '4c', '5s', '6h']],
   -1),
  ('six-high vs wheel', [['2c', '3h', '4d', '5c', '6s'], ['As', '2c', '3d', '4h', '5d']], 1),
  ('pair of twos vs ace high kickers',
   [['2h', '2d', 'Kc', 'Qs', 'Jh'], ['3h', '3d', '4c', '5s', '7h']], -1),
  ('full house trips first', [['3h', '3d', '3c', 'As', 'Ah'], ['Kh', 'Kd', '2c', '2s', '2h']], 1),
  ('paired five-card span', [['5h', '5d', '6c', '7s', '9h'], ['Ah', 'Kd', 'Qc', '8s', '4h']], 1),
  ('two pair high pair first', [['Kh', 'Kd', '3c', '3s', '9h'], ['Qh', 'Qd', 'Jc', 'Js', '2h']], 1),
  ('high card ace vs king', [['Ah', '9d', '7c', '4s', '2h'], ['Kh', 'Qd', 'Jc', '9s', '7h']], 1),
  ('broadway vs wheel', [['Th', 'Jd', 'Qc', 'Ks', 'Ah'], ['As', '2c', '3d', '4h', '5d']], 1)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Threes full of aces loses to kings full of deuces, and a pair of deuces with K-Q-J beats a pair of treys.

Input: [hand_a, hand_b], each five distinct cards "Rs" (ranks 23456789TJQKA, suits cdhs). Return 1 if hand_a wins, -1 if hand_b wins, 0 for a split. Categories rank in the standard order; within a category compare rank groups by (group size, rank) descending; a wheel straight is five-high; suits never break ties.

split: open-access