FA-60541 / Loyalty points ledgers / Open access
Promotion stacking rules: uncapped sentinel · case 01
Promotions with no cap award zero bonus points.
ROOT CAUSE
The cap is applied even when it is 0, which means uncapped.
THE FAILURE
The cap is applied even when it is 0, which means uncapped.
Unsuccessful approach: Applying caps only to multiplier promos leaves capped fixed promos uncapped.
Case contract
Input {base, promos:[{id,kind,value,stackable,cap}]}. A multiplier promo (value in percent) gives floor(base*(value-100)/100) extra; a fixed promo gives value. Each extra is capped at cap when cap > 0. All stackable extras apply; of the non-stackable promos only the single best capped extra applies (ties to the lower id), in addition to the stackable ones. Return {bonus, applied ids sorted}.
Why this case matters
Member point balances, statements and the program liability depend on this ledger rule.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
st = []
ns = []
for p in x['promos']:
if p['kind'] == 'multiplier':
e = x['base'] * (p['value'] - 100) // 100
else:
e = p['value']
if True:
e = min(e, p['cap'])
(st if p['stackable'] else ns).append([e, p['id']])
bonus = sum(e for e, _ in st)
applied = [i for _, i in st]
if ns:
best = min(ns, key=lambda r: (-r[0], r[1]))
bonus += best[0]
applied.append(best[1])
return {'bonus': bonus, 'applied': sorted(applied)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed promos', {'base': 1001, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1501, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2501}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3001, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 101, 'stackable': True, 'cap': 0}]}, {'bonus': 301, 'applied': [3, 9]}], ['no promos', {'base': 10, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 111, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 77, 'applied': [5]}], ['odd base', {'base': 334, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 333, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 501, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 531, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1002, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1503, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2502}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3002, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 102, 'stackable': True, 'cap': 0}]}, {'bonus': 302, 'applied': [3, 9]}], ['no promos', {'base': 20, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 112, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 84, 'applied': [5]}], ['odd base', {'base': 335, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 334, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 502, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 532, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1003, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1504, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2503}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3003, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 103, 'stackable': True, 'cap': 0}]}, {'bonus': 303, 'applied': [3, 9]}], ['no promos', {'base': 30, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 113, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 91, 'applied': [5]}], ['odd base', {'base': 336, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 336, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 503, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 533, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1004, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1506, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2504}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3004, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 104, 'stackable': True, 'cap': 0}]}, {'bonus': 304, 'applied': [3, 9]}], ['no promos', {'base': 40, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 114, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 98, 'applied': [5]}], ['odd base', {'base': 337, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 336, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 504, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 534, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1005, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1507, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2505}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3005, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 105, 'stackable': True, 'cap': 0}]}, {'bonus': 305, 'applied': [3, 9]}], ['no promos', {'base': 50, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 115, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 105, 'applied': [5]}], ['odd base', {'base': 338, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 337, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 505, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 535, 'applied': [1, 2, 3]}]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed promos | {'applied': [1, 2], 'bonus': 0} | {'applied': [1, 3], 'bonus': 1501} | Failed |
| caps | {'applied': [1, 2], 'bonus': 3001} | {'applied': [1, 2], 'bonus': 3001} | Passed |
| tie on value | {'applied': [3, 9], 'bonus': 0} | {'applied': [3, 9], 'bonus': 301} | Failed |
| no promos | {'applied': [], 'bonus': 0} | {'applied': [], 'bonus': 0} | Passed |
| only non stackable | {'applied': [6], 'bonus': 40} | {'applied': [5], 'bonus': 77} | Failed |
| odd base | {'applied': [1, 2], 'bonus': 0} | {'applied': [1, 2], 'bonus': 333} | Failed |
| best beats stack | {'applied': [1, 2, 3], 'bonus': 0} | {'applied': [1, 2, 3], 'bonus': 531} | Failed |
SHA-256 / b6f4a459f5efda67c8ccf70a85d61e19654cd1d9ccf73a6e71cf67fbc383c417
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
st = []
ns = []
for p in x['promos']:
if p['kind'] == 'multiplier':
e = x['base'] * (p['value'] - 100) // 100
else:
e = p['value']
if p['cap'] > 0 and p['kind'] == 'multiplier':
e = min(e, p['cap'])
(st if p['stackable'] else ns).append([e, p['id']])
bonus = sum(e for e, _ in st)
applied = [i for _, i in st]
if ns:
best = min(ns, key=lambda r: (-r[0], r[1]))
bonus += best[0]
applied.append(best[1])
return {'bonus': bonus, 'applied': sorted(applied)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed promos', {'base': 1001, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1501, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2501}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3001, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 101, 'stackable': True, 'cap': 0}]}, {'bonus': 301, 'applied': [3, 9]}], ['no promos', {'base': 10, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 111, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 77, 'applied': [5]}], ['odd base', {'base': 334, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 333, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 501, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 531, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1002, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1503, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2502}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3002, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 102, 'stackable': True, 'cap': 0}]}, {'bonus': 302, 'applied': [3, 9]}], ['no promos', {'base': 20, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 112, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 84, 'applied': [5]}], ['odd base', {'base': 335, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 334, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 502, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 532, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1003, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1504, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2503}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3003, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 103, 'stackable': True, 'cap': 0}]}, {'bonus': 303, 'applied': [3, 9]}], ['no promos', {'base': 30, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 113, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 91, 'applied': [5]}], ['odd base', {'base': 336, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 336, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 503, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 533, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1004, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1506, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2504}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3004, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 104, 'stackable': True, 'cap': 0}]}, {'bonus': 304, 'applied': [3, 9]}], ['no promos', {'base': 40, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 114, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 98, 'applied': [5]}], ['odd base', {'base': 337, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 336, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 504, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 534, 'applied': [1, 2, 3]}]], [['mixed promos', {'base': 1005, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 200, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 300, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}]}, {'bonus': 1507, 'applied': [1, 3]}], ['caps', {'base': 2000, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 300, 'stackable': True, 'cap': 2505}, {'id': 2, 'kind': 'fixed', 'value': 900, 'stackable': True, 'cap': 500}]}, {'bonus': 3005, 'applied': [1, 2]}], ['tie on value', {'base': 400, 'promos': [{'id': 7, 'kind': 'fixed', 'value': 200, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'multiplier', 'value': 150, 'stackable': False, 'cap': 0}, {'id': 9, 'kind': 'fixed', 'value': 105, 'stackable': True, 'cap': 0}]}, {'bonus': 305, 'applied': [3, 9]}], ['no promos', {'base': 50, 'promos': []}, {'bonus': 0, 'applied': []}], ['only non stackable', {'base': 700, 'promos': [{'id': 4, 'kind': 'fixed', 'value': 50, 'stackable': False, 'cap': 0}, {'id': 5, 'kind': 'multiplier', 'value': 115, 'stackable': False, 'cap': 0}, {'id': 6, 'kind': 'fixed', 'value': 60, 'stackable': False, 'cap': 40}]}, {'bonus': 105, 'applied': [5]}], ['odd base', {'base': 338, 'promos': [{'id': 1, 'kind': 'multiplier', 'value': 125, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'multiplier', 'value': 175, 'stackable': True, 'cap': 0}]}, {'bonus': 337, 'applied': [1, 2]}], ['best beats stack', {'base': 100, 'promos': [{'id': 1, 'kind': 'fixed', 'value': 10, 'stackable': True, 'cap': 0}, {'id': 2, 'kind': 'fixed', 'value': 505, 'stackable': False, 'cap': 0}, {'id': 3, 'kind': 'fixed', 'value': 20, 'stackable': True, 'cap': 0}]}, {'bonus': 535, 'applied': [1, 2, 3]}]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed promos | {'applied': [1, 3], 'bonus': 1501} | {'applied': [1, 3], 'bonus': 1501} | Passed |
| caps | {'applied': [1, 2], 'bonus': 3401} | {'applied': [1, 2], 'bonus': 3001} | Failed |
| tie on value | {'applied': [3, 9], 'bonus': 301} | {'applied': [3, 9], 'bonus': 301} | Passed |
| no promos | {'applied': [], 'bonus': 0} | {'applied': [], 'bonus': 0} | Passed |
| only non stackable | {'applied': [5], 'bonus': 77} | {'applied': [5], 'bonus': 77} | Passed |
| odd base | {'applied': [1, 2], 'bonus': 333} | {'applied': [1, 2], 'bonus': 333} | Passed |
| best beats stack | {'applied': [1, 2, 3], 'bonus': 531} | {'applied': [1, 2, 3], 'bonus': 531} | Passed |
SHA-256 / 8a95a7ee20286117bf2c0b38f599e7aa290a2deec51b4096166a6111bdc4cf98
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
Stipulated bounded loyalty-program model with explicit toy rules; not any real program terms. 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:46:46.667377+00:00.
Case digest / 73f8a78f403012c3bd64c90b7006f884392f6c126e95d94cbbb8a7ef9c3d0eba