FA-82026 / Poker hand evaluation / Open access
Folded commitment creates a phantom side pot · case 01
A folded player's bet size splits the pot into extra layers with identical eligibility.
ROOT CAUSE
Levels are taken from every commitment, including folded players who cannot win.
VERIFIED REPAIR
Only live, positive commitments define pot levels.
Unsuccessful approach: Keeping zero commitments from live players creates an empty zero-level pot.
Case contract
Input: {"bets": {player: total chips committed this hand}, "folded": [players]}. Build pots by layering at each distinct live (non-folded) commitment level, main pot first. Each layer takes from every player (folded ones included) the part of their commitment between the previous and current level; eligible players are the live players committed at least to the level, sorted. Folded chips above the top live level go to the last pot. Return [{"amount", "eligible"}].
Why this case matters
Side-pot construction decides which all-in players can win which chips.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
bets=x['bets']; folded=set(x['folded'])
levels=sorted({v for v in bets.values() if v>0})
pots=[]; prev=0
for lv in levels:
amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
pots.append({'amount':amt,'eligible':elig})
prev=lv
extra=sum(max(0,v-prev) for v in bets.values())
if extra and pots: pots[-1]['amount']+=extra
return pots
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
[{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
[{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])],
[('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
[{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
[{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
[{'amount': 180, 'eligible': ['a', 'b']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
[{'amount': 180, 'eligible': ['a', 'b']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
[{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
[{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| single all-in | [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}] | [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}] | Passed |
| folded partial caller | [{'amount': 90, 'eligible': ['a', 'b']}, {'amount': 40, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}] | [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}] | Failed |
| folded between levels | [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}, {'amount': 25, 'eligible': ['a']}] | [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}] | Failed |
| two all-ins | [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']}, {'amount': 80, 'eligible': ['c', 'd']}] | [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']}, {'amount': 80, 'eligible': ['c', 'd']}] | Passed |
| everyone equal | [{'amount': 120, 'eligible': ['a', 'b', 'c']}] | [{'amount': 120, 'eligible': ['a', 'b', 'c']}] | Passed |
| checked live player | [{'amount': 20, 'eligible': ['b']}, {'amount': 20, 'eligible': ['b']}] | [{'amount': 40, 'eligible': ['b']}] | Failed |
| no chips committed | [] | [] | Passed |
| three layers | [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']}, {'amount': 50, 'eligible': ['c', 'd']}] | [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']}, {'amount': 50, 'eligible': ['c', 'd']}] | Passed |
SHA-256 / b3f76b88036165f9161c725da2230e45679db9cefb38a1bc120d617bb2c5c490
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
bets=x['bets']; folded=set(x['folded'])
levels=sorted({v for p,v in bets.items() if p not in folded})
pots=[]; prev=0
for lv in levels:
amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
pots.append({'amount':amt,'eligible':elig})
prev=lv
extra=sum(max(0,v-prev) for v in bets.values())
if extra and pots: pots[-1]['amount']+=extra
return pots
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
[{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
[{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])],
[('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
[{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
[{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
[{'amount': 180, 'eligible': ['a', 'b']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
[{'amount': 180, 'eligible': ['a', 'b']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
[{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
[{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| single all-in | [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}] | [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}] | Passed |
| folded partial caller | [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}] | [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}] | Passed |
| folded between levels | [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}] | [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}] | Passed |
| two all-ins | [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']}, {'amount': 80, 'eligible': ['c', 'd']}] | [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']}, {'amount': 80, 'eligible': ['c', 'd']}] | Passed |
| everyone equal | [{'amount': 120, 'eligible': ['a', 'b', 'c']}] | [{'amount': 120, 'eligible': ['a', 'b', 'c']}] | Passed |
| checked live player | [{'amount': 0, 'eligible': ['a', 'b']}, {'amount': 40, 'eligible': ['b']}] | [{'amount': 40, 'eligible': ['b']}] | Failed |
| no chips committed | [{'amount': 0, 'eligible': ['a', 'b']}] | [] | Failed |
| three layers | [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']}, {'amount': 50, 'eligible': ['c', 'd']}] | [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']}, {'amount': 50, 'eligible': ['c', 'd']}] | Passed |
SHA-256 / cc7e04375fe2bb483b4122c963ba6fd2381dd850b69da6f9f6572e739a2f5506
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
bets=x['bets']; folded=set(x['folded'])
levels=sorted({v for p,v in bets.items() if p not in folded and v>0})
pots=[]; prev=0
for lv in levels:
amt=sum(min(v,lv)-min(v,prev) for v in bets.values())
elig=sorted(p for p,v in bets.items() if p not in folded and v>=lv)
pots.append({'amount':amt,'eligible':elig})
prev=lv
extra=sum(max(0,v-prev) for v in bets.values())
if extra and pots: pots[-1]['amount']+=extra
return pots
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
[{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
[{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])],
[('folded partial caller', {'bets': {'a': 100, 'b': 50, 'c': 30}, 'folded': ['c']},
[{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}]),
('folded between levels', {'bets': {'a': 100, 'b': 50, 'c': 75}, 'folded': ['c']},
[{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}]),
('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
[{'amount': 180, 'eligible': ['a', 'b']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('folded above top', {'bets': {'a': 50, 'b': 50, 'c': 80}, 'folded': ['c']},
[{'amount': 180, 'eligible': ['a', 'b']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
[{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('folded overbet over two pots', {'bets': {'a': 20, 'b': 60, 'c': 90}, 'folded': ['c']},
[{'amount': 60, 'eligible': ['a', 'b']}, {'amount': 110, 'eligible': ['b']}])],
[('single all-in', {'bets': {'a': 100, 'b': 50, 'c': 100}, 'folded': []},
[{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}]),
('two all-ins', {'bets': {'a': 20, 'b': 60, 'c': 100, 'd': 100}, 'folded': []},
[{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']},
{'amount': 80, 'eligible': ['c', 'd']}]),
('everyone equal', {'bets': {'a': 40, 'b': 40, 'c': 40}, 'folded': []},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}]),
('checked live player', {'bets': {'a': 0, 'b': 30, 'c': 10}, 'folded': ['c']},
[{'amount': 40, 'eligible': ['b']}]),
('blind folded small', {'bets': {'a': 200, 'b': 200, 'c': 5}, 'folded': ['c']},
[{'amount': 405, 'eligible': ['a', 'b']}]),
('short stack all-in with folders',
{'bets': {'a': 30, 'b': 90, 'c': 90, 'd': 45}, 'folded': ['d']},
[{'amount': 120, 'eligible': ['a', 'b', 'c']}, {'amount': 135, 'eligible': ['b', 'c']}]),
('no chips committed', {'bets': {'a': 0, 'b': 0}, 'folded': []}, []),
('three layers', {'bets': {'a': 10, 'b': 25, 'c': 50, 'd': 50}, 'folded': []},
[{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']},
{'amount': 50, 'eligible': ['c', 'd']}])]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| single all-in | [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}] | [{'amount': 150, 'eligible': ['a', 'b', 'c']}, {'amount': 100, 'eligible': ['a', 'c']}] | Passed |
| folded partial caller | [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}] | [{'amount': 130, 'eligible': ['a', 'b']}, {'amount': 50, 'eligible': ['a']}] | Passed |
| folded between levels | [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}] | [{'amount': 150, 'eligible': ['a', 'b']}, {'amount': 75, 'eligible': ['a']}] | Passed |
| two all-ins | [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']}, {'amount': 80, 'eligible': ['c', 'd']}] | [{'amount': 80, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 120, 'eligible': ['b', 'c', 'd']}, {'amount': 80, 'eligible': ['c', 'd']}] | Passed |
| everyone equal | [{'amount': 120, 'eligible': ['a', 'b', 'c']}] | [{'amount': 120, 'eligible': ['a', 'b', 'c']}] | Passed |
| checked live player | [{'amount': 40, 'eligible': ['b']}] | [{'amount': 40, 'eligible': ['b']}] | Passed |
| no chips committed | [] | [] | Passed |
| three layers | [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']}, {'amount': 50, 'eligible': ['c', 'd']}] | [{'amount': 40, 'eligible': ['a', 'b', 'c', 'd']}, {'amount': 45, 'eligible': ['b', 'c', 'd']}, {'amount': 50, 'eligible': ['c', 'd']}] | Passed |
SHA-256 / 92eabcd1fb201b47ab3036bbc840b19b8342cc7de9d45d9763187a0e4b788181
Verification & scope
A deterministic toy model with an explicitly stated contract; no claim of conformance to any casino or tournament rulebook. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:50:08.277254+00:00.
Case digest / 36d1e9b31bc7ec55cc722668e474af2c05ee1410a8980deecb890af06a887cb1