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

N = 1
observations = []
def solve(x):
    p, b, shoe = x
    def val(c):
        r = c[0]
        if r == 'A':
            return 1
        if r in 'TJQK':
            return 0
        return int(r)
    def tot(h):
        return sum(val(c) for c in h) % 10
    p = list(p)
    b = list(b)
    k = 0
    pt, bt = tot(p), tot(b)
    if pt < 8 and bt < 8:
        third = None
        if pt <= 5:
            p.append(shoe[k])
            k += 1
            third = tot(p)
        if third is None:
            draw = bt <= 5
        elif bt <= 2:
            draw = True
        elif bt == 3:
            draw = third != 8
        elif bt == 4:
            draw = 2 <= third <= 7
        elif bt == 5:
            draw = 4 <= third <= 7
        elif bt == 6:
            draw = 6 <= third <= 7
        else:
            draw = False
        if draw:
            b.append(shoe[k])
            k += 1
    pt, bt = tot(p), tot(b)
    winner = 'player' if pt > bt else 'banker' if bt > pt else 'tie'
    return [pt, bt, winner, k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['6C', '8D'], ['3H', 'TS'], ['9D', 'QS']], [3, 3, 'tie', 2]], [[['JD', '4H'], ['QC', '8D'], ['TS', '7H']], [4, 8, 'banker', 0]], [[['2H', '8C'], ['7C', 'JS'], ['2C', '7D']], [2, 7, 'banker', 1]], [[['2C', '9D'], ['7C', 'JH'], ['2S', '8H']], [3, 7, 'banker', 1]], [[['5C', '3C'], ['TC', '5H'], ['AC', 'TH']], [8, 5, 'player', 0]], [[['7C', '2C'], ['6H', '3S'], ['AH', '5S']], [9, 9, 'tie', 0]], [[['3H', 'TD'], ['QS', '5C'], ['5D', 'AD']], [8, 6, 'player', 2]], [[['4S', '9H'], ['TS', '4H'], ['KH', '9S']], [3, 4, 'banker', 1]]], [[[['6S', 'QD'], ['6C', '7D'], ['7S', '4D']], [6, 0, 'player', 1]], [[['7H', '3D'], ['JS', 'JH'], ['6H', 'AC']], [6, 1, 'player', 2]], [[['2S', '2C'], ['AS', '7D'], ['2H', '9H']], [4, 8, 'banker', 0]], [[['KC', '6H'], ['9D', 'QS'], ['2C', 'KD']], [6, 9, 'banker', 0]], [[['5S', '6C'], ['6S', '3S'], ['KC', 'KH']], [1, 9, 'banker', 0]], [[['9C', '2H'], ['JC', 'JS'], ['TH', 'QC']], [1, 0, 'player', 2]], [[['AH', 'TS'], ['3D', '2D'], ['7C', 'KC']], [8, 5, 'player', 2]], [[['QC', '5S'], ['QS', '5H'], ['8S', 'JC']], [3, 5, 'banker', 1]]], [[[['4C', '5S'], ['6S', '4H'], ['QC', '3C']], [9, 0, 'player', 0]], [[['5H', '2C'], ['TD', '6C'], ['7S', 'KC']], [7, 6, 'player', 0]], [[['2C', '4D'], ['8D', '3H'], ['KS', '6C']], [6, 1, 'player', 1]], [[['6S', 'QD'], ['8H', '9D'], ['3S', 'TD']], [6, 7, 'banker', 0]], [[['3H', 'TD'], ['QS', '5C'], ['5D', 'AD']], [8, 6, 'player', 2]], [[['6S', 'JS'], ['4D', '6D'], ['2C', 'KD']], [6, 2, 'player', 1]], [[['5D', 'JS'], ['9H', '6D'], ['QH', 'QS']], [5, 5, 'tie', 1]], [[['7D', '6C'], ['8C', '8D'], ['6S', '7S']], [9, 3, 'player', 2]]], [[[['8D', 'TH'], ['QS', '9S'], ['3S', '9H']], [8, 9, 'banker', 0]], [[['AS', '5H'], ['5D', '9D'], ['7S', '5S']], [6, 1, 'player', 1]], [[['7C', 'JD'], ['2H', 'KC'], ['JS', 'AS']], [7, 2, 'player', 1]], [[['TH', '8C'], ['2C', '7H'], ['JH', '4D']], [8, 9, 'banker', 0]], [[['TC', '5D'], ['JC', '7S'], ['7C', '4C']], [2, 7, 'banker', 1]], [[['AS', '5H'], ['6C', '8C'], ['7D', '9S']], [6, 1, 'player', 1]], [[['4H', 'AH'], ['8S', '6C'], ['9D', '7S']], [4, 4, 'tie', 1]], [[['2S', '3H'], ['4C', '2D'], ['6C', '5S']], [1, 1, 'tie', 2]]], [[[['5S', 'JS'], ['KH', 'TC'], ['4C', '9S']], [9, 9, 'tie', 2]], [[['9H', '9S'], ['TS', '4S'], ['TD', 'TC']], [8, 4, 'player', 0]], [[['9D', '9S'], ['2S', '6D'], ['6S', '4C']], [8, 8, 'tie', 0]], [[['2S', '9H'], ['7H', 'AS'], ['AH', '5H']], [1, 8, 'banker', 0]], [[['2C', '6H'], ['3D', 'TH'], ['QD', 'KS']], [8, 3, 'player', 0]], [[['2S', '2H'], ['3C', '9D'], ['KH', '6C']], [4, 8, 'banker', 2]], [[['4H', '8C'], ['3D', 'AS'], ['QH', 'QS']], [2, 4, 'banker', 1]], [[['5S', 'TS'], ['8D', '8C'], ['2H', 'QS']], [7, 6, 'player', 1]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("coup 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, b, shoe = x
    def val(c):
        r = c[0]
        if r == 'A':
            return 1
        if r in 'TJQK':
            return 0
        return int(r)
    def tot(h):
        return sum(val(c) for c in h) % 10
    p = list(p)
    b = list(b)
    k = 0
    pt, bt = tot(p), tot(b)
    if pt < 8 and bt < 8:
        third = None
        if pt <= 5:
            p.append(shoe[k])
            k += 1
            third = tot(p[:-1])
        if third is None:
            draw = bt <= 5
        elif bt <= 2:
            draw = True
        elif bt == 3:
            draw = third != 8
        elif bt == 4:
            draw = 2 <= third <= 7
        elif bt == 5:
            draw = 4 <= third <= 7
        elif bt == 6:
            draw = 6 <= third <= 7
        else:
            draw = False
        if draw:
            b.append(shoe[k])
            k += 1
    pt, bt = tot(p), tot(b)
    winner = 'player' if pt > bt else 'banker' if bt > pt else 'tie'
    return [pt, bt, winner, k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['6C', '8D'], ['3H', 'TS'], ['9D', 'QS']], [3, 3, 'tie', 2]], [[['JD', '4H'], ['QC', '8D'], ['TS', '7H']], [4, 8, 'banker', 0]], [[['2H', '8C'], ['7C', 'JS'], ['2C', '7D']], [2, 7, 'banker', 1]], [[['2C', '9D'], ['7C', 'JH'], ['2S', '8H']], [3, 7, 'banker', 1]], [[['5C', '3C'], ['TC', '5H'], ['AC', 'TH']], [8, 5, 'player', 0]], [[['7C', '2C'], ['6H', '3S'], ['AH', '5S']], [9, 9, 'tie', 0]], [[['3H', 'TD'], ['QS', '5C'], ['5D', 'AD']], [8, 6, 'player', 2]], [[['4S', '9H'], ['TS', '4H'], ['KH', '9S']], [3, 4, 'banker', 1]]], [[[['6S', 'QD'], ['6C', '7D'], ['7S', '4D']], [6, 0, 'player', 1]], [[['7H', '3D'], ['JS', 'JH'], ['6H', 'AC']], [6, 1, 'player', 2]], [[['2S', '2C'], ['AS', '7D'], ['2H', '9H']], [4, 8, 'banker', 0]], [[['KC', '6H'], ['9D', 'QS'], ['2C', 'KD']], [6, 9, 'banker', 0]], [[['5S', '6C'], ['6S', '3S'], ['KC', 'KH']], [1, 9, 'banker', 0]], [[['9C', '2H'], ['JC', 'JS'], ['TH', 'QC']], [1, 0, 'player', 2]], [[['AH', 'TS'], ['3D', '2D'], ['7C', 'KC']], [8, 5, 'player', 2]], [[['QC', '5S'], ['QS', '5H'], ['8S', 'JC']], [3, 5, 'banker', 1]]], [[[['4C', '5S'], ['6S', '4H'], ['QC', '3C']], [9, 0, 'player', 0]], [[['5H', '2C'], ['TD', '6C'], ['7S', 'KC']], [7, 6, 'player', 0]], [[['2C', '4D'], ['8D', '3H'], ['KS', '6C']], [6, 1, 'player', 1]], [[['6S', 'QD'], ['8H', '9D'], ['3S', 'TD']], [6, 7, 'banker', 0]], [[['3H', 'TD'], ['QS', '5C'], ['5D', 'AD']], [8, 6, 'player', 2]], [[['6S', 'JS'], ['4D', '6D'], ['2C', 'KD']], [6, 2, 'player', 1]], [[['5D', 'JS'], ['9H', '6D'], ['QH', 'QS']], [5, 5, 'tie', 1]], [[['7D', '6C'], ['8C', '8D'], ['6S', '7S']], [9, 3, 'player', 2]]], [[[['8D', 'TH'], ['QS', '9S'], ['3S', '9H']], [8, 9, 'banker', 0]], [[['AS', '5H'], ['5D', '9D'], ['7S', '5S']], [6, 1, 'player', 1]], [[['7C', 'JD'], ['2H', 'KC'], ['JS', 'AS']], [7, 2, 'player', 1]], [[['TH', '8C'], ['2C', '7H'], ['JH', '4D']], [8, 9, 'banker', 0]], [[['TC', '5D'], ['JC', '7S'], ['7C', '4C']], [2, 7, 'banker', 1]], [[['AS', '5H'], ['6C', '8C'], ['7D', '9S']], [6, 1, 'player', 1]], [[['4H', 'AH'], ['8S', '6C'], ['9D', '7S']], [4, 4, 'tie', 1]], [[['2S', '3H'], ['4C', '2D'], ['6C', '5S']], [1, 1, 'tie', 2]]], [[[['5S', 'JS'], ['KH', 'TC'], ['4C', '9S']], [9, 9, 'tie', 2]], [[['9H', '9S'], ['TS', '4S'], ['TD', 'TC']], [8, 4, 'player', 0]], [[['9D', '9S'], ['2S', '6D'], ['6S', '4C']], [8, 8, 'tie', 0]], [[['2S', '9H'], ['7H', 'AS'], ['AH', '5H']], [1, 8, 'banker', 0]], [[['2C', '6H'], ['3D', 'TH'], ['QD', 'KS']], [8, 3, 'player', 0]], [[['2S', '2H'], ['3C', '9D'], ['KH', '6C']], [4, 8, 'banker', 2]], [[['4H', '8C'], ['3D', 'AS'], ['QH', 'QS']], [2, 4, 'banker', 1]], [[['5S', 'TS'], ['8D', '8C'], ['2H', 'QS']], [7, 6, 'player', 1]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("coup 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 tableau is consulted with the wrong number.

Input [player_cards, banker_cards, next_shoe_cards]. Values A=1, 2-9 pip, T/J/Q/K 0; totals mod 10. A natural 8/9 on either side stops the coup. Player draws on 0-5. If player stood, banker draws on 0-5; otherwise banker draws on 0-2, on 3 unless the player third card is 8, on 4 vs 2-7, on 5 vs 4-7, on 6 vs 6-7. Return [player_total, banker_total, winner, cards_drawn].

split: open-access


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

N = 1
observations = []
def solve(x):
    p, b, shoe = x
    def val(c):
        r = c[0]
        if r == 'A':
            return 1
        if r in 'TJQK':
            return 0
        return int(r)
    def tot(h):
        return sum(val(c) for c in h) % 10
    p = list(p)
    b = list(b)
    k = 0
    pt, bt = tot(p), tot(b)
    if pt < 8 and bt < 8:
        third = None
        if pt <= 6:
            p.append(shoe[k])
            k += 1
            third = val(p[-1])
        if third is None:
            draw = bt <= 5
        elif bt <= 2:
            draw = True
        elif bt == 3:
            draw = third != 8
        elif bt == 4:
            draw = 2 <= third <= 7
        elif bt == 5:
            draw = 4 <= third <= 7
        elif bt == 6:
            draw = 6 <= third <= 7
        else:
            draw = False
        if draw:
            b.append(shoe[k])
            k += 1
    pt, bt = tot(p), tot(b)
    winner = 'player' if pt > bt else 'banker' if bt > pt else 'tie'
    return [pt, bt, winner, k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['6S', 'TS'], ['7S', 'QS'], ['QC', 'KD']], [6, 7, 'banker', 0]], [[['JD', '4H'], ['QC', '8D'], ['TS', '7H']], [4, 8, 'banker', 0]], [[['2H', '8C'], ['7C', 'JS'], ['2C', '7D']], [2, 7, 'banker', 1]], [[['2C', '9D'], ['7C', 'JH'], ['2S', '8H']], [3, 7, 'banker', 1]], [[['5C', '3C'], ['TC', '5H'], ['AC', 'TH']], [8, 5, 'player', 0]], [[['7C', '2C'], ['6H', '3S'], ['AH', '5S']], [9, 9, 'tie', 0]], [[['KC', 'JD'], ['TC', 'TD'], ['AH', '4S']], [1, 4, 'banker', 2]], [[['AD', '4H'], ['8S', '3C'], ['JC', 'TC']], [5, 1, 'player', 2]]], [[[['6S', 'QD'], ['6C', '7D'], ['7S', '4D']], [6, 0, 'player', 1]], [[['7H', '3D'], ['JS', 'JH'], ['6H', 'AC']], [6, 1, 'player', 2]], [[['2S', '2C'], ['AS', '7D'], ['2H', '9H']], [4, 8, 'banker', 0]], [[['KC', '6H'], ['9D', 'QS'], ['2C', 'KD']], [6, 9, 'banker', 0]], [[['5S', '6C'], ['6S', '3S'], ['KC', 'KH']], [1, 9, 'banker', 0]], [[['9C', '2H'], ['JC', 'JS'], ['TH', 'QC']], [1, 0, 'player', 2]], [[['6S', 'QD'], ['8H', '9D'], ['3S', 'TD']], [6, 7, 'banker', 0]], [[['9D', '6D'], ['3C', 'JC'], ['QS', 'KC']], [5, 3, 'player', 2]]], [[[['4C', '5S'], ['6S', '4H'], ['QC', '3C']], [9, 0, 'player', 0]], [[['5H', '2C'], ['TD', '6C'], ['7S', 'KC']], [7, 6, 'player', 0]], [[['2C', '4D'], ['8D', '3H'], ['KS', '6C']], [6, 1, 'player', 1]], [[['6S', 'QD'], ['8H', '9D'], ['3S', 'TD']], [6, 7, 'banker', 0]], [[['3H', 'TD'], ['QS', '5C'], ['5D', 'AD']], [8, 6, 'player', 2]], [[['6S', 'JS'], ['4D', '6D'], ['2C', 'KD']], [6, 2, 'player', 1]], [[['AS', '5H'], ['6C', '8C'], ['7D', '9S']], [6, 1, 'player', 1]], [[['7D', '8D'], ['JH', 'KH'], ['QS', '3H']], [5, 3, 'player', 2]]], [[[['8D', 'TH'], ['QS', '9S'], ['3S', '9H']], [8, 9, 'banker', 0]], [[['AS', '5H'], ['5D', '9D'], ['7S', '5S']], [6, 1, 'player', 1]], [[['7C', 'JD'], ['2H', 'KC'], ['JS', 'AS']], [7, 2, 'player', 1]], [[['TH', '8C'], ['2C', '7H'], ['JH', '4D']], [8, 9, 'banker', 0]], [[['TC', '5D'], ['JC', '7S'], ['7C', '4C']], [2, 7, 'banker', 1]], [[['AS', '5H'], ['6C', '8C'], ['7D', '9S']], [6, 1, 'player', 1]], [[['6S', 'KH'], ['7C', '8C'], ['8S', 'AD']], [6, 3, 'player', 1]], [[['QC', '5S'], ['QS', '5H'], ['8S', 'JC']], [3, 5, 'banker', 1]]], [[[['5S', 'JS'], ['KH', 'TC'], ['4C', '9S']], [9, 9, 'tie', 2]], [[['9H', '9S'], ['TS', '4S'], ['TD', 'TC']], [8, 4, 'player', 0]], [[['9D', '9S'], ['2S', '6D'], ['6S', '4C']], [8, 8, 'tie', 0]], [[['2S', '9H'], ['7H', 'AS'], ['AH', '5H']], [1, 8, 'banker', 0]], [[['2C', '6H'], ['3D', 'TH'], ['QD', 'KS']], [8, 3, 'player', 0]], [[['2S', '2H'], ['3C', '9D'], ['KH', '6C']], [4, 8, 'banker', 2]], [[['TS', '6S'], ['TC', 'KD'], ['5H', 'AC']], [6, 5, 'player', 1]], [[['2H', '3D'], ['2C', 'TC'], ['9D', '8D']], [4, 0, 'player', 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("coup 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):
    p, b, shoe = x
    def val(c):
        r = c[0]
        if r == 'A':
            return 1
        if r in 'TJQK':
            return 0
        return int(r)
    def tot(h):
        return sum(val(c) for c in h) % 10
    p = list(p)
    b = list(b)
    k = 0
    pt, bt = tot(p), tot(b)
    if pt < 8 and bt < 8:
        third = None
        if pt < 5:
            p.append(shoe[k])
            k += 1
            third = val(p[-1])
        if third is None:
            draw = bt <= 5
        elif bt <= 2:
            draw = True
        elif bt == 3:
            draw = third != 8
        elif bt == 4:
            draw = 2 <= third <= 7
        elif bt == 5:
            draw = 4 <= third <= 7
        elif bt == 6:
            draw = 6 <= third <= 7
        else:
            draw = False
        if draw:
            b.append(shoe[k])
            k += 1
    pt, bt = tot(p), tot(b)
    winner = 'player' if pt > bt else 'banker' if bt > pt else 'tie'
    return [pt, bt, winner, k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['6S', 'TS'], ['7S', 'QS'], ['QC', 'KD']], [6, 7, 'banker', 0]], [[['JD', '4H'], ['QC', '8D'], ['TS', '7H']], [4, 8, 'banker', 0]], [[['2H', '8C'], ['7C', 'JS'], ['2C', '7D']], [2, 7, 'banker', 1]], [[['2C', '9D'], ['7C', 'JH'], ['2S', '8H']], [3, 7, 'banker', 1]], [[['5C', '3C'], ['TC', '5H'], ['AC', 'TH']], [8, 5, 'player', 0]], [[['7C', '2C'], ['6H', '3S'], ['AH', '5S']], [9, 9, 'tie', 0]], [[['KC', 'JD'], ['TC', 'TD'], ['AH', '4S']], [1, 4, 'banker', 2]], [[['AD', '4H'], ['8S', '3C'], ['JC', 'TC']], [5, 1, 'player', 2]]], [[[['6S', 'QD'], ['6C', '7D'], ['7S', '4D']], [6, 0, 'player', 1]], [[['7H', '3D'], ['JS', 'JH'], ['6H', 'AC']], [6, 1, 'player', 2]], [[['2S', '2C'], ['AS', '7D'], ['2H', '9H']], [4, 8, 'banker', 0]], [[['KC', '6H'], ['9D', 'QS'], ['2C', 'KD']], [6, 9, 'banker', 0]], [[['5S', '6C'], ['6S', '3S'], ['KC', 'KH']], [1, 9, 'banker', 0]], [[['9C', '2H'], ['JC', 'JS'], ['TH', 'QC']], [1, 0, 'player', 2]], [[['6S', 'QD'], ['8H', '9D'], ['3S', 'TD']], [6, 7, 'banker', 0]], [[['9D', '6D'], ['3C', 'JC'], ['QS', 'KC']], [5, 3, 'player', 2]]], [[[['4C', '5S'], ['6S', '4H'], ['QC', '3C']], [9, 0, 'player', 0]], [[['5H', '2C'], ['TD', '6C'], ['7S', 'KC']], [7, 6, 'player', 0]], [[['2C', '4D'], ['8D', '3H'], ['KS', '6C']], [6, 1, 'player', 1]], [[['6S', 'QD'], ['8H', '9D'], ['3S', 'TD']], [6, 7, 'banker', 0]], [[['3H', 'TD'], ['QS', '5C'], ['5D', 'AD']], [8, 6, 'player', 2]], [[['6S', 'JS'], ['4D', '6D'], ['2C', 'KD']], [6, 2, 'player', 1]], [[['AS', '5H'], ['6C', '8C'], ['7D', '9S']], [6, 1, 'player', 1]], [[['7D', '8D'], ['JH', 'KH'], ['QS', '3H']], [5, 3, 'player', 2]]], [[[['8D', 'TH'], ['QS', '9S'], ['3S', '9H']], [8, 9, 'banker', 0]], [[['AS', '5H'], ['5D', '9D'], ['7S', '5S']], [6, 1, 'player', 1]], [[['7C', 'JD'], ['2H', 'KC'], ['JS', 'AS']], [7, 2, 'player', 1]], [[['TH', '8C'], ['2C', '7H'], ['JH', '4D']], [8, 9, 'banker', 0]], [[['TC', '5D'], ['JC', '7S'], ['7C', '4C']], [2, 7, 'banker', 1]], [[['AS', '5H'], ['6C', '8C'], ['7D', '9S']], [6, 1, 'player', 1]], [[['6S', 'KH'], ['7C', '8C'], ['8S', 'AD']], [6, 3, 'player', 1]], [[['QC', '5S'], ['QS', '5H'], ['8S', 'JC']], [3, 5, 'banker', 1]]], [[[['5S', 'JS'], ['KH', 'TC'], ['4C', '9S']], [9, 9, 'tie', 2]], [[['9H', '9S'], ['TS', '4S'], ['TD', 'TC']], [8, 4, 'player', 0]], [[['9D', '9S'], ['2S', '6D'], ['6S', '4C']], [8, 8, 'tie', 0]], [[['2S', '9H'], ['7H', 'AS'], ['AH', '5H']], [1, 8, 'banker', 0]], [[['2C', '6H'], ['3D', 'TH'], ['QD', 'KS']], [8, 3, 'player', 0]], [[['2S', '2H'], ['3C', '9D'], ['KH', '6C']], [4, 8, 'banker', 2]], [[['TS', '6S'], ['TC', 'KD'], ['5H', 'AC']], [6, 5, 'player', 1]], [[['2H', '3D'], ['2C', 'TC'], ['9D', '8D']], [4, 0, 'player', 2]]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("coup 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:
Player takes a third card on 6.

Input [player_cards, banker_cards, next_shoe_cards]. Values A=1, 2-9 pip, T/J/Q/K 0; totals mod 10. A natural 8/9 on either side stops the coup. Player draws on 0-5. If player stood, banker draws on 0-5; otherwise banker draws on 0-2, on 3 unless the player third card is 8, on 4 vs 2-7, on 5 vs 4-7, on 6 vs 6-7. Return [player_total, banker_total, winner, cards_drawn].

split: open-access


prompt:
The dealer receives the first batch.

Input [players, dealer, batch_pattern, deck]. For each batch size in order, deal that many cards to each player starting left of the dealer (dealer+1) clockwise. Remaining cards form the kitty. Return [hands_by_seat, kitty].

split: open-access


prompt:
When no cards remain, the kitty repeats the deck.

Input [players, dealer, batch_pattern, deck]. For each batch size in order, deal that many cards to each player starting left of the dealer (dealer+1) clockwise. Remaining cards form the kitty. Return [hands_by_seat, kitty].

split: open-access


prompt:
In a 3-2 deal the first player gets five consecutive cards.

Input [players, dealer, batch_pattern, deck]. For each batch size in order, deal that many cards to each player starting left of the dealer (dealer+1) clockwise. Remaining cards form the kitty. Return [hands_by_seat, kitty].

split: open-access


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

N = 1
observations = []
def solve(x):
    cards, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AC', '5H'], 0, True, True], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['4D', 'QS'], 3, True, False], ['stand']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['6S', '6H'], 2, True, True], ['stand']], [[['6H', '4H'], 1, True, True], ['stand']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['3C', '3D'], 0, True, True], ['stand']], [[['8D', 'AH'], 2, True, True], ['stand']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['7S', '7D'], 3, True, True], ['stand']], [[['TS', 'KC'], 0, True, True], ['stand']]], [[[['5H', '6C'], 2, True, True], ['stand']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['AH', 'KH', '5S'], 1, True, False], ['stand']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces and len(cards) > 2:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AC', '5H'], 0, True, True], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['4D', 'QS'], 3, True, False], ['stand']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['6S', '6H'], 2, True, True], ['stand']], [[['6H', '4H'], 1, True, True], ['stand']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['3C', '3D'], 0, True, True], ['stand']], [[['8D', 'AH'], 2, True, True], ['stand']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['7S', '7D'], 3, True, True], ['stand']], [[['TS', 'KC'], 0, True, True], ['stand']]], [[[['5H', '6C'], 2, True, True], ['stand']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['AH', 'KH', '5S'], 1, True, False], ['stand']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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 hand from split aces can draw more cards.

Input [cards, splits_so_far, from_split_aces, double_after_split]. Split-ace hands may only stand. A total >= 21 may only stand. Otherwise hit; double on two cards if no split yet or DAS allowed; split two cards of equal value if fewer than 3 splits so far; surrender on two cards with no split. Return the action list.

split: open-access


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

N = 1
observations = []
def solve(x):
    cards, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two:
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'AH'], 2, False, False], ['stand', 'hit', 'split']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['6C', '6H'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['JH', 'JS'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['TD', 'TH'], 2, False, False], ['stand', 'hit', 'split']], [[['7H', '6C'], 0, False, False], ['stand', 'hit', 'double', 'surrender']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['QH', '7C'], 3, False, False], ['stand', 'hit']], [[['4C', '4D'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and das:
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'AH'], 2, False, False], ['stand', 'hit', 'split']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['6C', '6H'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['JH', 'JS'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['TD', 'TH'], 2, False, False], ['stand', 'hit', 'split']], [[['7H', '6C'], 0, False, False], ['stand', 'hit', 'double', 'surrender']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['QH', '7C'], 3, False, False], ['stand', 'hit']], [[['4C', '4D'], 0, False, False], ['stand', 'hit', 'double', 'split', 'surrender']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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 can double on tables that forbid it.

Input [cards, splits_so_far, from_split_aces, double_after_split]. Split-ace hands may only stand. A total >= 21 may only stand. Otherwise hit; double on two cards if no split yet or DAS allowed; split two cards of equal value if fewer than 3 splits so far; surrender on two cards with no split. Return the action list.

split: open-access


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

N = 1
observations = []
def solve(x):
    cards, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits <= 3:
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['KH', '9H', '2S', '9D'], 3, False, False], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['TC', 'TD'], 3, False, False], ['stand', 'hit']], [[['5D', '5H'], 3, False, False], ['stand', 'hit']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2D', '2D'], 3, False, False], ['stand', 'hit']], [[['QS', 'QD'], 3, False, False], ['stand', 'hit']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['5D', '5H'], 3, False, False], ['stand', 'hit']], [[['KD', 'KC'], 3, False, False], ['stand', 'hit']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['TC', 'TD'], 3, False, False], ['stand', 'hit']], [[['QS', 'QD'], 3, False, False], ['stand', 'hit']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['QS', 'QD'], 3, False, False], ['stand', 'hit']], [[['8S', '8H'], 3, False, True], ['stand', 'hit', 'double']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]):
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['KH', '9H', '2S', '9D'], 3, False, False], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['TC', 'TD'], 3, False, False], ['stand', 'hit']], [[['5D', '5H'], 3, False, False], ['stand', 'hit']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2D', '2D'], 3, False, False], ['stand', 'hit']], [[['QS', 'QD'], 3, False, False], ['stand', 'hit']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['5D', '5H'], 3, False, False], ['stand', 'hit']], [[['KD', 'KC'], 3, False, False], ['stand', 'hit']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['TC', 'TD'], 3, False, False], ['stand', 'hit']], [[['QS', 'QD'], 3, False, False], ['stand', 'hit']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['QS', 'QD'], 3, False, False], ['stand', 'hit']], [[['8S', '8H'], 3, False, True], ['stand', 'hit', 'double']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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:
Players can split into five hands.

Input [cards, splits_so_far, from_split_aces, double_after_split]. Split-ace hands may only stand. A total >= 21 may only stand. Otherwise hit; double on two cards if no split yet or DAS allowed; split two cards of equal value if fewer than 3 splits so far; surrender on two cards with no split. Return the action list.

split: open-access


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

N = 1
observations = []
def solve(x):
    cards, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if two:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'AH'], 2, False, False], ['stand', 'hit', 'split']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['9C', '2S', '9H'], 0, False, True], ['stand', 'hit']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['KH', '9H'], 1, False, True], ['stand', 'hit', 'double']], [[['AC', '4H', '4S'], 0, False, False], ['stand', 'hit']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['KC', 'KH'], 1, True, True], ['stand']], [[['KS', '3D', '2C'], 0, False, False], ['stand', 'hit']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['6D', '2C', '8D', 'AD'], 0, False, True], ['stand', 'hit']]], [[[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'AH'], 2, False, False], ['stand', 'hit', 'split']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['9C', '2S', '9H'], 0, False, True], ['stand', 'hit']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['KH', '9H'], 1, False, True], ['stand', 'hit', 'double']], [[['AC', '4H', '4S'], 0, False, False], ['stand', 'hit']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['KC', 'KH'], 1, True, True], ['stand']], [[['KS', '3D', '2C'], 0, False, False], ['stand', 'hit']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['6D', '2C', '8D', 'AD'], 0, False, True], ['stand', 'hit']]], [[[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['2H', 'KD'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['2C', 'KS'], 3, False, False], ['stand', 'hit']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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 may surrender.

Input [cards, splits_so_far, from_split_aces, double_after_split]. Split-ace hands may only stand. A total >= 21 may only stand. Otherwise hit; double on two cards if no split yet or DAS allowed; split two cards of equal value if fewer than 3 splits so far; surrender on two cards with no split. Return the action list.

split: open-access


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

N = 1
observations = []
def solve(x):
    cards, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total > 21:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'QS'], 0, False, False], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['JH', '6S', 'TH'], 3, False, False], ['stand']], [[['3S', '9S', '9D'], 3, False, False], ['stand']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['4H', 'AD', 'QC', 'JC'], 3, False, True], ['stand']], [[['KS', 'AC'], 2, False, True], ['stand']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['KD', 'KD', 'JH', '6C'], 0, False, False], ['stand']], [[['9S', 'TH', '2D'], 0, False, True], ['stand']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['JH', 'JD', 'AS'], 0, False, True], ['stand']], [[['QC', 'QH', 'TH', '8H'], 0, False, False], ['stand']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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, splits, from_aces, das = x
    def v(c):
        return 10 if c[0] in 'TJQK' else 11 if c[0] == 'A' else int(c[0])
    acts = ['stand']
    if from_aces:
        return acts
    total = 0
    aces = 0
    for c in cards:
        total += v(c)
        aces += c[0] == 'A'
    while total > 21 and aces:
        total -= 10
        aces -= 1
    if total >= 21 and len(cards) == 2:
        return acts
    acts.append('hit')
    two = len(cards) == 2
    if two and (splits == 0 or das):
        acts.append('double')
    if two and v(cards[0]) == v(cards[1]) and splits < 3:
        acts.append('split')
    if two and splits == 0:
        acts.append('surrender')
    return acts
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[['AD', 'QS'], 0, False, False], ['stand']], [[['8C', 'TD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['9S', '3C', 'QC'], 1, False, True], ['stand']], [[['8H', '8C', 'KC'], 1, False, False], ['stand']], [[['5H', '6C'], 2, True, True], ['stand']], [[['9S', 'QD', '2H', '4C'], 1, True, True], ['stand']], [[['6D', '6C', '3C'], 0, False, False], ['stand', 'hit']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']]], [[[['2S', '8S'], 1, False, False], ['stand', 'hit']], [[['TD', 'TD', '7D', '6S'], 0, True, True], ['stand']], [[['3S', '3C'], 3, True, True], ['stand']], [[['AC', '6S', 'TC', 'KH'], 1, False, False], ['stand']], [[['QH', 'TS'], 2, False, False], ['stand', 'hit', 'split']], [[['4H', '2D'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['JH', '6S', 'TH'], 3, False, False], ['stand']], [[['3S', '9S', '9D'], 3, False, False], ['stand']]], [[[['KD', '3D'], 3, False, False], ['stand', 'hit']], [[['3H', '7S'], 2, False, True], ['stand', 'hit', 'double']], [[['6S', '6H'], 2, True, True], ['stand']], [[['QD', 'QS', 'TC'], 0, False, True], ['stand']], [[['JC', 'JS'], 1, False, True], ['stand', 'hit', 'double', 'split']], [[['JH', 'JC'], 1, False, False], ['stand', 'hit', 'split']], [[['4H', 'AD', 'QC', 'JC'], 3, False, True], ['stand']], [[['KS', 'AC'], 2, False, True], ['stand']]], [[[['5D', '5C', '9S', '6C'], 0, False, False], ['stand']], [[['4S', '4D', 'TH'], 2, True, True], ['stand']], [[['5D', '5C', '6C', 'TC'], 2, False, False], ['stand']], [[['4H', '4C'], 0, False, True], ['stand', 'hit', 'double', 'split', 'surrender']], [[['3S', 'JS', 'QC', '2S'], 0, False, True], ['stand']], [[['8H', '6S', '9H', '8C'], 0, True, True], ['stand']], [[['KD', 'KD', 'JH', '6C'], 0, False, False], ['stand']], [[['9S', 'TH', '2D'], 0, False, True], ['stand']]], [[[['6C', '4C'], 3, False, True], ['stand', 'hit', 'double']], [[['2C', 'QD'], 0, False, True], ['stand', 'hit', 'double', 'surrender']], [[['3H', '8S'], 1, False, True], ['stand', 'hit', 'double']], [[['3C', '3D'], 0, True, True], ['stand']], [[['6S', 'KH'], 0, False, False], ['stand', 'hit', 'double', 'surrender']], [[['5H', '5C', 'JD', '4D'], 1, True, False], ['stand']], [[['JH', 'JD', 'AS'], 0, False, True], ['stand']], [[['QC', 'QH', 'TH', '8H'], 0, False, False], ['stand']]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("actions 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:
Players at 21 can still draw.

Input [cards, splits_so_far, from_split_aces, double_after_split]. Split-ace hands may only stand. A total >= 21 may only stand. Otherwise hit; double on two cards if no split yet or DAS allowed; split two cards of equal value if fewer than 3 splits so far; surrender on two cards with no split. Return the action list.

split: open-access


prompt:
A single 2 can be topped by an ace.

Input [current_combination, play]. Ranks 3 low to 2 high; suits D<C<H<S. A play is 1-3 cards of one rank. On an empty table any valid play is "ok"; otherwise it must have the same size and its highest card must outrank the current highest card (rank, then suit). Empty play is "pass". Return "ok", "invalid" or "pass".

split: open-access


prompt:
5S cannot be played over 5D.

Input [current_combination, play]. Ranks 3 low to 2 high; suits D<C<H<S. A play is 1-3 cards of one rank. On an empty table any valid play is "ok"; otherwise it must have the same size and its highest card must outrank the current highest card (rank, then suit). Empty play is "pass". Return "ok", "invalid" or "pass".

split: open-access


prompt:
Plays of a different size are compared by rank alone.

Input [current_combination, play]. Ranks 3 low to 2 high; suits D<C<H<S. A play is 1-3 cards of one rank. On an empty table any valid play is "ok"; otherwise it must have the same size and its highest card must outrank the current highest card (rank, then suit). Empty play is "pass". Return "ok", "invalid" or "pass".

split: open-access


prompt:
5D-5S cannot beat 5C-5H.

Input [current_combination, play]. Ranks 3 low to 2 high; suits D<C<H<S. A play is 1-3 cards of one rank. On an empty table any valid play is "ok"; otherwise it must have the same size and its highest card must outrank the current highest card (rank, then suit). Empty play is "pass". Return "ok", "invalid" or "pass".

split: open-access


prompt:
Four same-rank cards are played like a triple.

Input [current_combination, play]. Ranks 3 low to 2 high; suits D<C<H<S. A play is 1-3 cards of one rank. On an empty table any valid play is "ok"; otherwise it must have the same size and its highest card must outrank the current highest card (rank, then suit). Empty play is "pass". Return "ok", "invalid" or "pass".

split: open-access


prompt:
A trump run scores 190 instead of 150.

Input [hand, trump]. Arounds (one of the rank in each suit): A 100, K 80, Q 60, J 40; double around x10. Run in trump (A T K Q J) 150 each; marriages (K+Q same suit) 20, royal marriage in trump 40, but a K+Q used in a run is not also a royal marriage. Pinochle (JD+QS) 40, double pinochle 300. Return the meld total.

split: open-access


prompt:
Eight aces score 200 instead of 1000.

Input [hand, trump]. Arounds (one of the rank in each suit): A 100, K 80, Q 60, J 40; double around x10. Run in trump (A T K Q J) 150 each; marriages (K+Q same suit) 20, royal marriage in trump 40, but a K+Q used in a run is not also a royal marriage. Pinochle (JD+QS) 40, double pinochle 300. Return the meld total.

split: open-access


prompt:
Both jacks of diamonds and queens of spades score 80.

Input [hand, trump]. Arounds (one of the rank in each suit): A 100, K 80, Q 60, J 40; double around x10. Run in trump (A T K Q J) 150 each; marriages (K+Q same suit) 20, royal marriage in trump 40, but a K+Q used in a run is not also a royal marriage. Pinochle (JD+QS) 40, double pinochle 300. Return the meld total.

split: open-access


prompt:
A royal marriage scores 20.

Input [hand, trump]. Arounds (one of the rank in each suit): A 100, K 80, Q 60, J 40; double around x10. Run in trump (A T K Q J) 150 each; marriages (K+Q same suit) 20, royal marriage in trump 40, but a K+Q used in a run is not also a royal marriage. Pinochle (JD+QS) 40, double pinochle 300. Return the meld total.

split: open-access


prompt:
The dealer is unrestricted.

Input [bids_so_far, players, hand_size]. Bids range 0..hand_size. The last bidder (dealer) may not bid the amount that makes the total of bids equal hand_size. Return the allowed bids ascending.

split: open-access


prompt:
A bid equal to the hand size is missing.

Input [bids_so_far, players, hand_size]. Bids range 0..hand_size. The last bidder (dealer) may not bid the amount that makes the total of bids equal hand_size. Return the allowed bids ascending.

split: open-access


prompt:
The wrong bid is removed from the dealer choices.

Input [bids_so_far, players, hand_size]. Bids range 0..hand_size. The last bidder (dealer) may not bid the amount that makes the total of bids equal hand_size. Return the allowed bids ascending.

split: open-access


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

N = 1
observations = []
def solve(x):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'ATKQ987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in seq:
        if card in has:
            mat += 1
        else:
            break
    mult = mat + 1
    if hand:
        mult += 1
    if schneider or schwarz:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['D', ['DJ', 'TD', 'KD', 'QD', '9D', '8D'], False, True, True], 54], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'SJ'], False, False, False], 72], [['C', ['9C', '8C', '7C'], False, False, False], 108]], [[['S', ['CJ', 'DJ', 'AS', '9S', '8S', '7S'], False, False, False], 22], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['H', ['AH', 'KH', '8H'], False, True, True], 70], [['S', ['KS', 'QS', '9S', '8S', '7S'], True, False, False], 88]], [[['D', ['CJ', 'HJ', 'KD', '9D', '8D'], False, True, False], 27], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['H', [], False, True, False], 130], [['H', ['7H'], False, False, False], 110]], [[['H', ['DJ', 'TH', 'KH', 'QH', '7H'], False, False, False], 40], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['D', ['SJ', 'HJ', 'AD', 'TD', 'KD'], False, False, False], 18], [['H', ['8H', '7H'], False, True, True], 120]], [[['D', ['SJ', 'HJ', 'AD', 'TD', 'KD'], False, False, False], 18], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['D', ['CJ', 'SJ', 'AD', 'TD', 'QD', '8D', '7D'], False, False, False], 27], [['C', ['QC', '9C', '8C', '7C'], False, True, False], 108]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'ATKQ987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in (seq if first else seq[:4]):
        if (card in has) == first:
            mat += 1
        else:
            break
    mult = mat + 1
    if hand:
        mult += 1
    if schneider or schwarz:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['D', ['DJ', 'TD', 'KD', 'QD', '9D', '8D'], False, True, True], 54], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'SJ'], False, False, False], 72], [['C', ['9C', '8C', '7C'], False, False, False], 108]], [[['S', ['CJ', 'DJ', 'AS', '9S', '8S', '7S'], False, False, False], 22], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['H', ['AH', 'KH', '8H'], False, True, True], 70], [['S', ['KS', 'QS', '9S', '8S', '7S'], True, False, False], 88]], [[['D', ['CJ', 'HJ', 'KD', '9D', '8D'], False, True, False], 27], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['H', [], False, True, False], 130], [['H', ['7H'], False, False, False], 110]], [[['H', ['DJ', 'TH', 'KH', 'QH', '7H'], False, False, False], 40], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['D', ['SJ', 'HJ', 'AD', 'TD', 'KD'], False, False, False], 18], [['H', ['8H', '7H'], False, True, True], 120]], [[['D', ['SJ', 'HJ', 'AD', 'TD', 'KD'], False, False, False], 18], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['D', ['CJ', 'SJ', 'AD', 'TD', 'QD', '8D', '7D'], False, False, False], 27], [['C', ['QC', '9C', '8C', '7C'], False, True, False], 108]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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:
