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

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

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

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

prompt:
"AK" counts 12 combos instead of 16.

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

split: open-access


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

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

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

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

prompt:
"QQ+, AKs" fails to parse because the second token starts with a space.

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

split: open-access


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

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

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

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

prompt:
"TT-77" counts zero combos.

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

split: open-access


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

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

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

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

prompt:
"22" counts 12 combos and "QQ+" counts 36.

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

split: open-access


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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead={c[0].upper()+c[1].lower() for c in x['dead']}
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j==i: continue
            if suf=='s' and s1!=s2: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead or r2+s2 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead={c[0].upper()+c[1].lower() for c in x['dead']}
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j<i: continue
            if suf=='s' and s1!=s2: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead or r2+s2 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 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:
"QQ" enumerates 12 combos with no blockers and 9 with one queen dead.

Input: {"hand": class such as "AKs", "AKo", "AK" or "QQ", "dead": [known cards, rank upper-case or lower-case, suit lower-case or upper-case]}. Enumerate the concrete two-card combos of the class (suits c,d,h,s) and return how many contain no dead card.

split: open-access


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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead={c[0].upper()+c[1].lower() for c in x['dead']}
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j<=i: continue
            if suf=='s' and s1==s2: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead or r2+s2 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1)],
 [('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead={c[0].upper()+c[1].lower() for c in x['dead']}
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j<=i: continue
            if suf=='s' and i>j: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead or r2+s2 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1)],
 [('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)]]
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:
"AKs" counts 12 combos.

Input: {"hand": class such as "AKs", "AKo", "AK" or "QQ", "dead": [known cards, rank upper-case or lower-case, suit lower-case or upper-case]}. Enumerate the concrete two-card combos of the class (suits c,d,h,s) and return how many contain no dead card.

split: open-access


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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead={c[0].upper()+c[1].lower() for c in x['dead']}
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j<=i: continue
            if suf=='s' and s1!=s2: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead={c[0].upper()+c[1].lower() for c in x['dead']}
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j<=i: continue
            if suf=='s' and s1!=s2: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead and r2+s2 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A dead king does not reduce "AKs" or "AKo" combos.

Input: {"hand": class such as "AKs", "AKo", "AK" or "QQ", "dead": [known cards, rank upper-case or lower-case, suit lower-case or upper-case]}. Enumerate the concrete two-card combos of the class (suits c,d,h,s) and return how many contain no dead card.

split: open-access


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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead=set(x['dead'])
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j<=i: continue
            if suf=='s' and s1!=s2: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead or r2+s2 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    S='cdhs'
    h=x['hand']; dead={c.upper() for c in x['dead']}
    r1,r2=h[0],h[1]; suf=h[2:]
    n=0
    for i,s1 in enumerate(S):
        for j,s2 in enumerate(S):
            if r1==r2 and j<=i: continue
            if suf=='s' and s1!=s2: continue
            if suf=='o' and s1==s2: continue
            if r1+s1 in dead or r2+s2 in dead: continue
            n+=1
    return n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('offsuit blocked king', {'dead': ['Kd'], 'hand': 'AKo'}, 9),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('any ace king two blockers', {'dead': ['As', 'Kc'], 'hand': 'AK'}, 9),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('pair two blockers', {'dead': ['9c', '9s'], 'hand': '99'}, 1),
  ('blocked first rank only', {'dead': ['Qs', 'Qh'], 'hand': 'KQs'}, 2)],
 [('pair no blockers', {'dead': [], 'hand': 'QQ'}, 6),
  ('pair one blocker', {'dead': ['Qh'], 'hand': 'QQ'}, 3),
  ('suited no blockers', {'dead': [], 'hand': 'AKs'}, 4),
  ('suited blocked king', {'dead': ['Kd'], 'hand': 'AKs'}, 3),
  ('lower-case dead', {'dead': ['ah', 'kS'], 'hand': 'AKo'}, 7),
  ('upper-case suit dead', {'dead': ['JH'], 'hand': 'JTs'}, 3),
  ('unrelated dead', {'dead': ['2c', '7d'], 'hand': 'AKs'}, 4),
  ('offsuit no blockers', {'dead': [], 'hand': 'T9o'}, 12)]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Dead cards written "ah" or "JH" leave the combo count unchanged.

Input: {"hand": class such as "AKs", "AKo", "AK" or "QQ", "dead": [known cards, rank upper-case or lower-case, suit lower-case or upper-case]}. Enumerate the concrete two-card combos of the class (suits c,d,h,s) and return how many contain no dead card.

split: open-access


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

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

prompt:
A pair of sixes is announced as "Pair of Sixs".

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

split: open-access


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

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

prompt:
A-2-3-4-5 is announced "Straight, Ace high" and the steel wheel as a royal flush.

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

split: open-access


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

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

prompt:
A-2-3-4-5 suited is announced as "Royal Flush".

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

split: open-access


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

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

prompt:
Threes full of kings is announced as "Kings full of Threes".

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

split: open-access