broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
import itertools
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key5(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        flush=len({c[1] for c in h})==1
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or vals==[14,5,4,3,2])
        top=5 if vals==[14,5,4,3,2] else vals[0]
        if straight and flush: return (8,[top])
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,[top])
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)

    NAMES=['high card','one pair','two pair','three of a kind','straight','flush','full house','four of a kind','straight flush']
    hole=x['hole']; board=x['board']
    if len(hole)!={'plo':4,'plo5':5}[x['variant']]: return 'invalid'
    if not 3<=len(board)<=5: return 'invalid'
    allc=hole+board
    if len(set(hole))!=len(hole): return 'invalid'
    cands=[hc+bc for hc in itertools.combinations(hole,2) for bc in itertools.combinations(board,3)]
    return NAMES[max(key5(c) for c in cands)[0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('board flush one suited hole card',
   {'board': ['2h', '5h', '7h', '9h', 'Th'], 'hole': ['Ah', 'Kd', 'Qc', 'Js'], 'variant': 'plo'},
   'high card'),
  ('board straight',
   {'board': ['9h', 'Td', 'Jc', 'Qs', 'Kh'], 'hole': ['2c', '2d', '3c', '3s'], 'variant': 'plo'},
   'one pair'),
  ('four aces in hand',
   {'board': ['2h', '7d', '9c', 'Js', '4h'], 'hole': ['Ah', 'Ad', 'Ac', 'As'], 'variant': 'plo'},
   'one pair'),
  ('real flush',
   {'board': ['2h', '5h', '7h', '9d', 'Tc'], 'hole': ['Ah', 'Kh', 'Qc', 'Js'], 'variant': 'plo'},
   'flush'),
  ('flop only', {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'three of a kind'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid')],
 [('real flush',
   {'board': ['2h', '5h', '7h', '9d', 'Tc'], 'hole': ['Ah', 'Kh', 'Qc', 'Js'], 'variant': 'plo'},
   'flush'),
  ('flop only', {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'three of a kind'),
  ('turn board',
   {'board': ['Tc', 'Jd', '2c', '5h'], 'hole': ['8h', '9d', 'Kc', 'Ks'], 'variant': 'plo'},
   'one pair'),
  ('two card board', {'board': ['Ac', '7d'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'invalid'),
  ('plo5 five holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks', '2d'], 'variant': 'plo5'},
   'three of a kind'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid')],
 [('two card board', {'board': ['Ac', '7d'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'invalid'),
  ('plo5 five holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks', '2d'], 'variant': 'plo5'},
   'three of a kind'),
  ('plo with five holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks', '2d'], 'variant': 'plo'},
   'invalid'),
  ('plo5 with four holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo5'}, 'invalid'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('six card board',
   {'board': ['Qh', 'Jh', '2c', '3c', '4c', '5c'],
    'hole': ['Ah', 'Ad', 'Kc', 'Ks'],
    'variant': 'plo'},
   'invalid')],
 [('board flush one suited hole card',
   {'board': ['2h', '5h', '7h', '9h', 'Th'], 'hole': ['Ah', 'Kd', 'Qc', 'Js'], 'variant': 'plo'},
   'high card'),
  ('board straight',
   {'board': ['9h', 'Td', 'Jc', 'Qs', 'Kh'], 'hole': ['2c', '2d', '3c', '3s'], 'variant': 'plo'},
   'one pair'),
  ('plo5 with four holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo5'}, 'invalid'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('six card board',
   {'board': ['Qh', 'Jh', '2c', '3c', '4c', '5c'],
    'hole': ['Ah', 'Ad', 'Kc', 'Ks'],
    'variant': 'plo'},
   'invalid'),
  ('full house two pairs in hand',
   {'board': ['Kc', '7d', '2c', '3h', '9s'], 'hole': ['Kh', 'Kd', '7c', '7s'], 'variant': 'plo'},
   'three of a kind')],
 [('board flush one suited hole card',
   {'board': ['2h', '5h', '7h', '9h', 'Th'], 'hole': ['Ah', 'Kd', 'Qc', 'Js'], 'variant': 'plo'},
   'high card'),
  ('board straight',
   {'board': ['9h', 'Td', 'Jc', 'Qs', 'Kh'], 'hole': ['2c', '2d', '3c', '3s'], 'variant': 'plo'},
   'one pair'),
  ('four aces in hand',
   {'board': ['2h', '7d', '9c', 'Js', '4h'], 'hole': ['Ah', 'Ad', 'Ac', 'As'], 'variant': 'plo'},
   'one pair'),
  ('real flush',
   {'board': ['2h', '5h', '7h', '9d', 'Tc'], 'hole': ['Ah', 'Kh', 'Qc', 'Js'], 'variant': 'plo'},
   'flush'),
  ('flop only', {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'three of a kind'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import collections
import itertools
N = 1
observations = []
def solve(x):
    R='23456789TJQKA'
    def key5(h):
        vals=sorted((R.index(c[0])+2 for c in h), reverse=True)
        cnt=collections.Counter(vals)
        order=sorted(cnt, key=lambda v:(cnt[v],v), reverse=True)
        shape=sorted(cnt.values(), reverse=True)
        flush=len({c[1] for c in h})==1
        straight=len(cnt)==5 and (vals[0]-vals[4]==4 or vals==[14,5,4,3,2])
        top=5 if vals==[14,5,4,3,2] else vals[0]
        if straight and flush: return (8,[top])
        if shape==[4,1]: return (7,order)
        if shape==[3,2]: return (6,order)
        if flush: return (5,vals)
        if straight: return (4,[top])
        if shape==[3,1,1]: return (3,order)
        if shape==[2,2,1]: return (2,order)
        if shape==[2,1,1,1]: return (1,order)
        return (0,vals)

    NAMES=['high card','one pair','two pair','three of a kind','straight','flush','full house','four of a kind','straight flush']
    hole=x['hole']; board=x['board']
    if len(hole)!={'plo':4,'plo5':5}[x['variant']]: return 'invalid'
    if not 3<=len(board)<=5: return 'invalid'
    allc=hole+board
    if len(set(board))!=len(board): return 'invalid'
    cands=[hc+bc for hc in itertools.combinations(hole,2) for bc in itertools.combinations(board,3)]
    return NAMES[max(key5(c) for c in cands)[0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('board flush one suited hole card',
   {'board': ['2h', '5h', '7h', '9h', 'Th'], 'hole': ['Ah', 'Kd', 'Qc', 'Js'], 'variant': 'plo'},
   'high card'),
  ('board straight',
   {'board': ['9h', 'Td', 'Jc', 'Qs', 'Kh'], 'hole': ['2c', '2d', '3c', '3s'], 'variant': 'plo'},
   'one pair'),
  ('four aces in hand',
   {'board': ['2h', '7d', '9c', 'Js', '4h'], 'hole': ['Ah', 'Ad', 'Ac', 'As'], 'variant': 'plo'},
   'one pair'),
  ('real flush',
   {'board': ['2h', '5h', '7h', '9d', 'Tc'], 'hole': ['Ah', 'Kh', 'Qc', 'Js'], 'variant': 'plo'},
   'flush'),
  ('flop only', {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'three of a kind'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid')],
 [('real flush',
   {'board': ['2h', '5h', '7h', '9d', 'Tc'], 'hole': ['Ah', 'Kh', 'Qc', 'Js'], 'variant': 'plo'},
   'flush'),
  ('flop only', {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'three of a kind'),
  ('turn board',
   {'board': ['Tc', 'Jd', '2c', '5h'], 'hole': ['8h', '9d', 'Kc', 'Ks'], 'variant': 'plo'},
   'one pair'),
  ('two card board', {'board': ['Ac', '7d'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'invalid'),
  ('plo5 five holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks', '2d'], 'variant': 'plo5'},
   'three of a kind'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid')],
 [('two card board', {'board': ['Ac', '7d'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'invalid'),
  ('plo5 five holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks', '2d'], 'variant': 'plo5'},
   'three of a kind'),
  ('plo with five holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks', '2d'], 'variant': 'plo'},
   'invalid'),
  ('plo5 with four holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo5'}, 'invalid'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('six card board',
   {'board': ['Qh', 'Jh', '2c', '3c', '4c', '5c'],
    'hole': ['Ah', 'Ad', 'Kc', 'Ks'],
    'variant': 'plo'},
   'invalid')],
 [('board flush one suited hole card',
   {'board': ['2h', '5h', '7h', '9h', 'Th'], 'hole': ['Ah', 'Kd', 'Qc', 'Js'], 'variant': 'plo'},
   'high card'),
  ('board straight',
   {'board': ['9h', 'Td', 'Jc', 'Qs', 'Kh'], 'hole': ['2c', '2d', '3c', '3s'], 'variant': 'plo'},
   'one pair'),
  ('plo5 with four holes',
   {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo5'}, 'invalid'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('six card board',
   {'board': ['Qh', 'Jh', '2c', '3c', '4c', '5c'],
    'hole': ['Ah', 'Ad', 'Kc', 'Ks'],
    'variant': 'plo'},
   'invalid'),
  ('full house two pairs in hand',
   {'board': ['Kc', '7d', '2c', '3h', '9s'], 'hole': ['Kh', 'Kd', '7c', '7s'], 'variant': 'plo'},
   'three of a kind')],
 [('board flush one suited hole card',
   {'board': ['2h', '5h', '7h', '9h', 'Th'], 'hole': ['Ah', 'Kd', 'Qc', 'Js'], 'variant': 'plo'},
   'high card'),
  ('board straight',
   {'board': ['9h', 'Td', 'Jc', 'Qs', 'Kh'], 'hole': ['2c', '2d', '3c', '3s'], 'variant': 'plo'},
   'one pair'),
  ('four aces in hand',
   {'board': ['2h', '7d', '9c', 'Js', '4h'], 'hole': ['Ah', 'Ad', 'Ac', 'As'], 'variant': 'plo'},
   'one pair'),
  ('real flush',
   {'board': ['2h', '5h', '7h', '9d', 'Tc'], 'hole': ['Ah', 'Kh', 'Qc', 'Js'], 'variant': 'plo'},
   'flush'),
  ('flop only', {'board': ['Ac', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'},
   'three of a kind'),
  ('duplicate across hole and board',
   {'board': ['Ah', '7d', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate inside hole',
   {'board': ['Qh', '7d', '2c'], 'hole': ['Ah', 'Ah', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid'),
  ('duplicate on board',
   {'board': ['Qh', 'Qh', '2c'], 'hole': ['Ah', 'Ad', 'Kc', 'Ks'], 'variant': 'plo'}, 'invalid')]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An ace of hearts dealt both in hand and on the board produces a hand instead of "invalid".

Input: {"variant": "plo" (4 hole cards) or "plo5" (5 hole cards), "hole": [...], "board": 3 to 5 cards}. The hand must use exactly two hole cards and exactly three board cards. Return the best category name, or "invalid" for a wrong hole count, a board outside 3-5 cards, or a duplicated card.

split: open-access


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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for p,v in bets.items() if p not in folded and v>0})
    pots=[]; prev=0
    for lv in levels:
        amt=(lv-prev)*sum(1 for v in bets.values() if v>=lv)
        elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots[-1]['amount']+=extra
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for p,v in bets.items() if p not in folded and v>0})
    pots=[]; prev=0
    for lv in levels:
        amt=sum(min(v,lv)-prev for v in bets.values())
        elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots[-1]['amount']+=extra
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Chips from a folded short contributor vanish and the pots sum to less than the total bet.

Input: {"bets": {player: total chips committed this hand}, "folded": [players]}. Build pots by layering at each distinct live (non-folded) commitment level, main pot first. Each layer takes from every player (folded ones included) the part of their commitment between the previous and current level; eligible players are the live players committed at least to the level, sorted. Folded chips above the top live level go to the last pot. Return [{"amount", "eligible"}].

split: open-access


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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for p,v in bets.items() if p not in folded and v>0})
    pots=[]; prev=0
    for lv in levels:
        amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
        elig=sorted(p for p,v in bets.items() if p not in folded and v>lv)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots[-1]['amount']+=extra
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, [])],
 [('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}])],
 [('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, [])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for p,v in bets.items() if p not in folded and v>0})
    pots=[]; prev=0
    for lv in levels:
        amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
        elig=sorted(p for p,v in bets.items() if p not in folded and v>=prev)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots[-1]['amount']+=extra
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, [])],
 [('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}])],
 [('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, [])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The player whose all-in defines a level is not eligible for that level's pot.

Input: {"bets": {player: total chips committed this hand}, "folded": [players]}. Build pots by layering at each distinct live (non-folded) commitment level, main pot first. Each layer takes from every player (folded ones included) the part of their commitment between the previous and current level; eligible players are the live players committed at least to the level, sorted. Folded chips above the top live level go to the last pot. Return [{"amount", "eligible"}].

split: open-access


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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for v in bets.values() if v>0})
    pots=[]; prev=0
    for lv in levels:
        amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
        elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots[-1]['amount']+=extra
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for p,v in bets.items() if p not in folded})
    pots=[]; prev=0
    for lv in levels:
        amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
        elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots[-1]['amount']+=extra
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A folded player's bet size splits the pot into extra layers with identical eligibility.

Input: {"bets": {player: total chips committed this hand}, "folded": [players]}. Build pots by layering at each distinct live (non-folded) commitment level, main pot first. Each layer takes from every player (folded ones included) the part of their commitment between the previous and current level; eligible players are the live players committed at least to the level, sorted. Folded chips above the top live level go to the last pot. Return [{"amount", "eligible"}].

split: open-access


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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for p,v in bets.items() if p not in folded and v>0})
    pots=[]; prev=0
    for lv in levels:
        amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
        elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots.append({'amount':extra,'eligible':[]})
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    bets=x['bets']; folded=set(x['folded'])
    levels=sorted({v for p,v in bets.items() if p not in folded and v>0})
    pots=[]; prev=0
    for lv in levels:
        amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
        elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
        pots.append({'amount':amt,'eligible':elig})
        prev=lv
    extra=sum(max(0,v-prev) for v in bets.values())
    if extra and pots: pots[0]['amount']+=extra
    return pots
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
   [{'amount': 405, 'eligible': ['a', 'b']}]),
  ('short stack all-in with folders',
   {'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
  ('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}]),
  ('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
   [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
    {'amount': 50, 'eligible': ['c', 'd']}])],
 [('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
   [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
  ('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
   [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
  ('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
   [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
  ('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
   [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
    {'amount': 80, 'eligible': ['c', 'd']}]),
  ('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
   [{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
  ('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
   [{'amount': 180, 'eligible': ['a', 'b']}]),
  ('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
   [{'amount': 40, 'eligible': ['b']}]),
  ('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
   [{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A pot with no eligible players appears when a folder committed more than any live player.

Input: {"bets": {player: total chips committed this hand}, "folded": [players]}. Build pots by layering at each distinct live (non-folded) commitment level, main pot first. Each layer takes from every player (folded ones included) the part of their commitment between the previous and current level; eligible players are the live players committed at least to the level, sorted. Folded chips above the top live level go to the last pot. Return [{"amount", "eligible"}].

split: open-access


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

N = 1
observations = []
def solve(x):
    pot=x['pot']; unit=x['unit']; winners=x['winners']; seats=x['seats']
    k=len(winners)
    units=pot//unit
    share=units//k
    rem=units-share*k
    out={w:pot//k for w in winners}
    start=(seats.index(x['button'])+1)%len(seats)
    order=seats[start:]+seats[:start]
    for w in [s for s in order if s in winners][:rem]:
        out[w]+=unit
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('wrap past last seat',
   {'button': 'd',
    'pot': 11,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 1,
    'winners': ['a', 'e', 'b']},
   {'a': 4, 'b': 3, 'e': 4}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('wrap past last seat',
   {'button': 'd',
    'pot': 11,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 1,
    'winners': ['a', 'e', 'b']},
   {'a': 4, 'b': 3, 'e': 4}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('wrap past last seat',
   {'button': 'd',
    'pot': 11,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 1,
    'winners': ['a', 'e', 'b']},
   {'a': 4, 'b': 3, 'e': 4}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    pot=x['pot']; unit=x['unit']; winners=x['winners']; seats=x['seats']
    k=len(winners)
    units=pot//unit
    share=units//k
    rem=units-share*k
    out={w:share for w in winners}
    start=(seats.index(x['button'])+1)%len(seats)
    order=seats[start:]+seats[:start]
    for w in [s for s in order if s in winners][:rem]:
        out[w]+=unit
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('wrap past last seat',
   {'button': 'd',
    'pot': 11,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 1,
    'winners': ['a', 'e', 'b']},
   {'a': 4, 'b': 3, 'e': 4}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('wrap past last seat',
   {'button': 'd',
    'pot': 11,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 1,
    'winners': ['a', 'e', 'b']},
   {'a': 4, 'b': 3, 'e': 4}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('wrap past last seat',
   {'button': 'd',
    'pot': 11,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 1,
    'winners': ['a', 'e', 'b']},
   {'a': 4, 'b': 3, 'e': 4}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2})],
 [('three-way odd units',
   {'button': 'c',
    'pot': 110,
    'seats': ['a', 'b', 'c', 'd', 'e'],
    'unit': 5,
    'winners': ['b', 'd', 'e']},
   {'b': 35, 'd': 40, 'e': 35}),
  ('two-way one unit',
   {'button': 'b', 'pot': 25, 'seats': ['a', 'b', 'c', 'd'], 'unit': 5, 'winners': ['a', 'c']},
   {'a': 10, 'c': 15}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('single winner',
   {'button': 'a', 'pot': 35, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['c']}, {'c': 35}),
  ('four-way three odd',
   {'button': 'b',
    'pot': 19,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 1,
    'winners': ['a', 'b', 'c', 'd']},
   {'a': 5, 'b': 4, 'c': 5, 'd': 5}),
  ('large unit',
   {'button': 'a',
    'pot': 300,
    'seats': ['a', 'b', 'c', 'd', 'e', 'f'],
    'unit': 100,
    'winners': ['f', 'a']},
   {'a': 100, 'f': 200}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Winners receive more chips than the pot holds when the pot is not evenly divisible.

Input: {"pot", "winners", "seats" (clockwise), "button", "unit" (smallest chip in play; pot is a multiple of it)}. Split the pot equally in whole units; each leftover unit goes to one winner, starting with the first winner clockwise from the button (the button itself is last). Return {winner: amount} sorted by name.

split: open-access