Declarers missing the top trumps score only the game level.

Input [game(D/H/S/C/G), trumps_held, hand, schneider, schwarz]. Base D9 H10 S11 C12 G24. Matadors count the unbroken run from CJ down the trump sequence (CJ SJ HJ DJ then A T K Q 9 8 7 of the suit; grand only jacks), either held ("with") or missing ("without"). Multiplier = matadors + 1 (game) + hand + schneider (implied by schwarz) + schwarz. Return base * multiplier.

split: open-access


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

N = 1
observations = []
def solve(x):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'AKQT987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in seq:
        if (card in has) == first:
            mat += 1
        else:
            break
    mult = mat + 1
    if hand:
        mult += 1
    if schneider or schwarz:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'TS', 'KS'], False, False, False], 88], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'SJ'], False, False, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'KD', '9D', '8D'], False, False, False], 54]], [[['S', ['CJ', 'DJ', 'AS', '9S', '8S', '7S'], False, False, False], 22], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'TC', 'KC', '9C', '7C'], True, True, False], 84]], [[['D', ['CJ', 'HJ', 'KD', '9D', '8D'], False, True, False], 27], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['S', ['QS', '9S', '8S', '7S'], False, True, False], 99], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH'], False, False, False], 60]], [[['H', ['DJ', 'TH', 'KH', 'QH', '7H'], False, False, False], 40], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['D', ['QD', '9D', '8D', '7D'], True, False, False], 81], [['S', ['CJ', 'SJ', 'HJ', 'DJ', 'TS'], False, False, False], 55]], [[['D', ['SJ', 'HJ', 'AD', 'QD', '7D'], False, False, False], 18], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'KS', 'QS', '7S'], False, True, True], 88], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, False, False], 96]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'TAKQ987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in seq:
        if (card in has) == first:
            mat += 1
        else:
            break
    mult = mat + 1
    if hand:
        mult += 1
    if schneider or schwarz:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'TS', 'KS'], False, False, False], 88], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'SJ'], False, False, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'KD', '9D', '8D'], False, False, False], 54]], [[['S', ['CJ', 'DJ', 'AS', '9S', '8S', '7S'], False, False, False], 22], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'TC', 'KC', '9C', '7C'], True, True, False], 84]], [[['D', ['CJ', 'HJ', 'KD', '9D', '8D'], False, True, False], 27], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['S', ['QS', '9S', '8S', '7S'], False, True, False], 99], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH'], False, False, False], 60]], [[['H', ['DJ', 'TH', 'KH', 'QH', '7H'], False, False, False], 40], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['D', ['QD', '9D', '8D', '7D'], True, False, False], 81], [['S', ['CJ', 'SJ', 'HJ', 'DJ', 'TS'], False, False, False], 55]], [[['D', ['SJ', 'HJ', 'AD', 'QD', '7D'], False, False, False], 18], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'KS', 'QS', '7S'], False, True, True], 88], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, False, False], 96]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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:
