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

N = 1
observations = []
def solve(x):
    hand, trick, broken, first = x
    def penalty(c):
        return c[1] == 'H' or c == 'QS'
    if not trick:
        if first and '2C' in hand:
            return ['2C']
        if not broken:
            safe = [c for c in hand if c[1] != 'H']
            if safe:
                return safe
        return list(hand)
    suit = trick[0][1]
    follow = [c for c in hand if c[1] == suit]
    if follow:
        return follow
    if first:
        clean = [c for c in hand if c[1] != 'H']
        if clean:
            return clean
    return list(hand)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['6H', 'AH', 'JC'], ['7S', 'KC'], False, False], ['6H', 'AH', 'JC']], [[['5H', '6C', '7C', '9C', 'KD', 'QC', 'TS'], ['3S', '8S', '2S'], False, True], ['TS']], [[['2C', 'JS'], [], True, True], ['2C']], [[['AS', 'TH'], [], False, True], ['AS']], [[['2C', '8C', 'AS', 'KH'], [], True, False], ['2C', '8C', 'AS', 'KH']], [[['2H', '3C', '3H', 'QC'], [], True, False], ['2H', '3C', '3H', 'QC']], [[['2S', 'KS', 'TH'], ['JC', '2C'], False, True], ['2S', 'KS']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']]], [[[['2S', 'KS', 'TH'], ['JC', '2C'], False, True], ['2S', 'KS']], [[['2S'], ['QS'], False, False], ['2S']], [[['2H', '6C', '7H', '9C', '9S'], ['QC', '2C', '6H'], False, False], ['6C', '9C']], [[['3H', '5D', '9D'], ['3C'], True, False], ['3H', '5D', '9D']], [[['AH', 'JH', 'TH'], ['9C', 'TS'], True, False], ['AH', 'JH', 'TH']], [[['2H', '6S', '8D', 'AC', 'JD', 'QH'], ['4H', 'KC', '3S'], True, True], ['2H', 'QH']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']], [[['4H', '7H', 'QS'], ['2C'], False, True], ['4H', '7H', 'QS']]], [[[['5C'], [], False, True], ['5C']], [[['5D', 'JH'], ['QH', 'KC', '8S'], True, False], ['JH']], [[['4H'], [], True, True], ['4H']], [[['3D', '5C'], [], True, False], ['3D', '5C']], [[['2H', '5H'], ['KS', '9C', '7H'], False, False], ['2H', '5H']], [[['8C', 'AC', 'KD', 'TS'], [], False, True], ['8C', 'AC', 'KD', 'TS']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']], [[['3H', 'QS'], ['4C'], False, True], ['3H', 'QS']]], [[[['2H', '6C', '6D', '7C', 'KS', 'QC'], ['3C', '7D'], True, False], ['6C', '7C', 'QC']], [[['AC'], ['2C', '8D'], False, False], ['AC']], [[['2S', '6D'], [], True, False], ['2S', '6D']], [[['5D', 'AS'], ['5S', '3C'], False, False], ['AS']], [[['3C', '4S', '6S', '7D', '8H', 'AS', 'KC', 'KH'], [], False, False], ['3C', '4S', '6S', '7D', 'AS', 'KC']], [[['2H', '3D', '5H', '9D', 'JC', 'KS', 'QD'], [], False, False], ['3D', '9D', 'JC', 'KS', 'QD']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']]], [[[['4D', '6S', '9C', 'JD'], ['9H', 'AS', 'KC'], False, True], ['4D', '6S', '9C', 'JD']], [[['3S', '7D'], [], False, True], ['3S', '7D']], [[['2D', '3H', '3S', '4S', '6D', 'QC', 'QH'], ['6C', 'AH'], False, False], ['QC']], [[['3C', '6D', 'TH'], [], False, False], ['3C', '6D']], [[['3D', '5C', '6S', '7H', 'KH', 'TH', 'TS'], [], False, False], ['3D', '5C', '6S', 'TS']], [[['7D', '8H', 'AD', 'AS'], ['AH', '4H', '9C'], True, True], ['8H']], [[['3C', 'KH', 'TD'], ['5S', '2H', '7D'], False, True], ['3C', 'TD']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("legal plays case %d" % i, solve(args), 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):
    hand, trick, broken, first = x
    def penalty(c):
        return c[1] == 'H' or c == 'QS'
    if not trick:
        if first and '2C' in hand:
            return ['2C']
        if not broken:
            safe = [c for c in hand if c[1] != 'H']
            if safe:
                return safe
        return list(hand)
    suit = trick[0][1]
    follow = [c for c in hand if c[1] == suit]
    if follow:
        return follow
    if first:
        clean = [c for c in hand if c != 'QS']
        if clean:
            return clean
    return list(hand)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['6H', 'AH', 'JC'], ['7S', 'KC'], False, False], ['6H', 'AH', 'JC']], [[['5H', '6C', '7C', '9C', 'KD', 'QC', 'TS'], ['3S', '8S', '2S'], False, True], ['TS']], [[['2C', 'JS'], [], True, True], ['2C']], [[['AS', 'TH'], [], False, True], ['AS']], [[['2C', '8C', 'AS', 'KH'], [], True, False], ['2C', '8C', 'AS', 'KH']], [[['2H', '3C', '3H', 'QC'], [], True, False], ['2H', '3C', '3H', 'QC']], [[['2S', 'KS', 'TH'], ['JC', '2C'], False, True], ['2S', 'KS']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']]], [[[['2S', 'KS', 'TH'], ['JC', '2C'], False, True], ['2S', 'KS']], [[['2S'], ['QS'], False, False], ['2S']], [[['2H', '6C', '7H', '9C', '9S'], ['QC', '2C', '6H'], False, False], ['6C', '9C']], [[['3H', '5D', '9D'], ['3C'], True, False], ['3H', '5D', '9D']], [[['AH', 'JH', 'TH'], ['9C', 'TS'], True, False], ['AH', 'JH', 'TH']], [[['2H', '6S', '8D', 'AC', 'JD', 'QH'], ['4H', 'KC', '3S'], True, True], ['2H', 'QH']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']], [[['4H', '7H', 'QS'], ['2C'], False, True], ['4H', '7H', 'QS']]], [[[['5C'], [], False, True], ['5C']], [[['5D', 'JH'], ['QH', 'KC', '8S'], True, False], ['JH']], [[['4H'], [], True, True], ['4H']], [[['3D', '5C'], [], True, False], ['3D', '5C']], [[['2H', '5H'], ['KS', '9C', '7H'], False, False], ['2H', '5H']], [[['8C', 'AC', 'KD', 'TS'], [], False, True], ['8C', 'AC', 'KD', 'TS']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']], [[['3H', 'QS'], ['4C'], False, True], ['3H', 'QS']]], [[[['2H', '6C', '6D', '7C', 'KS', 'QC'], ['3C', '7D'], True, False], ['6C', '7C', 'QC']], [[['AC'], ['2C', '8D'], False, False], ['AC']], [[['2S', '6D'], [], True, False], ['2S', '6D']], [[['5D', 'AS'], ['5S', '3C'], False, False], ['AS']], [[['3C', '4S', '6S', '7D', '8H', 'AS', 'KC', 'KH'], [], False, False], ['3C', '4S', '6S', '7D', 'AS', 'KC']], [[['2H', '3D', '5H', '9D', 'JC', 'KS', 'QD'], [], False, False], ['3D', '9D', 'JC', 'KS', 'QD']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']]], [[[['4D', '6S', '9C', 'JD'], ['9H', 'AS', 'KC'], False, True], ['4D', '6S', '9C', 'JD']], [[['3S', '7D'], [], False, True], ['3S', '7D']], [[['2D', '3H', '3S', '4S', '6D', 'QC', 'QH'], ['6C', 'AH'], False, False], ['QC']], [[['3C', '6D', 'TH'], [], False, False], ['3C', '6D']], [[['3D', '5C', '6S', '7H', 'KH', 'TH', 'TS'], [], False, False], ['3D', '5C', '6S', 'TS']], [[['7D', '8H', 'AD', 'AS'], ['AH', '4H', '9C'], True, True], ['8H']], [[['3C', 'KH', 'TD'], ['5S', '2H', '7D'], False, True], ['3C', 'TD']], [[['3H', 'QS', 'KD'], ['4C'], True, True], ['KD']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("legal plays case %d" % i, solve(args), 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 void player discards QS into the opening trick.

Input [hand, trick_so_far, hearts_broken, first_trick]. Leading: on the first trick the holder of 2C must lead it; hearts may not be led before they are broken unless the hand is all hearts (QS may be led). Following: follow the led suit if possible; on the first trick a void player may not discard hearts or QS unless nothing else is held. Return legal cards in hand order.

split: open-access


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

N = 1
observations = []
def solve(x):
    hand, trick, broken, first = x
    def penalty(c):
        return c[1] == 'H' or c == 'QS'
    if not trick:
        if first and '2C' in hand:
            return ['2C']
        if not broken:
            safe = [c for c in hand if c[1] != 'H']
            if safe:
                return safe
        return list(hand)
    suit = trick[-1][1]
    follow = [c for c in hand if c[1] == suit]
    if follow:
        return follow
    if first:
        clean = [c for c in hand if not penalty(c)]
        if clean:
            return clean
    return list(hand)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['4C', '8D', '9S', 'QC', 'TC', 'TS'], ['8S', 'QD', '7C'], True, False], ['9S', 'TS']], [[['5H', '6C', '7C', '9C', 'KD', 'QC', 'TS'], ['3S', '8S', '2S'], False, True], ['TS']], [[['2C', 'JS'], [], True, True], ['2C']], [[['AS', 'TH'], [], False, True], ['AS']], [[['2C', '8C', 'AS', 'KH'], [], True, False], ['2C', '8C', 'AS', 'KH']], [[['2H', '3C', '3H', 'QC'], [], True, False], ['2H', '3C', '3H', 'QC']], [[['7C'], ['4S'], False, True], ['7C']], [[['6H', '7H', '8H', 'JD', 'KC', 'KD', 'TS'], ['AC', '7D', '9S'], False, False], ['KC']]], [[[['2S', 'KS', 'TH'], ['JC', '2C'], False, True], ['2S', 'KS']], [[['2S'], ['QS'], False, False], ['2S']], [[['2H', '6C', '7H', '9C', '9S'], ['QC', '2C', '6H'], False, False], ['6C', '9C']], [[['3H', '5D', '9D'], ['3C'], True, False], ['3H', '5D', '9D']], [[['AH', 'JH', 'TH'], ['9C', 'TS'], True, False], ['AH', 'JH', 'TH']], [[['2H', '6S', '8D', 'AC', 'JD', 'QH'], ['4H', 'KC', '3S'], True, True], ['2H', 'QH']], [[['3D', '9H', 'QS'], [], False, False], ['3D', 'QS']], [[['4S', '5C', 'JC', 'KD', 'QD'], ['9H', '3C'], False, False], ['4S', '5C', 'JC', 'KD', 'QD']]], [[[['5C'], [], False, True], ['5C']], [[['5D', 'JH'], ['QH', 'KC', '8S'], True, False], ['JH']], [[['4H'], [], True, True], ['4H']], [[['3D', '5C'], [], True, False], ['3D', '5C']], [[['2H', '5H'], ['KS', '9C', '7H'], False, False], ['2H', '5H']], [[['8C', 'AC', 'KD', 'TS'], [], False, True], ['8C', 'AC', 'KD', 'TS']], [[['5D', 'AS'], ['5S', '3C'], False, False], ['AS']], [[['3H', '7C', '8S', '9S', 'JC', 'KC', 'KH', 'KS'], ['8H', '4C', '4D'], True, False], ['3H', 'KH']]], [[[['2H', '6C', '6D', '7C', 'KS', 'QC'], ['3C', '7D'], True, False], ['6C', '7C', 'QC']], [[['AC'], ['2C', '8D'], False, False], ['AC']], [[['2S', '6D'], [], True, False], ['2S', '6D']], [[['5D', 'AS'], ['5S', '3C'], False, False], ['AS']], [[['3C', '4S', '6S', '7D', '8H', 'AS', 'KC', 'KH'], [], False, False], ['3C', '4S', '6S', '7D', 'AS', 'KC']], [[['2H', '3D', '5H', '9D', 'JC', 'KS', 'QD'], [], False, False], ['3D', '9D', 'JC', 'KS', 'QD']], [[['2D', '3H', '3S', '4S', '6D', 'QC', 'QH'], ['6C', 'AH'], False, False], ['QC']], [[['6H', '6S', 'TC', 'TS'], ['6D', '4D', '2H'], False, False], ['6H', '6S', 'TC', 'TS']]], [[[['4C', '8D', '9S', 'QC', 'TC', 'TS'], ['8S', 'QD', '7C'], True, False], ['9S', 'TS']], [[['3S', '7D'], [], False, True], ['3S', '7D']], [[['2D', '3H', '3S', '4S', '6D', 'QC', 'QH'], ['6C', 'AH'], False, False], ['QC']], [[['3C', '6D', 'TH'], [], False, False], ['3C', '6D']], [[['3D', '5C', '6S', '7H', 'KH', 'TH', 'TS'], [], False, False], ['3D', '5C', '6S', 'TS']], [[['7D', '8H', 'AD', 'AS'], ['AH', '4H', '9C'], True, True], ['8H']], [[['2C', '4C', '6H', '8H', '9D', 'KC', 'TS'], ['6C', '9C'], False, False], ['2C', '4C', 'KC']], [[['2C', '3C', '5D', '6H', 'KD', 'QC', 'TC', 'TH'], ['8C', '6S'], True, True], ['2C', '3C', 'QC', 'TC']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("legal plays case %d" % i, solve(args), 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):
    hand, trick, broken, first = x
    def penalty(c):
        return c[1] == 'H' or c == 'QS'
    if not trick:
        if first and '2C' in hand:
            return ['2C']
        if not broken:
            safe = [c for c in hand if c[1] != 'H']
            if safe:
                return safe
        return list(hand)
    suit = sorted(trick)[0][1]
    follow = [c for c in hand if c[1] == suit]
    if follow:
        return follow
    if first:
        clean = [c for c in hand if not penalty(c)]
        if clean:
            return clean
    return list(hand)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['4C', '8D', '9S', 'QC', 'TC', 'TS'], ['8S', 'QD', '7C'], True, False], ['9S', 'TS']], [[['5H', '6C', '7C', '9C', 'KD', 'QC', 'TS'], ['3S', '8S', '2S'], False, True], ['TS']], [[['2C', 'JS'], [], True, True], ['2C']], [[['AS', 'TH'], [], False, True], ['AS']], [[['2C', '8C', 'AS', 'KH'], [], True, False], ['2C', '8C', 'AS', 'KH']], [[['2H', '3C', '3H', 'QC'], [], True, False], ['2H', '3C', '3H', 'QC']], [[['7C'], ['4S'], False, True], ['7C']], [[['6H', '7H', '8H', 'JD', 'KC', 'KD', 'TS'], ['AC', '7D', '9S'], False, False], ['KC']]], [[[['2S', 'KS', 'TH'], ['JC', '2C'], False, True], ['2S', 'KS']], [[['2S'], ['QS'], False, False], ['2S']], [[['2H', '6C', '7H', '9C', '9S'], ['QC', '2C', '6H'], False, False], ['6C', '9C']], [[['3H', '5D', '9D'], ['3C'], True, False], ['3H', '5D', '9D']], [[['AH', 'JH', 'TH'], ['9C', 'TS'], True, False], ['AH', 'JH', 'TH']], [[['2H', '6S', '8D', 'AC', 'JD', 'QH'], ['4H', 'KC', '3S'], True, True], ['2H', 'QH']], [[['3D', '9H', 'QS'], [], False, False], ['3D', 'QS']], [[['4S', '5C', 'JC', 'KD', 'QD'], ['9H', '3C'], False, False], ['4S', '5C', 'JC', 'KD', 'QD']]], [[[['5C'], [], False, True], ['5C']], [[['5D', 'JH'], ['QH', 'KC', '8S'], True, False], ['JH']], [[['4H'], [], True, True], ['4H']], [[['3D', '5C'], [], True, False], ['3D', '5C']], [[['2H', '5H'], ['KS', '9C', '7H'], False, False], ['2H', '5H']], [[['8C', 'AC', 'KD', 'TS'], [], False, True], ['8C', 'AC', 'KD', 'TS']], [[['5D', 'AS'], ['5S', '3C'], False, False], ['AS']], [[['3H', '7C', '8S', '9S', 'JC', 'KC', 'KH', 'KS'], ['8H', '4C', '4D'], True, False], ['3H', 'KH']]], [[[['2H', '6C', '6D', '7C', 'KS', 'QC'], ['3C', '7D'], True, False], ['6C', '7C', 'QC']], [[['AC'], ['2C', '8D'], False, False], ['AC']], [[['2S', '6D'], [], True, False], ['2S', '6D']], [[['5D', 'AS'], ['5S', '3C'], False, False], ['AS']], [[['3C', '4S', '6S', '7D', '8H', 'AS', 'KC', 'KH'], [], False, False], ['3C', '4S', '6S', '7D', 'AS', 'KC']], [[['2H', '3D', '5H', '9D', 'JC', 'KS', 'QD'], [], False, False], ['3D', '9D', 'JC', 'KS', 'QD']], [[['2D', '3H', '3S', '4S', '6D', 'QC', 'QH'], ['6C', 'AH'], False, False], ['QC']], [[['6H', '6S', 'TC', 'TS'], ['6D', '4D', '2H'], False, False], ['6H', '6S', 'TC', 'TS']]], [[[['4C', '8D', '9S', 'QC', 'TC', 'TS'], ['8S', 'QD', '7C'], True, False], ['9S', 'TS']], [[['3S', '7D'], [], False, True], ['3S', '7D']], [[['2D', '3H', '3S', '4S', '6D', 'QC', 'QH'], ['6C', 'AH'], False, False], ['QC']], [[['3C', '6D', 'TH'], [], False, False], ['3C', '6D']], [[['3D', '5C', '6S', '7H', 'KH', 'TH', 'TS'], [], False, False], ['3D', '5C', '6S', 'TS']], [[['7D', '8H', 'AD', 'AS'], ['AH', '4H', '9C'], True, True], ['8H']], [[['2C', '4C', '6H', '8H', '9D', 'KC', 'TS'], ['6C', '9C'], False, False], ['2C', '4C', 'KC']], [[['2C', '3C', '5D', '6H', 'KD', 'QC', 'TC', 'TH'], ['8C', '6S'], True, True], ['2C', '3C', 'QC', 'TC']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("legal plays case %d" % i, solve(args), 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:
After a discard, the next player is forced to follow the discard suit.

Input [hand, trick_so_far, hearts_broken, first_trick]. Leading: on the first trick the holder of 2C must lead it; hearts may not be led before they are broken unless the hand is all hearts (QS may be led). Following: follow the led suit if possible; on the first trick a void player may not discard hearts or QS unless nothing else is held. Return legal cards in hand order.

split: open-access


prompt:
The table rule is applied backwards on soft 17.

Input [dealer_cards, shoe, rule]. Dealer draws from the front of the shoe while total < 17, and under H17 also on soft 17; aces count 11 when that does not bust. Stop if the shoe runs out. Return [final_cards, total].

split: open-access


prompt:
Hit cards come from the wrong end of the prepared shoe.

Input [dealer_cards, shoe, rule]. Dealer draws from the front of the shoe while total < 17, and under H17 also on soft 17; aces count 11 when that does not bust. Stop if the shoe runs out. Return [final_cards, total].

split: open-access


prompt:
A dealer holding A-T keeps hitting from 11.

Input [dealer_cards, shoe, rule]. Dealer draws from the front of the shoe while total < 17, and under H17 also on soft 17; aces count 11 when that does not bust. Stop if the shoe runs out. Return [final_cards, total].

split: open-access


prompt:
The dealer keeps drawing on 17 and busts more often.

Input [dealer_cards, shoe, rule]. Dealer draws from the front of the shoe while total < 17, and under H17 also on soft 17; aces count 11 when that does not bust. Stop if the shoe runs out. Return [final_cards, total].

split: open-access


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

N = 1
observations = []
def solve(x):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if dt > 21:
        return stake
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['8D', 'TH', '5H'], ['KD', '6D', '7D'], 20, False, True], -20], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['8S', '5C', 'QS', '9S'], ['9D', '6C', 'TC'], 2, False, True], -2]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['9S', '8H', '7C'], ['9C', '7D', '8S'], 10, False, False], -10]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['QC', 'TD', 'QD'], ['7D', '6S', 'JC'], 10, False, True], -10], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21 and dt <= 21:
        return -stake
    if pt > 21:
        return 0
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['8D', 'TH', '5H'], ['KD', '6D', '7D'], 20, False, True], -20], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['8S', '5C', 'QS', '9S'], ['9D', '6C', 'TC'], 2, False, True], -2]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['6H', '7H', 'AS', '8D'], ['9H', '7D', 'QD'], 4, True, False], -8], [[['9S', '8H', '7C'], ['9C', '7D', '8S'], 10, False, False], -10]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['QC', 'TD', 'QD'], ['7D', '6S', 'JC'], 10, False, True], -10], [[['9H', 'TS', '9D', 'TC'], ['TD', '7S', 'QS'], 2, False, False], -2]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Hands where both sides bust are settled in the player favour.

