FA-60536 / Loyalty points ledgers / Open access
Promotion stacking rules: multiplier increment · case 01
A double-points promo awards triple points in total.
ROOT CAUSE
The multiplier extra uses the full percentage instead of the part above 100%.
THE FAILURE
The multiplier extra uses the full percentage instead of the part above 100%.
Unsuccessful approach: Subtracting 100 points instead of 100 percent overstates every multiplier bonus.
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
else:
e = p['value']
if p['cap'] > 0:
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': 3503} | {'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': 701} | {'applied': [3, 9], 'bonus': 301} | Failed |
| no promos | {'applied': [], 'bonus': 0} | {'applied': [], 'bonus': 0} | Passed |
| only non stackable | {'applied': [5], 'bonus': 777} | {'applied': [5], 'bonus': 77} | Failed |
| odd base | {'applied': [1, 2], 'bonus': 1001} | {'applied': [1, 2], 'bonus': 333} | Failed |
| best beats stack | {'applied': [1, 2, 3], 'bonus': 531} | {'applied': [1, 2, 3], 'bonus': 531} | Passed |
SHA-256 / 27a8f49f4a7788854b6e4ecbce5b24e089afbac102e5cd0a2a95bff947c69820
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:
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': 3501} | {'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': 700} | {'applied': [3, 9], 'bonus': 301} | Failed |
| no promos | {'applied': [], 'bonus': 0} | {'applied': [], 'bonus': 0} | Passed |
| only non stackable | {'applied': [5], 'bonus': 776} | {'applied': [5], 'bonus': 77} | Failed |
| odd base | {'applied': [1, 2], 'bonus': 999} | {'applied': [1, 2], 'bonus': 333} | Failed |
| best beats stack | {'applied': [1, 2, 3], 'bonus': 531} | {'applied': [1, 2, 3], 'bonus': 531} | Passed |
SHA-256 / c0cd99e44a7323bc5bb51e9c8a5a6987597b93a90998238c4b2614b3ca806ce6
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 / 4ef2a037514ab695dbeea86562f49c6654d84fa3b2a7a87ec7c604e2b6778791