Runs through A-10-K are broken at the wrong card.

Input [game(D/H/S/C/G), trumps_held, hand, schneider, schwarz]. Base D9 H10 S11 C12 G24. Matadors count the unbroken run from CJ down the trump sequence (CJ SJ HJ DJ then A T K Q 9 8 7 of the suit; grand only jacks), either held ("with") or missing ("without"). Multiplier = matadors + 1 (game) + hand + schneider (implied by schwarz) + schwarz. Return base * multiplier.

split: open-access


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

N = 1
observations = []
def solve(x):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'ATKQ987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in seq:
        if (card in has) == first:
            mat += 1
        else:
            break
    mult = mat
    if hand:
        mult += 1
    if schneider or schwarz:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'TS', 'KS'], False, False, False], 88], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'SJ'], False, False, False], 72], [['C', ['CJ', 'SJ', 'DJ', 'AC', 'TC', '9C'], True, False, False], 48]], [[['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'TS', 'KS', 'QS', '9S', '8S'], False, True, False], 132], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['H', ['AH', 'KH', '8H'], False, True, True], 70], [['S', ['CJ', 'SJ'], True, True, False], 55]], [[['C', ['CJ', 'SJ'], False, False, False], 36], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['H', [], False, True, False], 130], [['D', ['CJ', 'SJ', 'HJ'], True, False, False], 45]], [[['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['D', ['SJ', 'HJ', 'AD', 'TD', 'KD'], False, False, False], 18], [['S', ['SJ', 'HJ', 'DJ', '9S'], True, False, False], 33]], [[['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['D', ['CJ', 'SJ', 'AD', 'TD', 'QD', '8D', '7D'], False, False, False], 27], [['S', ['CJ', 'SJ', 'TS', 'KS', 'QS'], True, True, True], 66]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'ATKQ987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in seq:
        if (card in has) == first:
            mat += 1
        else:
            break
    mult = mat + 1 if not hand else mat
    if hand:
        mult += 1
    if schneider or schwarz:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'TS', 'KS'], False, False, False], 88], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'SJ'], False, False, False], 72], [['C', ['CJ', 'SJ', 'DJ', 'AC', 'TC', '9C'], True, False, False], 48]], [[['S', ['CJ', 'SJ', 'HJ', 'DJ', 'AS', 'TS', 'KS', 'QS', '9S', '8S'], False, True, False], 132], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['H', ['AH', 'KH', '8H'], False, True, True], 70], [['S', ['CJ', 'SJ'], True, True, False], 55]], [[['C', ['CJ', 'SJ'], False, False, False], 36], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['H', [], False, True, False], 130], [['D', ['CJ', 'SJ', 'HJ'], True, False, False], 45]], [[['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['D', ['SJ', 'HJ', 'AD', 'TD', 'KD'], False, False, False], 18], [['S', ['SJ', 'HJ', 'DJ', '9S'], True, False, False], 33]], [[['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['D', ['CJ', 'SJ', 'AD', 'TD', 'QD', '8D', '7D'], False, False, False], 27], [['S', ['CJ', 'SJ', 'TS', 'KS', 'QS'], True, True, True], 66]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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:
Every game value is one base short.

Input [game(D/H/S/C/G), trumps_held, hand, schneider, schwarz]. Base D9 H10 S11 C12 G24. Matadors count the unbroken run from CJ down the trump sequence (CJ SJ HJ DJ then A T K Q 9 8 7 of the suit; grand only jacks), either held ("with") or missing ("without"). Multiplier = matadors + 1 (game) + hand + schneider (implied by schwarz) + schwarz. Return base * multiplier.

split: open-access


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

N = 1
observations = []
def solve(x):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'ATKQ987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in seq:
        if (card in has) == first:
            mat += 1
        else:
            break
    mult = mat + 1
    if hand:
        mult += 1
    if schneider:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['D', ['CJ', 'HJ', 'QD', '9D', '8D'], True, False, False], 27], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'HJ'], False, True, False], 72], [['C', ['9C', '8C', '7C'], False, False, True], 132]], [[['S', ['CJ', 'DJ', 'AS', '9S', '8S', '7S'], False, False, False], 22], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['H', ['SJ', 'DJ', 'QH', '7H'], False, False, True], 40]], [[['D', ['CJ', 'HJ', 'KD', '9D', '8D'], False, True, False], 27], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['S', ['CJ'], False, True, False], 33]], [[['H', ['DJ', 'TH', 'KH', 'QH', '7H'], False, False, False], 40], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], False, True, False], 100], [['H', ['SJ', 'DJ', 'QH', '7H'], False, False, True], 40]], [[['C', ['9C', '8C', '7C'], False, False, True], 132], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['D', ['CJ', 'SJ', 'AD', 'TD', 'QD', '8D', '7D'], False, False, False], 27], [['G', ['HJ', 'DJ'], False, True, False], 96]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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):
    game, held, hand, schneider, schwarz = x
    base = {'D': 9, 'H': 10, 'S': 11, 'C': 12, 'G': 24}[game]
    seq = ['CJ', 'SJ', 'HJ', 'DJ']
    if game != 'G':
        seq += [r + game for r in 'ATKQ987']
    has = set(held)
    first = seq[0] in has
    mat = 0
    for card in seq:
        if (card in has) == first:
            mat += 1
        else:
            break
    mult = mat + 1
    if hand:
        mult += 1
    if schneider and schwarz:
        mult += 1
    if schwarz:
        mult += 1
    return base * mult
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[['D', ['CJ', 'HJ', 'QD', '9D', '8D'], True, False, False], 27], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC'], False, True, False], 108], [['C', ['CJ', 'SJ', 'HJ'], True, False, False], 60], [['G', ['CJ', 'SJ', 'DJ'], True, False, False], 96], [['C', ['CJ', 'SJ', 'HJ', 'DJ', 'AC', 'TC', 'KC', 'QC', '9C', '8C'], True, True, False], 156], [['H', ['AH', 'TH', 'KH', 'QH', '9H', '8H', '7H'], False, True, False], 60], [['G', ['CJ', 'HJ'], False, True, False], 72], [['C', ['9C', '8C', '7C'], False, False, True], 132]], [[['S', ['CJ', 'DJ', 'AS', '9S', '8S', '7S'], False, False, False], 22], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH'], False, False, False], 80], [['D', ['7D'], False, False, False], 99], [['D', ['CJ', 'AD', 'TD', 'QD'], False, False, False], 18], [['G', ['CJ', 'HJ'], False, True, False], 72], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD'], False, False, False], 81], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['H', ['SJ', 'DJ', 'QH', '7H'], False, False, True], 40]], [[['D', ['CJ', 'HJ', 'KD', '9D', '8D'], False, True, False], 27], [['H', ['CJ'], False, False, False], 20], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], True, True, False], 110], [['H', ['SJ', 'TH', 'KH', '9H', '7H'], False, True, False], 30], [['C', ['SJ', 'DJ', 'KC', 'QC', '8C', '7C'], False, False, False], 24], [['C', ['HJ', 'DJ'], False, False, False], 36], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['S', ['CJ'], False, True, False], 33]], [[['H', ['DJ', 'TH', 'KH', 'QH', '7H'], False, False, False], 40], [['C', ['KC', 'QC', '9C', '8C', '7C'], False, False, False], 84], [['C', ['9C', '8C', '7C'], False, False, True], 132], [['C', ['CJ', 'SJ', 'HJ', 'DJ'], False, False, False], 60], [['S', ['CJ', 'SJ', 'AS', 'TS', '7S'], False, True, True], 55], [['D', ['7D'], False, True, False], 108], [['H', ['CJ', 'SJ', 'HJ', 'DJ', 'AH', 'TH', 'KH', 'QH'], False, True, False], 100], [['H', ['SJ', 'DJ', 'QH', '7H'], False, False, True], 40]], [[['C', ['9C', '8C', '7C'], False, False, True], 132], [['H', ['KH', 'QH', '9H', '8H', '7H'], False, False, False], 70], [['H', ['HJ', 'DJ', 'KH', '9H', '8H'], False, True, False], 40], [['C', ['CJ', 'DJ', 'AC', 'TC', '9C'], False, True, True], 48], [['H', ['SJ', 'AH', 'KH', '8H', '7H'], False, False, False], 20], [['D', ['CJ', 'SJ', 'HJ', 'DJ', 'AD', 'TD', 'KD', 'QD', '9D'], False, True, True], 108], [['D', ['CJ', 'SJ', 'AD', 'TD', 'QD', '8D', '7D'], False, False, False], 27], [['G', ['HJ', 'DJ'], False, True, False], 96]]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("game value 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 schwarz game is valued one level short.