Input [player_cards, dealer_cards, bet, doubled, from_split]. A natural is a two-card 21 not from a split. Player bust loses the stake (2*bet if doubled) first; both naturals push; player natural pays 3:2 on the bet; dealer natural takes only the original bet; dealer bust pays the stake; otherwise compare totals, equal totals push. Return net units.

split: open-access


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

N = 1
observations = []
def solve(x):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['TD', 'AD'], ['JC', '7H'], 4, False, True], 4], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['KS', '3D', '4D', '4H'], ['5H', 'QC'], 20, False, False], 20], [[['AS', 'KH'], ['9C', '8D'], 10, False, True], 10]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['TD', '9C', '2D'], ['AH', '8D'], 4, True, False], 8], [[['TD', 'AD'], ['JC', '7H'], 4, False, True], 4]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['8D', 'AC', '7C', '5C'], ['9C', '8H'], 20, False, False], 20], [[['AS', 'KH'], ['9C', '8D'], 10, False, True], 10]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['8S', 'TS', '3S'], ['TD', '9H', 'AS'], 10, False, False], 10], [[['TD', 'AD'], ['JC', '7H'], 4, False, True], 4]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['TD', 'AD'], ['JC', '7H'], 4, False, True], 4], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['KS', '3D', '4D', '4H'], ['5H', 'QC'], 20, False, False], 20], [[['AS', 'KH'], ['9C', '8D'], 10, False, True], 10]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['TD', '9C', '2D'], ['AH', '8D'], 4, True, False], 8], [[['TD', 'AD'], ['JC', '7H'], 4, False, True], 4]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['8D', 'AC', '7C', '5C'], ['9C', '8H'], 20, False, False], 20], [[['AS', 'KH'], ['9C', '8D'], 10, False, True], 10]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['8S', 'TS', '3S'], ['TD', '9H', 'AS'], 10, False, False], 10], [[['TD', 'AD'], ['JC', '7H'], 4, False, True], 4]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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:
Split hands reaching 21 in two cards collect 3:2.

