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:share*unit for w in winners}
    start=seats.index(x['button'])
    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}),
  ('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}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('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})],
 [('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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*unit 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}),
  ('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}),
  ('even split',
   {'button': 'c', 'pot': 100, 'seats': ['a', 'b', 'c'], 'unit': 5, 'winners': ['a', 'b']},
   {'a': 50, 'b': 50}),
  ('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})],
 [('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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:
The button seat, when it wins, receives the odd chip ahead of the player to its left.

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


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:share*unit 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}),
  ('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})],
 [('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('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}),
  ('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)

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):
    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*unit for w in winners}
    start=(seats.index(x['button'])+1)%len(seats)
    order=seats[start:]+seats[:start]
    for w in [s for s in sorted(winners, key=seats.index) 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}),
  ('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})],
 [('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('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}),
  ('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:
Odd units go to the winners farthest from the button, and an even split pays everyone an extra unit.

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


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%len(seats)
    out={w:share*unit 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}),
  ('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}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('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}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2})],
 [('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    pot=x['pot']; unit=x['unit']; winners=x['winners']; seats=x['seats']
    k=len(winners)
    units=pot//unit
    share=units//k
    rem=1 if units%k else 0
    out={w:share*unit 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}),
  ('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}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('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}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2})],
 [('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('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}),
  ('button left winner',
   {'button': 'a', 'pot': 5, 'seats': ['a', 'b', 'c'], 'unit': 1, 'winners': ['b', 'c']},
   {'b': 3, 'c': 2})]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'error:' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The number of odd units depends on how many seats are at the table.

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


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:share*unit for w in winners}
    start=(seats.index(x['button'])+1)%len(seats)
    order=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}),
  ('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}),
  ('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}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('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}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('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}),
  ('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})],
 [('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}),
  ('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}),
  ('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}),
  ('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*unit 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}),
  ('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}),
  ('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}),
  ('button is a winner',
   {'button': 'd', 'pot': 7, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'd']},
   {'a': 4, 'd': 3}),
  ('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}),
  ('winner right of button',
   {'button': 'b', 'pot': 5, 'seats': ['a', 'b', 'c', 'd'], 'unit': 1, 'winners': ['a', 'c']},
   {'a': 2, 'c': 3})],
 [('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}),
  ('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})],
 [('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}),
  ('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}),
  ('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}),
  ('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 seated before the button in the seat list never receive odd units.

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


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

N = 1
observations = []
def solve(x):
    pot=x['pot']; order=x['order']
    def split(amount, winners):
        k=len(winners); share=amount//k; rem=amount-share*k
        out={w:share for w in winners}
        for w in [s for s in order if s in winners][:rem]:
            out[w]+=1
        return out
    if x['low']:
        high_half=pot//2; low_half=pot-high_half
        parts=[split(high_half,x['high']), split(low_half,x['low'])]
    else:
        parts=[split(pot,x['high'])]
    res={}
    for part in parts:
        for k,v in part.items():
            res[k]=res.get(k,0)+v
    return dict(sorted(res.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})]]
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']; order=x['order']
    def split(amount, winners):
        k=len(winners); share=amount//k; rem=amount-share*k
        out={w:share for w in winners}
        for w in [s for s in order if s in winners][:rem]:
            out[w]+=1
        return out
    if x['low']:
        low_half=high_half=pot//2
        parts=[split(high_half,x['high']), split(low_half,x['low'])]
    else:
        parts=[split(pot,x['high'])]
    res={}
    for part in parts:
        for k,v in part.items():
            res[k]=res.get(k,0)+v
    return dict(sorted(res.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})]]
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:
In an odd pot the low winner gets the extra chip.

Input: {"pot", "high": [winners], "low": [qualifying low winners, possibly empty], "order": [seat order from the button's left]}. With a qualifying low the pot is halved, the odd chip going to the high half; each half is split among its winners with odd chips by seat order. Without a low, high winners scoop. A player winning both halves is paid both. Return {player: chips} sorted.

split: open-access


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

N = 1
observations = []
def solve(x):
    pot=x['pot']; order=x['order']
    def split(amount, winners):
        k=len(winners); share=amount//k; rem=amount-share*k
        out={w:share for w in winners}
        for w in [s for s in order if s in winners][:rem]:
            out[w]+=1
        return out
    if x['low'] is not None:
        low_half=pot//2; high_half=pot-low_half
        parts=[split(high_half,x['high']), split(low_half,x['low'])]
    else:
        parts=[split(pot,x['high'])]
    res={}
    for part in parts:
        for k,v in part.items():
            res[k]=res.get(k,0)+v
    return dict(sorted(res.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})]]
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']; order=x['order']
    def split(amount, winners):
        k=len(winners); share=amount//k; rem=amount-share*k
        out={w:share for w in winners}
        for w in [s for s in order if s in winners][:rem]:
            out[w]+=1
        return out
    if len(x['low'])>=0:
        low_half=pot//2; high_half=pot-low_half
        parts=[split(high_half,x['high']), split(low_half,x['low'])]
    else:
        parts=[split(pot,x['high'])]
    res={}
    for part in parts:
        for k,v in part.items():
            res[k]=res.get(k,0)+v
    return dict(sorted(res.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})]]
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:
With no qualifying low, evaluation fails dividing the low half among zero winners instead of scooping.

Input: {"pot", "high": [winners], "low": [qualifying low winners, possibly empty], "order": [seat order from the button's left]}. With a qualifying low the pot is halved, the odd chip going to the high half; each half is split among its winners with odd chips by seat order. Without a low, high winners scoop. A player winning both halves is paid both. Return {player: chips} sorted.

split: open-access


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

N = 1
observations = []
def solve(x):
    pot=x['pot']; order=x['order']
    def split(amount, winners):
        k=len(winners); share=amount//k; rem=amount-share*k
        out={w:share for w in winners}
        for w in [s for s in order if s in winners][:rem]:
            out[w]+=1
        return out
    if x['low']:
        low_half=pot//2; high_half=pot-low_half
        parts=[split(high_half,x['high']), split(low_half,x['low'])]
    else:
        parts=[split(pot,x['high'])]
    res={}
    for part in parts:
        for k,v in part.items():
            res[k]=v
    return dict(sorted(res.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})]]
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']; order=x['order']
    def split(amount, winners):
        k=len(winners); share=amount//k; rem=amount-share*k
        out={w:share for w in winners}
        for w in [s for s in order if s in winners][:rem]:
            out[w]+=1
        return out
    if x['low']:
        low_half=pot//2; high_half=pot-low_half
        parts=[split(high_half,x['high']), split(low_half,x['low'])]
    else:
        parts=[split(pot,x['high'])]
    res={}
    for part in parts:
        for k,v in part.items():
            res[k]=max(res.get(k,0),v)
    return dict(sorted(res.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})],
 [('odd pot two winners', {'high': ['a'], 'low': ['b'], 'order': ['a', 'b', 'c'], 'pot': 101},
   {'a': 51, 'b': 50}),
  ('no low scoop', {'high': ['a'], 'low': [], 'order': ['a', 'b'], 'pot': 100}, {'a': 100}),
  ('scoop both halves', {'high': ['a'], 'low': ['a'], 'order': ['a', 'b'], 'pot': 101}, {'a': 101}),
  ('quartered low', {'high': ['a'], 'low': ['b', 'c'], 'order': ['a', 'b', 'c'], 'pot': 100},
   {'a': 50, 'b': 25, 'c': 25}),
  ('high and shared low with scooper',
   {'high': ['c'], 'low': ['c', 'b'], 'order': ['a', 'b', 'c'], 'pot': 90}, {'b': 23, 'c': 67}),
  ('even pot', {'high': ['b'], 'low': ['c'], 'order': ['a', 'b', 'c'], 'pot': 80},
   {'b': 40, 'c': 40}),
  ('odd pot no low split high', {'high': ['b', 'a'], 'low': [], 'order': ['b', 'a'], 'pot': 51},
   {'a': 25, 'b': 26}),
  ('small odd pot', {'high': ['c'], 'low': ['a'], 'order': ['a', 'b', 'c'], 'pot': 7},
   {'a': 3, 'c': 4})]]
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 player who wins both high and low is paid half the pot.

Input: {"pot", "high": [winners], "low": [qualifying low winners, possibly empty], "order": [seat order from the button's left]}. With a qualifying low the pot is halved, the odd chip going to the high half; each half is split among its winners with odd chips by seat order. Without a low, high winners scoop. A player winning both halves is paid both. Return {player: chips} sorted.

split: open-access