FA-58496 / Loan amortization schedules / Open access
Payment application waterfall: curtailment room · case 01
Overpayments near payoff drive the principal balance negative.
ROOT CAUSE
Curtailment room ignores the scheduled principal just applied.
VERIFIED REPAIR
Limit curtailment to the balance left after scheduled principal.
Unsuccessful approach: Refunding everything when the payment covers the balance skips a curtailment that fits.
Case contract
x = {'due': {'interest', 'principal', 'late_fee', 'fees'}, 'payment', 'suspense', 'threshold', 'balance'}. Available = payment + suspense. If available < threshold, everything goes to suspense and nothing is applied. Otherwise apply in order interest, principal, late_fee, fees, then curtail principal with the remainder up to balance - applied principal; the rest is refunded. Return {'applied', 'curtailment', 'refund', 'suspense', 'new_balance'}.
Why this case matters
Amortization engines drive borrower statements, payoff quotes and investor remittances; a misplaced rounding step, boundary or ordering rule compounds across hundreds of periods.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
avail = x['payment'] + x['suspense']
applied = {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}
if avail < x['threshold']:
return {'applied': applied, 'curtailment': 0, 'refund': 0, 'suspense': avail, 'new_balance': x['balance']}
for k in ('interest', 'principal', 'late_fee', 'fees'):
take = min(avail, x['due'][k])
applied[k] = take
avail -= take
room = x['balance']
curt = min(avail, room)
refund = avail - curt
return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - applied['principal'] - curt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: curtailment room', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 7200, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 4000, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 2', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 0, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 800}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1250, 'suspense': 700, 'threshold': 1250, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 99300}], ['control 4', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1300, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 5', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4500}], ['control 6', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1285, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 950, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 350, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 5835, 'suspense': 700, 'threshold': 835, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 1200, 'refund': 4500, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 1500}], ['control 2', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'curtailment': 165, 'refund': 0, 'suspense': 0, 'new_balance': 2835}], ['control 3', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2201, 'suspense': 200, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 3999}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 649, 'suspense': 0, 'threshold': 650, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 649, 'new_balance': 100000}], ['control 5', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1000, 'suspense': 0, 'threshold': 535, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 465, 'refund': 0, 'suspense': 0, 'new_balance': 1535}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': -200, 'refund': 200, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 6300, 'suspense': 0, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 800, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4000}], ['control 2', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 835, 'suspense': 0, 'threshold': 835, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4200}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 0, 'threshold': 800, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 94200}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 499, 'suspense': 200, 'threshold': 500, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 200, 'new_balance': 800}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 200, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 1000, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 36, 'suspense': 700, 'threshold': 35, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 701, 'refund': 0, 'suspense': 0, 'new_balance': 99}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 3300}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 4', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100}], ['control 5', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 300}], ['control 6', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 2650, 'suspense': 0, 'threshold': 2650, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 2000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'curtailment': -1200, 'refund': 1700, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 800, 'refund': 165, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': -1, 'suspense': 200, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 2', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 1300, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 300, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100000}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 2051, 'suspense': 200, 'threshold': 2050, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 98999}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + 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 |
|---|---|---|---|
| regression: curtailment room | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 2000, 'new_balance': -800, 'refund': 3200, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0} | Failed |
| control 1 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | Passed |
| control 2 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0} | Passed |
| control 3 | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0} | Passed |
| control 4 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | Passed |
| control 5 | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0} | Passed |
| control 6 | {'applied': {'fees': 35, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 35, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 0} | Passed |
SHA-256 / adba7dcfa045c584bb0ee9cafa5570d020edcf5e42470755a8aa3378167ce799
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
avail = x['payment'] + x['suspense']
applied = {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}
if avail < x['threshold']:
return {'applied': applied, 'curtailment': 0, 'refund': 0, 'suspense': avail, 'new_balance': x['balance']}
for k in ('interest', 'principal', 'late_fee', 'fees'):
take = min(avail, x['due'][k])
applied[k] = take
avail -= take
room = x['balance'] - applied['principal'] if x['balance'] > avail else 0
curt = min(avail, room)
refund = avail - curt
return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - applied['principal'] - curt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: curtailment room', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 7200, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 4000, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 2', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 0, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 800}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1250, 'suspense': 700, 'threshold': 1250, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 99300}], ['control 4', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1300, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 5', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4500}], ['control 6', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1285, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 950, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 350, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 5835, 'suspense': 700, 'threshold': 835, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 1200, 'refund': 4500, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 1500}], ['control 2', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'curtailment': 165, 'refund': 0, 'suspense': 0, 'new_balance': 2835}], ['control 3', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2201, 'suspense': 200, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 3999}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 649, 'suspense': 0, 'threshold': 650, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 649, 'new_balance': 100000}], ['control 5', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1000, 'suspense': 0, 'threshold': 535, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 465, 'refund': 0, 'suspense': 0, 'new_balance': 1535}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': -200, 'refund': 200, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 6300, 'suspense': 0, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 800, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4000}], ['control 2', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 835, 'suspense': 0, 'threshold': 835, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4200}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 0, 'threshold': 800, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 94200}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 499, 'suspense': 200, 'threshold': 500, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 200, 'new_balance': 800}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 200, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 1000, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 36, 'suspense': 700, 'threshold': 35, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 701, 'refund': 0, 'suspense': 0, 'new_balance': 99}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 3300}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 4', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100}], ['control 5', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 300}], ['control 6', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 2650, 'suspense': 0, 'threshold': 2650, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 2000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'curtailment': -1200, 'refund': 1700, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 800, 'refund': 165, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': -1, 'suspense': 200, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 2', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 1300, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 300, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100000}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 2051, 'suspense': 200, 'threshold': 2050, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 98999}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + 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 |
|---|---|---|---|
| regression: curtailment room | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 0, 'new_balance': 1200, 'refund': 5200, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0} | Failed |
| control 1 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | Passed |
| control 2 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0} | Passed |
| control 3 | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0} | Passed |
| control 4 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | Passed |
| control 5 | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0} | Passed |
| control 6 | {'applied': {'fees': 35, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 35, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 0} | Passed |
SHA-256 / 6f6669fd072f70b45f3a54b8046a954f009cfd77a1b3aaa8c65ae09764005bbd
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
avail = x['payment'] + x['suspense']
applied = {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}
if avail < x['threshold']:
return {'applied': applied, 'curtailment': 0, 'refund': 0, 'suspense': avail, 'new_balance': x['balance']}
for k in ('interest', 'principal', 'late_fee', 'fees'):
take = min(avail, x['due'][k])
applied[k] = take
avail -= take
room = x['balance'] - applied['principal']
curt = min(avail, room)
refund = avail - curt
return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - applied['principal'] - curt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: curtailment room', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 7200, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 4000, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 2', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 0, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 800}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1250, 'suspense': 700, 'threshold': 1250, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 99300}], ['control 4', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1300, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 5', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4500}], ['control 6', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1285, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 950, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 350, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 5835, 'suspense': 700, 'threshold': 835, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 1200, 'refund': 4500, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 1500}], ['control 2', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'curtailment': 165, 'refund': 0, 'suspense': 0, 'new_balance': 2835}], ['control 3', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2201, 'suspense': 200, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 3999}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 649, 'suspense': 0, 'threshold': 650, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 649, 'new_balance': 100000}], ['control 5', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1000, 'suspense': 0, 'threshold': 535, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 465, 'refund': 0, 'suspense': 0, 'new_balance': 1535}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': -200, 'refund': 200, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 6300, 'suspense': 0, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 800, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4000}], ['control 2', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 835, 'suspense': 0, 'threshold': 835, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4200}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 0, 'threshold': 800, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 94200}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 499, 'suspense': 200, 'threshold': 500, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 200, 'new_balance': 800}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 200, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 1000, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 36, 'suspense': 700, 'threshold': 35, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 701, 'refund': 0, 'suspense': 0, 'new_balance': 99}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 3300}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 4', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100}], ['control 5', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 300}], ['control 6', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 2650, 'suspense': 0, 'threshold': 2650, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}]], [['regression: curtailment room', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 2000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'curtailment': -1200, 'refund': 1700, 'suspense': 0, 'new_balance': 0}], ['regression: curtailment room, partial-repair probe', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 800, 'refund': 165, 'suspense': 0, 'new_balance': 0}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': -1, 'suspense': 200, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 2', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 1300, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 300, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100000}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 2051, 'suspense': 200, 'threshold': 2050, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 98999}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + 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 |
|---|---|---|---|
| regression: curtailment room | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0} | Passed |
| control 1 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | Passed |
| control 2 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0} | Passed |
| control 3 | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0} | Passed |
| control 4 | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | {'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300} | Passed |
| control 5 | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0} | Passed |
| control 6 | {'applied': {'fees': 35, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 35, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 0} | Passed |
SHA-256 / a0545c40eb906b6f15b0d955e5b2ba8d92304cffbc0a4ce13c3d59f5ed3e50fd
Verification & scope
A deterministic bounded teaching model with stipulated toy lending rules stated in the contract; money is integer cents and rates are basis points; it makes no claim of conformance to any regulation, servicing standard or product. 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:27.357853+00:00.
Case digest / 981d4483109691e1faa0f4243d34d8368505f8fc38425374f8c6496a3a07dcda