Input [player_cards, dealer_cards, bet, doubled, from_split]. A natural is a two-card 21 not from a split. Player bust loses the stake (2*bet if doubled) first; both naturals push; player natural pays 3:2 on the bet; dealer natural takes only the original bet; dealer bust pays the stake; otherwise compare totals, equal totals push. Return net units.

split: open-access


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

N = 1
observations = []
def solve(x):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['KS', 'AC'], ['7C', 'QD'], 4, False, False], 6], [[['AS', 'KH'], ['9C', '8D'], 10, False, False], 15]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['AS', 'QH'], ['2C', '9D'], 10, True, False], 15], [[['AS', 'QH'], ['2C', '9D'], 10, True, False], 15]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['KS', 'AC'], ['7C', 'QD'], 4, False, False], 6], [[['AS', 'KH'], ['9C', '8D'], 10, False, False], 15]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['JD', 'AD'], ['7C', 'AS', 'QD'], 10, False, False], 15], [[['JD', 'AD'], ['7C', 'AS', 'QD'], 10, False, False], 15]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['KS', 'AC'], ['7C', 'QD'], 4, False, False], 6], [[['AS', 'KH'], ['9C', '8D'], 10, False, False], 15]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 6 // 5
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['KS', 'AC'], ['7C', 'QD'], 4, False, False], 6], [[['AS', 'KH'], ['9C', '8D'], 10, False, False], 15]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['AS', 'QH'], ['2C', '9D'], 10, True, False], 15], [[['AS', 'QH'], ['2C', '9D'], 10, True, False], 15]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['KS', 'AC'], ['7C', 'QD'], 4, False, False], 6], [[['AS', 'KH'], ['9C', '8D'], 10, False, False], 15]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['JD', 'AD'], ['7C', 'AS', 'QD'], 10, False, False], 15], [[['JD', 'AD'], ['7C', 'AS', 'QD'], 10, False, False], 15]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['KS', 'AC'], ['7C', 'QD'], 4, False, False], 6], [[['AS', 'KH'], ['9C', '8D'], 10, False, False], 15]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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 natural on a 10-unit bet pays 10 instead of 15.