Input [game(D/H/S/C/G), trumps_held, hand, schneider, schwarz]. Base D9 H10 S11 C12 G24. Matadors count the unbroken run from CJ down the trump sequence (CJ SJ HJ DJ then A T K Q 9 8 7 of the suit; grand only jacks), either held ("with") or missing ("without"). Multiplier = matadors + 1 (game) + hand + schneider (implied by schwarz) + schwarz. Return base * multiplier.

split: open-access


prompt:
A pair of fives with four wilds is a legal meld.

Input a meld (cards; "JK" joker and deuces are wild). Valid: >= 3 cards, >= 2 naturals of one rank (not threes), at most 3 wild cards. Card points: joker 50, A and 2 20, 8-K 10, 4-7 and black 3 5. A canasta (7+ cards) earns 500 if natural, 300 if mixed. Return [valid|invalid, bonus, card_points].

split: open-access


prompt:
A canasta containing wild cards scores 500.

Input a meld (cards; "JK" joker and deuces are wild). Valid: >= 3 cards, >= 2 naturals of one rank (not threes), at most 3 wild cards. Card points: joker 50, A and 2 20, 8-K 10, 4-7 and black 3 5. A canasta (7+ cards) earns 500 if natural, 300 if mixed. Return [valid|invalid, bonus, card_points].