Input [player_cards, dealer_cards, bet, doubled, from_split]. A natural is a two-card 21 not from a split. Player bust loses the stake (2*bet if doubled) first; both naturals push; player natural pays 3:2 on the bet; dealer natural takes only the original bet; dealer bust pays the stake; otherwise compare totals, equal totals push. Return net units.

split: open-access


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

N = 1
observations = []
def solve(x):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return -stake
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['6D', 'JS', '3D'], ['5D', '9H'], 4, True, True], 8], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10]], [[[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['3H', 'TD'], ['8H', '5D'], 10, False, False], 0], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['6S', 'AH'], ['8S', 'QC', '7D'], 4, False, False], 4]], [[[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['8D', 'JH', '2S', '6S'], ['JD', 'TS'], 10, False, False], -10], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return 0 if doubled else -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['6D', 'JS', '3D'], ['5D', '9H'], 4, True, True], 8], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['JD', 'QC'], ['JC', '2D'], 20, False, False], 20], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10], [[['7S', '4H', 'TC'], ['TC', 'AD'], 10, True, False], -10]], [[[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['3H', 'TD'], ['8H', '5D'], 10, False, False], 0], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]], [[[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['6S', 'AH'], ['8S', 'QC', '7D'], 4, False, False], 4]], [[[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['8D', 'JH', '2S', '6S'], ['JD', 'TS'], 10, False, False], -10], [[['9S', '8H'], ['AC', 'QD'], 10, True, False], -10]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The doubled portion is taken although the contract refunds it.

Input [player_cards, dealer_cards, bet, doubled, from_split]. A natural is a two-card 21 not from a split. Player bust loses the stake (2*bet if doubled) first; both naturals push; player natural pays 3:2 on the bet; dealer natural takes only the original bet; dealer bust pays the stake; otherwise compare totals, equal totals push. Return net units.

split: open-access


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

N = 1
observations = []
def solve(x):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    if pt < dt:
        return -stake
    return stake if pt == 21 else 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['KS', '6D', 'AD'], ['3C', '4D', 'TH'], 4, False, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['2S', '6D', 'JS'], ['7H', 'AC', 'TD'], 4, False, False], 0], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['8D', 'TH', '5H'], ['KD', '6D', '7D'], 20, False, True], -20], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['AS', '8D', '7S'], ['KS', '6C'], 20, False, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['JH', '7D', 'AS'], ['TD', '8S'], 20, True, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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):
    p, d, bet, doubled, split = x
    def total(h):
        t = 0
        a = 0
        for c in h:
            if c[0] == 'A':
                a += 1
                t += 1
            elif c[0] in 'TJQK':
                t += 10
            else:
                t += int(c[0])
        if a and t + 10 <= 21:
            t += 10
        return t
    stake = bet * 2 if doubled else bet
    pt = total(p)
    dt = total(d)
    pn = pt == 21 and len(p) == 2 and not split
    dn = dt == 21 and len(d) == 2
    if pt > 21:
        return -stake
    if pn and dn:
        return 0
    if pn:
        return bet * 3 // 2
    if dn:
        return -bet
    if dt > 21:
        return stake
    if pt > dt:
        return stake
    return -stake
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['7D', '8C'], ['JC', '7S', 'QD'], 4, False, True], 4], [[['KH', '5D'], ['AD', 'JD'], 4, True, False], -4], [[['9H', '2H', '2D'], ['KC', '3C'], 10, False, False], 0], [[['7S', '6D'], ['4H', 'AC'], 20, False, False], -20], [[['6D', 'JC'], ['9H', '6C'], 4, True, False], 8], [[['7H', 'JS'], ['8S', '2D'], 20, True, False], 40], [[['KS', '6D', 'AD'], ['3C', '4D', 'TH'], 4, False, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['2S', '6D', 'JS'], ['7H', 'AC', 'TD'], 4, False, False], 0], [[['3C', 'TH'], ['AC', '8C'], 4, False, True], -4], [[['9C', '2D', '5D', '8D'], ['6H', 'KH'], 20, False, False], -20], [[['2D', '6S'], ['6H', 'TC'], 4, False, False], -4], [[['4H', '7S', '2C'], ['JC', '4S'], 20, False, False], -20], [[['9C', '8S'], ['9S', '5H'], 4, False, False], 4], [[['8D', 'TH', '5H'], ['KD', '6D', '7D'], 20, False, True], -20], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['QS', 'QD', '5S'], ['8D', 'QH'], 4, False, False], -4], [[['4D', 'KS'], ['9D', 'JH', '9C'], 20, False, True], 20], [[['5H', '4D'], ['QH', '6D'], 2, False, False], -2], [[['5D', 'TC', '2C', '5S'], ['KD', 'QD'], 10, False, False], -10], [[['TH', '9S', '2H', '3H'], ['AS', 'QD'], 2, False, False], -2], [[['2D', '7C'], ['AC', 'TC'], 2, True, False], -2], [[['AS', '8D', '7S'], ['KS', '6C'], 20, False, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['3D', '3S', '3C', 'JC'], ['TC', '9D'], 20, False, False], 0], [[['QS', '5S'], ['7S', '9C', '9S'], 2, False, True], 2], [[['4C', 'KH'], ['7H', 'TS'], 10, True, False], -20], [[['KH', '4D'], ['QD', '7S'], 2, False, False], -2], [[['TH', '3S', '5C', '8D'], ['8S', '6S'], 4, False, False], -4], [[['JC', '7S'], ['9D', 'JH', '6C'], 20, False, False], 20], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]], [[[['6D', '7C'], ['JD', '8S'], 2, True, False], -4], [[['7H', 'QH'], ['7S', '4C'], 10, False, False], 10], [[['AC', '7D'], ['4D', '4C'], 20, False, False], 20], [[['AS', '3C'], ['QD', '9C'], 4, False, False], -4], [[['KS', '8H', 'JD'], ['TS', 'AS'], 4, False, True], -4], [[['TD', 'QS', 'TH'], ['8H', 'TS'], 20, False, False], -20], [[['JH', '7D', 'AS'], ['TD', '8S'], 20, True, False], 0], [[['5S', '6H', 'TD'], ['9C', '5D', '7H'], 10, False, False], 0]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("settlement case %d" % i, solve(args), 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:
Non-natural 21 ties are paid instead of pushed.

Input [player_cards, dealer_cards, bet, doubled, from_split]. A natural is a two-card 21 not from a split. Player bust loses the stake (2*bet if doubled) first; both naturals push; player natural pays 3:2 on the bet; dealer natural takes only the original bet; dealer bust pays the stake; otherwise compare totals, equal totals push. Return net units.

split: open-access


prompt:
Moon rounds leave opponents at zero.

Input [cards_taken_by_each_player, jack_rule]. Each heart is 1, QS 13. A player taking all 26 penalty points shoots the moon: they score 0 and every other player 26. With jack_rule the taker of JD then scores -10. Return the list of round scores.

split: open-access


prompt:
A player with 13 hearts but not QS is treated as a shooter.

Input [cards_taken_by_each_player, jack_rule]. Each heart is 1, QS 13. A player taking all 26 penalty points shoots the moon: they score 0 and every other player 26. With jack_rule the taker of JD then scores -10. Return the list of round scores.

split: open-access


prompt:
Winning JD is punished.

Input [cards_taken_by_each_player, jack_rule]. Each heart is 1, QS 13. A player taking all 26 penalty points shoots the moon: they score 0 and every other player 26. With jack_rule the taker of JD then scores -10. Return the list of round scores.

split: open-access


prompt:
Twelve bags reset to zero instead of two.

Input [[bid1, bid2], [tricks1, tricks2], bags_before]. Nil (0) bids score +100 if the player took no tricks, else -100 and their tricks become bags. Other bids combine into a contract made by the non-nil players tricks: made -> 10*bid + 1 per overtrick (overtricks are bags); set -> -10*bid. Every 10 accumulated bags costs 100 and removes 10 bags. Return [score_delta, bags].

split: open-access


prompt:
Made contracts with overtricks score only the bid value.

Input [[bid1, bid2], [tricks1, tricks2], bags_before]. Nil (0) bids score +100 if the player took no tricks, else -100 and their tricks become bags. Other bids combine into a contract made by the non-nil players tricks: made -> 10*bid + 1 per overtrick (overtricks are bags); set -> -10*bid. Every 10 accumulated bags costs 100 and removes 10 bags. Return [score_delta, bags].

split: open-access


prompt:
Tricks taken by a failed nil bidder count toward the partner bid.

Input [[bid1, bid2], [tricks1, tricks2], bags_before]. Nil (0) bids score +100 if the player took no tricks, else -100 and their tricks become bags. Other bids combine into a contract made by the non-nil players tricks: made -> 10*bid + 1 per overtrick (overtricks are bags); set -> -10*bid. Every 10 accumulated bags costs 100 and removes 10 bags. Return [score_delta, bags].

split: open-access


prompt:
Going down by one on a bid of eight costs 10 instead of 80.

Input [[bid1, bid2], [tricks1, tricks2], bags_before]. Nil (0) bids score +100 if the player took no tricks, else -100 and their tricks become bags. Other bids combine into a contract made by the non-nil players tricks: made -> 10*bid + 1 per overtrick (overtricks are bags); set -> -10*bid. Every 10 accumulated bags costs 100 and removes 10 bags. Return [score_delta, bags].

split: open-access


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

N = 1
observations = []
def solve(x):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4:
            return 'set'
        return 'invalid'
    if len(set(suits)) != 1:
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    if idx[0] == 0:
        high = sorted(idx[1:] + [13])
        if all(high[i + 1] == high[i] + 1 for i in range(len(high) - 1)):
            return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['4S', '4H', '4D'], 'set'], [['JH', 'JH', 'JC'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['2H', '2H', '2S'], 'invalid'], [['JC', 'JH', 'JH'], 'invalid']], [[['JH', '9H', 'TH'], 'run'], [['TH', 'KH', 'QH', 'JH'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['JH', 'JH', 'JC'], 'invalid'], [['9C', '9H', '9D', '9C'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['6H', '6S', '6H'], 'invalid'], [['4C', '4H', '4C', '4D'], 'invalid']], [[['9C', '3S', '3H'], 'invalid'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['4C', '4H', '4C', '4D'], 'invalid'], [['2S', '2S', '2H'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, solve(args), 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):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4 and len(set(suits)) >= len(cards) - 1:
            return 'set'
        return 'invalid'
    if len(set(suits)) != 1:
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    if idx[0] == 0:
        high = sorted(idx[1:] + [13])
        if all(high[i + 1] == high[i] + 1 for i in range(len(high) - 1)):
            return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['4S', '4H', '4D'], 'set'], [['JH', 'JH', 'JC'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['2H', '2H', '2S'], 'invalid'], [['JC', 'JH', 'JH'], 'invalid']], [[['JH', '9H', 'TH'], 'run'], [['TH', 'KH', 'QH', 'JH'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['JH', 'JH', 'JC'], 'invalid'], [['9C', '9H', '9D', '9C'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['6H', '6S', '6H'], 'invalid'], [['4C', '4H', '4C', '4D'], 'invalid']], [[['9C', '3S', '3H'], 'invalid'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['4C', '4H', '4C', '4D'], 'invalid'], [['2S', '2S', '2H'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, solve(args), 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:
Two copies of the nine of clubs plus another nine form a "set".

Input a list of cards. A set is 3-4 cards of one rank in distinct suits. A run is 3+ consecutive cards of one suit; ace is low (A-2-3) or high (Q-K-A) but runs do not wrap (K-A-2). Return "set", "run" or "invalid".

split: open-access


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

N = 1
observations = []
def solve(x):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4 and len(set(suits)) == len(cards):
            return 'set'
        return 'invalid'
    if len(set(suits)) != 1:
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'AH', '2H'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['AH', 'QH', 'KH', 'JH'], 'run'], [['AD', '2D', 'KD'], 'invalid']], [[['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['4D', 'KC', 'QC'], 'invalid'], [['AD', 'AH', 'AD'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['QH', 'KH', 'AH', '2H'], 'invalid'], [['AH', 'QH', 'KH', 'JH'], 'run']], [[['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['AS', 'TD'], 'invalid'], [['KH', 'AH', '2H'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, solve(args), 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):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4 and len(set(suits)) == len(cards):
            return 'set'
        return 'invalid'
    if len(set(suits)) != 1:
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    if idx[0] == 0:
        high = sorted(i + 13 if i < 2 else i for i in idx)
        if all(high[i + 1] == high[i] + 1 for i in range(len(high) - 1)):
            return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'AH', '2H'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['AH', 'QH', 'KH', 'JH'], 'run'], [['AD', '2D', 'KD'], 'invalid']], [[['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['4D', 'KC', 'QC'], 'invalid'], [['AD', 'AH', 'AD'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['QH', 'KH', 'AH', '2H'], 'invalid'], [['AH', 'QH', 'KH', 'JH'], 'run']], [[['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['AS', 'TD'], 'invalid'], [['KH', 'AH', '2H'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Ace-high runs are invalid because ace only counts low.

Input a list of cards. A set is 3-4 cards of one rank in distinct suits. A run is 3+ consecutive cards of one suit; ace is low (A-2-3) or high (Q-K-A) but runs do not wrap (K-A-2). Return "set", "run" or "invalid".

split: open-access


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

N = 1
observations = []
def solve(x):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4 and len(set(suits)) == len(cards):
            return 'set'
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    if idx[0] == 0:
        high = sorted(idx[1:] + [13])
        if all(high[i + 1] == high[i] + 1 for i in range(len(high) - 1)):
            return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['JH', '9H', 'TH'], 'run'], [['TH', 'KH', 'QH', 'JH'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['9C', '3S', '3H'], 'invalid'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, solve(args), 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):
    cards = x
    order = 'A23456789TJQK'
    if len(cards) < 3:
        return 'invalid'
    ranks = [c[0] for c in cards]
    suits = [c[1] for c in cards]
    if len(set(ranks)) == 1:
        if len(cards) <= 4 and len(set(suits)) == len(cards):
            return 'set'
        return 'invalid'
    if len(set(suits)) > 2:
        return 'invalid'
    idx = sorted(order.index(r) for r in ranks)
    if all(idx[i + 1] == idx[i] + 1 for i in range(len(idx) - 1)):
        return 'run'
    if idx[0] == 0:
        high = sorted(idx[1:] + [13])
        if all(high[i + 1] == high[i] + 1 for i in range(len(high) - 1)):
            return 'run'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['9H', '9C', '9D', '9D'], 'invalid'], [['4D', '5D', '3D', '6D'], 'run'], [['KD', '6S', 'QS', '6H'], 'invalid'], [['8H', '8S'], 'invalid'], [['JD', 'QD', '2D', 'KD', 'AD'], 'invalid'], [['8H', '6D', 'AH'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['9C', 'JC', 'QC', 'TC'], 'run'], [['7S', '4D', 'JC'], 'invalid'], [['KH', 'QH', 'JH'], 'run'], [['5D', '5S'], 'invalid'], [['KD', 'TD', 'AD', 'JD', 'QD'], 'run'], [['KH', 'KD', 'KC', 'KC', 'KS'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['JH', '9H', 'TH'], 'run'], [['TH', 'KH', 'QH', 'JH'], 'run'], [['6C', '2C', '8D', '8C'], 'invalid'], [['5H', '2H', '3H', '6H', '4H'], 'run'], [['4H', '4S', '4C', '4D'], 'set'], [['3D', '3H', '3C'], 'set'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']], [[['AD', 'AH', 'AD'], 'invalid'], [['QC', 'QS', 'QD', 'QD'], 'invalid'], [['9S', 'JS', 'QS', '8S', 'TS'], 'run'], [['KS', '4S', '8D', '3C'], 'invalid'], [['9C', 'JC', 'TC', '8C'], 'run'], [['AH', '2H', '3H'], 'run'], [['5S', '6S', '7S', '8D'], 'invalid'], [['5S', '6S', '7S', '8D'], 'invalid']], [[['9C', '3S', '3H'], 'invalid'], [['9H', 'JH', 'QC', '2D'], 'invalid'], [['5S', 'AH'], 'invalid'], [['TH', 'JH', 'KH', 'QH'], 'run'], [['QC', '6D'], 'invalid'], [['9D', '7D', '3S', '9S'], 'invalid'], [['5S', '6S', '7D'], 'invalid'], [['5S', '6S', '7D'], 'invalid']]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("meld case %d" % i, solve(args), 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:
5-6-7 in different suits is scored as a run.

Input a list of cards. A set is 3-4 cards of one rank in distinct suits. A run is 3+ consecutive cards of one suit; ace is low (A-2-3) or high (Q-K-A) but runs do not wrap (K-A-2). Return "set", "run" or "invalid".

split: open-access


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

N = 1
observations = []
def solve(x):
    kc, dc, gin, big = x
    def dw(cards):
        t = 0
        for c in cards:
            r = c[0]
            t += 1 if r == 'A' else 10 if r in 'TJQK' else int(r)
        return t
    k = dw(kc)
    d = dw(dc)
    if k > 10:
        return ['illegal', 0]
    if big:
        return ['knocker', 31 + d]
    if gin:
        return ['knocker', 25 + d]
    if d < k:
        return ['defender', 25 + k - d]
    return ['knocker', d - k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[], [], False, False], ['defender', 25]], [[[], ['KS', '5S', '4H'], False, False], ['knocker', 19]], [[['KD', 'JH', '9S'], ['JS', '7D'], False, False], ['illegal', 0]], [[['4S', '4D', 'AS'], ['3D', 'JS', 'KD', '7D'], False, False], ['knocker', 21]], [[['TS', 'JC', '5S'], ['4H', '7C'], False, False], ['illegal', 0]], [[[], ['KS', 'TD', '5D', '7D'], False, False], ['knocker', 32]], [[[], ['7H', '5D'], False, False], ['knocker', 12]], [[['KS'], [], False, False], ['defender', 35]]], [[[['6S', '8S', '6C'], ['4C', 'KH', '9S'], False, False], ['illegal', 0]], [[[], [], True, False], ['knocker', 25]], [[['6C'], [], False, False], ['defender', 31]], [[[], ['4D', 'JS'], True, False], ['knocker', 39]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]], [[[], ['KH', '3D'], False, False], ['knocker', 13]], [[[], [], False, False], ['defender', 25]], [[['2H'], [], False, False], ['defender', 27]]], [[[['KH', '4H', 'JD'], [], False, False], ['illegal', 0]], [[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[['7D', '7S'], ['2S', 'QC'], False, False], ['illegal', 0]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['3C', '3H', '5S'], True, False], ['knocker', 36]], [[['AC', '9D', 'AD'], ['8S'], False, False], ['illegal', 0]], [[['JC'], ['AC', 'AH'], False, False], ['defender', 33]], [[[], [], False, False], ['defender', 25]]], [[[[], ['JS', '8H', '7C'], False, False], ['knocker', 25]], [[[], ['2C'], False, False], ['knocker', 2]], [[[], ['KD'], False, False], ['knocker', 10]], [[[], [], True, False], ['knocker', 25]], [[['TH', '3H', 'KC'], ['TD', 'AS', 'JD', '5H'], False, False], ['illegal', 0]], [[['TH', '8S'], ['QC', '5S', '2S', '6D'], False, False], ['illegal', 0]], [[['QD'], [], False, False], ['defender', 35]], [[['3S'], ['2C', 'AD'], False, False], ['defender', 25]]], [[[[], [], False, False], ['defender', 25]], [[['TH', '6C'], ['6D', 'QC'], False, False], ['illegal', 0]], [[['9C'], ['8S', 'JD'], False, False], ['knocker', 9]], [[['5H', '6D'], ['QH', '8D', 'KH'], False, False], ['illegal', 0]], [[['QC', 'JD'], ['7C', 'KH', '8C', '5S'], False, False], ['illegal', 0]], [[[], ['4D', '3S'], False, False], ['knocker', 7]], [[['8D', 'AH'], [], False, False], ['defender', 34]], [[['6D', '6H'], ['6C', 'QD', '9S', '5C'], False, False], ['illegal', 0]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("knock score case %d" % i, solve(args), 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):
    kc, dc, gin, big = x
    def dw(cards):
        t = 0
        for c in cards:
            r = c[0]
            t += 1 if r == 'A' else 10 if r in 'TJQK' else int(r)
        return t
    k = dw(kc)
    d = dw(dc)
    if k > 10:
        return ['illegal', 0]
    if big:
        return ['knocker', 31 + d]
    if gin:
        return ['knocker', 25 + d]
    if d <= k:
        return ['defender', 25]
    return ['knocker', d - k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[], [], False, False], ['defender', 25]], [[[], ['KS', '5S', '4H'], False, False], ['knocker', 19]], [[['KD', 'JH', '9S'], ['JS', '7D'], False, False], ['illegal', 0]], [[['4S', '4D', 'AS'], ['3D', 'JS', 'KD', '7D'], False, False], ['knocker', 21]], [[['TS', 'JC', '5S'], ['4H', '7C'], False, False], ['illegal', 0]], [[[], ['KS', 'TD', '5D', '7D'], False, False], ['knocker', 32]], [[[], ['7H', '5D'], False, False], ['knocker', 12]], [[['KS'], [], False, False], ['defender', 35]]], [[[['6S', '8S', '6C'], ['4C', 'KH', '9S'], False, False], ['illegal', 0]], [[[], [], True, False], ['knocker', 25]], [[['6C'], [], False, False], ['defender', 31]], [[[], ['4D', 'JS'], True, False], ['knocker', 39]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]], [[[], ['KH', '3D'], False, False], ['knocker', 13]], [[[], [], False, False], ['defender', 25]], [[['2H'], [], False, False], ['defender', 27]]], [[[['KH', '4H', 'JD'], [], False, False], ['illegal', 0]], [[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[['7D', '7S'], ['2S', 'QC'], False, False], ['illegal', 0]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['3C', '3H', '5S'], True, False], ['knocker', 36]], [[['AC', '9D', 'AD'], ['8S'], False, False], ['illegal', 0]], [[['JC'], ['AC', 'AH'], False, False], ['defender', 33]], [[[], [], False, False], ['defender', 25]]], [[[[], ['JS', '8H', '7C'], False, False], ['knocker', 25]], [[[], ['2C'], False, False], ['knocker', 2]], [[[], ['KD'], False, False], ['knocker', 10]], [[[], [], True, False], ['knocker', 25]], [[['TH', '3H', 'KC'], ['TD', 'AS', 'JD', '5H'], False, False], ['illegal', 0]], [[['TH', '8S'], ['QC', '5S', '2S', '6D'], False, False], ['illegal', 0]], [[['QD'], [], False, False], ['defender', 35]], [[['3S'], ['2C', 'AD'], False, False], ['defender', 25]]], [[[[], [], False, False], ['defender', 25]], [[['TH', '6C'], ['6D', 'QC'], False, False], ['illegal', 0]], [[['9C'], ['8S', 'JD'], False, False], ['knocker', 9]], [[['5H', '6D'], ['QH', '8D', 'KH'], False, False], ['illegal', 0]], [[['QC', 'JD'], ['7C', 'KH', '8C', '5S'], False, False], ['illegal', 0]], [[[], ['4D', '3S'], False, False], ['knocker', 7]], [[['8D', 'AH'], [], False, False], ['defender', 34]], [[['6D', '6H'], ['6C', 'QD', '9S', '5C'], False, False], ['illegal', 0]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("knock score case %d" % i, solve(args), 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 defender matching the knocker deadwood loses instead of undercutting.

Input [knocker_deadwood_cards, defender_deadwood_after_layoffs, gin, big_gin]. Deadwood: A=1, T/J/Q/K=10, others pip. Knocking above 10 is ["illegal", 0]. Big gin scores 31 + defender deadwood, gin 25 + defender deadwood (gin cannot be undercut). Otherwise if defender deadwood <= knocker deadwood the defender undercuts for 25 + difference; else knocker scores the difference.

split: open-access


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

N = 1
observations = []
def solve(x):
    kc, dc, gin, big = x
    def dw(cards):
        t = 0
        for c in cards:
            r = c[0]
            t += 1 if r == 'A' else 10 if r in 'TJQK' else int(r)
        return t
    k = dw(kc)
    d = dw(dc)
    if k > 10:
        return ['illegal', 0]
    if d <= k and not big:
        return ['defender', 25 + k - d]
    if big:
        return ['knocker', 31 + d]
    if gin:
        return ['knocker', 25 + d]
    if d <= k:
        return ['defender', 25 + k - d]
    return ['knocker', d - k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[], ['5H', 'JH', 'AC', '4H'], True, False], ['knocker', 45]], [[[], ['KS', '5S', '4H'], False, False], ['knocker', 19]], [[['KD', 'JH', '9S'], ['JS', '7D'], False, False], ['illegal', 0]], [[['4S', '4D', 'AS'], ['3D', 'JS', 'KD', '7D'], False, False], ['knocker', 21]], [[['TS', 'JC', '5S'], ['4H', '7C'], False, False], ['illegal', 0]], [[[], ['KS', 'TD', '5D', '7D'], False, False], ['knocker', 32]], [[[], [], True, False], ['knocker', 25]], [[[], ['6D'], True, False], ['knocker', 31]]], [[[['6S', '8S', '6C'], ['4C', 'KH', '9S'], False, False], ['illegal', 0]], [[[], [], True, False], ['knocker', 25]], [[['6C'], [], False, False], ['defender', 31]], [[[], ['4D', 'JS'], True, False], ['knocker', 39]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]], [[[], ['KH', '3D'], False, False], ['knocker', 13]], [[[], ['7D', 'TH'], True, False], ['knocker', 42]], [[[], [], True, False], ['knocker', 25]]], [[[['KH', '4H', 'JD'], [], False, False], ['illegal', 0]], [[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[['7D', '7S'], ['2S', 'QC'], False, False], ['illegal', 0]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['3C', '3H', '5S'], True, False], ['knocker', 36]], [[['AC', '9D', 'AD'], ['8S'], False, False], ['illegal', 0]], [[[], ['QC', 'KD', '7D'], True, False], ['knocker', 52]], [[[], [], True, False], ['knocker', 25]]], [[[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[[], ['2C'], False, False], ['knocker', 2]], [[[], ['KD'], False, False], ['knocker', 10]], [[[], [], True, False], ['knocker', 25]], [[['TH', '3H', 'KC'], ['TD', 'AS', 'JD', '5H'], False, False], ['illegal', 0]], [[['TH', '8S'], ['QC', '5S', '2S', '6D'], False, False], ['illegal', 0]], [[[], ['8H', '5D'], False, False], ['knocker', 13]], [[[], [], True, False], ['knocker', 25]]], [[[[], ['8D', 'KC', '7C', 'AC'], False, False], ['knocker', 26]], [[['TH', '6C'], ['6D', 'QC'], False, False], ['illegal', 0]], [[['9C'], ['8S', 'JD'], False, False], ['knocker', 9]], [[['5H', '6D'], ['QH', '8D', 'KH'], False, False], ['illegal', 0]], [[['QC', 'JD'], ['7C', 'KH', '8C', '5S'], False, False], ['illegal', 0]], [[[], ['4D', '3S'], False, False], ['knocker', 7]], [[[], ['7S'], True, False], ['knocker', 32]], [[[], [], True, False], ['knocker', 25]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("knock score case %d" % i, solve(args), 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):
    kc, dc, gin, big = x
    def dw(cards):
        t = 0
        for c in cards:
            r = c[0]
            t += 1 if r == 'A' else 10 if r in 'TJQK' else int(r)
        return t
    k = dw(kc)
    d = dw(dc)
    if k > 10:
        return ['illegal', 0]
    if big:
        return ['knocker', 31 + d]
    if gin:
        return ['knocker', 25]
    if d <= k:
        return ['defender', 25 + k - d]
    return ['knocker', d - k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[], ['5H', 'JH', 'AC', '4H'], True, False], ['knocker', 45]], [[[], ['KS', '5S', '4H'], False, False], ['knocker', 19]], [[['KD', 'JH', '9S'], ['JS', '7D'], False, False], ['illegal', 0]], [[['4S', '4D', 'AS'], ['3D', 'JS', 'KD', '7D'], False, False], ['knocker', 21]], [[['TS', 'JC', '5S'], ['4H', '7C'], False, False], ['illegal', 0]], [[[], ['KS', 'TD', '5D', '7D'], False, False], ['knocker', 32]], [[[], [], True, False], ['knocker', 25]], [[[], ['6D'], True, False], ['knocker', 31]]], [[[['6S', '8S', '6C'], ['4C', 'KH', '9S'], False, False], ['illegal', 0]], [[[], [], True, False], ['knocker', 25]], [[['6C'], [], False, False], ['defender', 31]], [[[], ['4D', 'JS'], True, False], ['knocker', 39]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]], [[[], ['KH', '3D'], False, False], ['knocker', 13]], [[[], ['7D', 'TH'], True, False], ['knocker', 42]], [[[], [], True, False], ['knocker', 25]]], [[[['KH', '4H', 'JD'], [], False, False], ['illegal', 0]], [[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[['7D', '7S'], ['2S', 'QC'], False, False], ['illegal', 0]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['3C', '3H', '5S'], True, False], ['knocker', 36]], [[['AC', '9D', 'AD'], ['8S'], False, False], ['illegal', 0]], [[[], ['QC', 'KD', '7D'], True, False], ['knocker', 52]], [[[], [], True, False], ['knocker', 25]]], [[[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[[], ['2C'], False, False], ['knocker', 2]], [[[], ['KD'], False, False], ['knocker', 10]], [[[], [], True, False], ['knocker', 25]], [[['TH', '3H', 'KC'], ['TD', 'AS', 'JD', '5H'], False, False], ['illegal', 0]], [[['TH', '8S'], ['QC', '5S', '2S', '6D'], False, False], ['illegal', 0]], [[[], ['8H', '5D'], False, False], ['knocker', 13]], [[[], [], True, False], ['knocker', 25]]], [[[[], ['8D', 'KC', '7C', 'AC'], False, False], ['knocker', 26]], [[['TH', '6C'], ['6D', 'QC'], False, False], ['illegal', 0]], [[['9C'], ['8S', 'JD'], False, False], ['knocker', 9]], [[['5H', '6D'], ['QH', '8D', 'KH'], False, False], ['illegal', 0]], [[['QC', 'JD'], ['7C', 'KH', '8C', '5S'], False, False], ['illegal', 0]], [[[], ['4D', '3S'], False, False], ['knocker', 7]], [[[], ['7S'], True, False], ['knocker', 32]], [[[], [], True, False], ['knocker', 25]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("knock score case %d" % i, solve(args), 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:
Going gin against a defender with zero deadwood hands the defender the undercut.

Input [knocker_deadwood_cards, defender_deadwood_after_layoffs, gin, big_gin]. Deadwood: A=1, T/J/Q/K=10, others pip. Knocking above 10 is ["illegal", 0]. Big gin scores 31 + defender deadwood, gin 25 + defender deadwood (gin cannot be undercut). Otherwise if defender deadwood <= knocker deadwood the defender undercuts for 25 + difference; else knocker scores the difference.

split: open-access


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

N = 1
observations = []
def solve(x):
    kc, dc, gin, big = x
    def dw(cards):
        t = 0
        for c in cards:
            r = c[0]
            t += 11 if r == 'A' else 10 if r in 'TJQK' else int(r)
        return t
    k = dw(kc)
    d = dw(dc)
    if k > 10:
        return ['illegal', 0]
    if big:
        return ['knocker', 31 + d]
    if gin:
        return ['knocker', 25 + d]
    if d <= k:
        return ['defender', 25 + k - d]
    return ['knocker', d - k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[], ['5H', 'JH', 'AC', '4H'], True, False], ['knocker', 45]], [[[], ['KS', '5S', '4H'], False, False], ['knocker', 19]], [[['KD', 'JH', '9S'], ['JS', '7D'], False, False], ['illegal', 0]], [[['4S', '4D', 'AS'], ['3D', 'JS', 'KD', '7D'], False, False], ['knocker', 21]], [[['TS', 'JC', '5S'], ['4H', '7C'], False, False], ['illegal', 0]], [[[], ['KS', 'TD', '5D', '7D'], False, False], ['knocker', 32]], [[[], ['7H', '5D'], False, False], ['knocker', 12]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]]], [[[['6S', '8S', '6C'], ['4C', 'KH', '9S'], False, False], ['illegal', 0]], [[[], [], True, False], ['knocker', 25]], [[['6C'], [], False, False], ['defender', 31]], [[[], ['4D', 'JS'], True, False], ['knocker', 39]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]], [[[], ['KH', '3D'], False, False], ['knocker', 13]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['JS', '8H', '7C'], False, False], ['knocker', 25]]], [[[['KH', '4H', 'JD'], [], False, False], ['illegal', 0]], [[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[['7D', '7S'], ['2S', 'QC'], False, False], ['illegal', 0]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['3C', '3H', '5S'], True, False], ['knocker', 36]], [[['AC', '9D', 'AD'], ['8S'], False, False], ['illegal', 0]], [[['AD'], ['KC', '9H', '5C', '5D'], False, False], ['knocker', 28]], [[['3H', '3D'], ['9C', 'KS', '7S'], False, False], ['knocker', 20]]], [[[[], ['JS', '8H', '7C'], False, False], ['knocker', 25]], [[[], ['2C'], False, False], ['knocker', 2]], [[[], ['KD'], False, False], ['knocker', 10]], [[[], [], True, False], ['knocker', 25]], [[['TH', '3H', 'KC'], ['TD', 'AS', 'JD', '5H'], False, False], ['illegal', 0]], [[['TH', '8S'], ['QC', '5S', '2S', '6D'], False, False], ['illegal', 0]], [[['2D', 'AD', '4S'], [], False, False], ['defender', 32]], [[['6H'], ['QH', 'TH', 'TC'], False, False], ['knocker', 24]]], [[[[], ['8D', 'KC', '7C', 'AC'], False, False], ['knocker', 26]], [[['TH', '6C'], ['6D', 'QC'], False, False], ['illegal', 0]], [[['9C'], ['8S', 'JD'], False, False], ['knocker', 9]], [[['5H', '6D'], ['QH', '8D', 'KH'], False, False], ['illegal', 0]], [[['QC', 'JD'], ['7C', 'KH', '8C', '5S'], False, False], ['illegal', 0]], [[[], ['4D', '3S'], False, False], ['knocker', 7]], [[[], ['4S', 'AH', '8C', 'JS'], True, True], ['knocker', 54]], [[['7C', 'AS'], ['8S', 'AH', 'QH'], False, False], ['knocker', 11]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("knock score case %d" % i, solve(args), 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):
    kc, dc, gin, big = x
    def dw(cards):
        t = 0
        for c in cards:
            r = c[0]
            t += 1 if r == 'A' else 10 if r == 'T' else {'J': 11, 'Q': 12, 'K': 13}[r] if r in 'JQK' else int(r)
        return t
    k = dw(kc)
    d = dw(dc)
    if k > 10:
        return ['illegal', 0]
    if big:
        return ['knocker', 31 + d]
    if gin:
        return ['knocker', 25 + d]
    if d <= k:
        return ['defender', 25 + k - d]
    return ['knocker', d - k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[[], ['5H', 'JH', 'AC', '4H'], True, False], ['knocker', 45]], [[[], ['KS', '5S', '4H'], False, False], ['knocker', 19]], [[['KD', 'JH', '9S'], ['JS', '7D'], False, False], ['illegal', 0]], [[['4S', '4D', 'AS'], ['3D', 'JS', 'KD', '7D'], False, False], ['knocker', 21]], [[['TS', 'JC', '5S'], ['4H', '7C'], False, False], ['illegal', 0]], [[[], ['KS', 'TD', '5D', '7D'], False, False], ['knocker', 32]], [[[], ['7H', '5D'], False, False], ['knocker', 12]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]]], [[[['6S', '8S', '6C'], ['4C', 'KH', '9S'], False, False], ['illegal', 0]], [[[], [], True, False], ['knocker', 25]], [[['6C'], [], False, False], ['defender', 31]], [[[], ['4D', 'JS'], True, False], ['knocker', 39]], [[['4S'], ['JH', '9H', '8C'], False, False], ['knocker', 23]], [[[], ['KH', '3D'], False, False], ['knocker', 13]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['JS', '8H', '7C'], False, False], ['knocker', 25]]], [[[['KH', '4H', 'JD'], [], False, False], ['illegal', 0]], [[[], ['8S', 'QD'], True, False], ['knocker', 43]], [[['7D', '7S'], ['2S', 'QC'], False, False], ['illegal', 0]], [[['2C'], ['2D', 'AH', 'JD', '5S'], False, False], ['knocker', 16]], [[[], ['3C', '3H', '5S'], True, False], ['knocker', 36]], [[['AC', '9D', 'AD'], ['8S'], False, False], ['illegal', 0]], [[['AD'], ['KC', '9H', '5C', '5D'], False, False], ['knocker', 28]], [[['3H', '3D'], ['9C', 'KS', '7S'], False, False], ['knocker', 20]]], [[[[], ['JS', '8H', '7C'], False, False], ['knocker', 25]], [[[], ['2C'], False, False], ['knocker', 2]], [[[], ['KD'], False, False], ['knocker', 10]], [[[], [], True, False], ['knocker', 25]], [[['TH', '3H', 'KC'], ['TD', 'AS', 'JD', '5H'], False, False], ['illegal', 0]], [[['TH', '8S'], ['QC', '5S', '2S', '6D'], False, False], ['illegal', 0]], [[['2D', 'AD', '4S'], [], False, False], ['defender', 32]], [[['6H'], ['QH', 'TH', 'TC'], False, False], ['knocker', 24]]], [[[[], ['8D', 'KC', '7C', 'AC'], False, False], ['knocker', 26]], [[['TH', '6C'], ['6D', 'QC'], False, False], ['illegal', 0]], [[['9C'], ['8S', 'JD'], False, False], ['knocker', 9]], [[['5H', '6D'], ['QH', '8D', 'KH'], False, False], ['illegal', 0]], [[['QC', 'JD'], ['7C', 'KH', '8C', '5S'], False, False], ['illegal', 0]], [[[], ['4D', '3S'], False, False], ['knocker', 7]], [[[], ['4S', 'AH', '8C', 'JS'], True, True], ['knocker', 54]], [[['7C', 'AS'], ['8S', 'AH', 'QH'], False, False], ['knocker', 11]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("knock score case %d" % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Hands holding aces are denied a legal knock.

Input [knocker_deadwood_cards, defender_deadwood_after_layoffs, gin, big_gin]. Deadwood: A=1, T/J/Q/K=10, others pip. Knocking above 10 is ["illegal", 0]. Big gin scores 31 + defender deadwood, gin 25 + defender deadwood (gin cannot be undercut). Otherwise if defender deadwood <= knocker deadwood the defender undercuts for 25 + difference; else knocker scores the difference.

split: open-access