split: open-access


prompt:
A meld of threes is accepted.

Input a meld (cards; "JK" joker and deuces are wild). Valid: >= 3 cards, >= 2 naturals of one rank (not threes), at most 3 wild cards. Card points: joker 50, A and 2 20, 8-K 10, 4-7 and black 3 5. A canasta (7+ cards) earns 500 if natural, 300 if mixed. Return [valid|invalid, bonus, card_points].

split: open-access


prompt:
Wild twos are undervalued in meld points.

Input a meld (cards; "JK" joker and deuces are wild). Valid: >= 3 cards, >= 2 naturals of one rank (not threes), at most 3 wild cards. Card points: joker 50, A and 2 20, 8-K 10, 4-7 and black 3 5. A canasta (7+ cards) earns 500 if natural, 300 if mixed. Return [valid|invalid, bonus, card_points].

split: open-access


prompt:
One king plus two deuces is laid down as a meld.

Input a meld (cards; "JK" joker and deuces are wild). Valid: >= 3 cards, >= 2 naturals of one rank (not threes), at most 3 wild cards. Card points: joker 50, A and 2 20, 8-K 10, 4-7 and black 3 5. A canasta (7+ cards) earns 500 if natural, 300 if mixed. Return [valid|invalid, bonus, card_points].

split: open-access