FA-58501 / Loan amortization schedules / Open access
Payment application waterfall: new balance reduction · case 01
Scheduled principal payments do not lower the reported balance.
ROOT CAUSE
The new balance subtracts only curtailment.
VERIFIED REPAIR
Subtract applied scheduled principal and curtailment.
Unsuccessful approach: Subtracting the full scheduled principal overstates reduction on partially funded payments.
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'] - applied['principal']
curt = min(avail, room)
refund = avail - curt
return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - curt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: new balance reduction', {'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}], ['regression: new balance reduction, partial-repair probe', {'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 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': 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: new balance reduction', {'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 1', {'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 2', {'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}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 800}], ['control 4', {'due': {'interest': 0, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 151, 'suspense': 200, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 351, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1285, 'suspense': 200, 'threshold': 1285, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 200, 'refund': 0, 'suspense': 0, 'new_balance': 4800}], ['control 6', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 200, 'refund': 0, 'suspense': 0, 'new_balance': 4800}]], [['regression: new balance reduction', {'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}], ['control 1', {'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 2', {'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}], ['control 3', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 4300}], ['control 4', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 5035, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 95000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 6', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 2000}]], [['regression: new balance reduction', {'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 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': 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 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1284, 'suspense': 700, 'threshold': 1000, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 699, 'refund': 0, 'suspense': 0, 'new_balance': 99301}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 534, 'suspense': 0, 'threshold': 535, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 534, 'new_balance': 100000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1249, 'suspense': 700, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 699, 'refund': 0, 'suspense': 0, 'new_balance': 4301}], ['control 6', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 35}, 'payment': 2500, 'suspense': 700, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 35}, 'curtailment': 1765, 'refund': 0, 'suspense': 0, 'new_balance': 98235}]], [['regression: new balance reduction', {'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}], ['regression: new balance reduction, partial-repair probe', {'due': {'interest': 1250, 'principal': 2000, 'late_fee': 150, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 1450, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 98550}], ['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': 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 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': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'curtailment': 1850, 'refund': 0, 'suspense': 0, 'new_balance': 150}]]]
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: new balance reduction | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 800, 'refund': 4000, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0} | Failed |
| regression: new balance reduction, partial-repair probe | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 5000, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, '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': 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 / 5b11775e635187574a9cb0f164ce10c7cbbc6db19bbea73d34a3a5b44894fea7
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']
curt = min(avail, room)
refund = avail - curt
return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - x['due']['principal'] - curt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: new balance reduction', {'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}], ['regression: new balance reduction, partial-repair probe', {'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 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': 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: new balance reduction', {'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 1', {'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 2', {'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}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 800}], ['control 4', {'due': {'interest': 0, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 151, 'suspense': 200, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 351, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1285, 'suspense': 200, 'threshold': 1285, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 200, 'refund': 0, 'suspense': 0, 'new_balance': 4800}], ['control 6', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 200, 'refund': 0, 'suspense': 0, 'new_balance': 4800}]], [['regression: new balance reduction', {'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}], ['control 1', {'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 2', {'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}], ['control 3', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 4300}], ['control 4', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 5035, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 95000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 6', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 2000}]], [['regression: new balance reduction', {'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 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': 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 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1284, 'suspense': 700, 'threshold': 1000, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 699, 'refund': 0, 'suspense': 0, 'new_balance': 99301}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 534, 'suspense': 0, 'threshold': 535, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 534, 'new_balance': 100000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1249, 'suspense': 700, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 699, 'refund': 0, 'suspense': 0, 'new_balance': 4301}], ['control 6', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 35}, 'payment': 2500, 'suspense': 700, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 35}, 'curtailment': 1765, 'refund': 0, 'suspense': 0, 'new_balance': 98235}]], [['regression: new balance reduction', {'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}], ['regression: new balance reduction, partial-repair probe', {'due': {'interest': 1250, 'principal': 2000, 'late_fee': 150, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 1450, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 98550}], ['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': 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 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': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'curtailment': 1850, 'refund': 0, 'suspense': 0, 'new_balance': 150}]]]
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: new balance reduction | {'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 |
| regression: new balance reduction, partial-repair probe | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4200, 'refund': 0, 'suspense': 0} | {'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, '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': 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 / 2b85863e04a5a1b550817d537e2f94d04b025f99a96c757dcc9f8bc0b6ef5aff
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: new balance reduction', {'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}], ['regression: new balance reduction, partial-repair probe', {'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 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': 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: new balance reduction', {'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 1', {'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 2', {'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}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 800}], ['control 4', {'due': {'interest': 0, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 151, 'suspense': 200, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 351, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1285, 'suspense': 200, 'threshold': 1285, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 200, 'refund': 0, 'suspense': 0, 'new_balance': 4800}], ['control 6', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 200, 'refund': 0, 'suspense': 0, 'new_balance': 4800}]], [['regression: new balance reduction', {'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}], ['control 1', {'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 2', {'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}], ['control 3', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 4300}], ['control 4', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 5035, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 95000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 6', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 2000}]], [['regression: new balance reduction', {'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 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': 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 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 1284, 'suspense': 700, 'threshold': 1000, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 699, 'refund': 0, 'suspense': 0, 'new_balance': 99301}], ['control 4', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 534, 'suspense': 0, 'threshold': 535, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 534, 'new_balance': 100000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1249, 'suspense': 700, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 699, 'refund': 0, 'suspense': 0, 'new_balance': 4301}], ['control 6', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 35}, 'payment': 2500, 'suspense': 700, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 35}, 'curtailment': 1765, 'refund': 0, 'suspense': 0, 'new_balance': 98235}]], [['regression: new balance reduction', {'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}], ['regression: new balance reduction, partial-repair probe', {'due': {'interest': 1250, 'principal': 2000, 'late_fee': 150, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 1450, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 98550}], ['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': 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 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': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'curtailment': 1850, 'refund': 0, 'suspense': 0, 'new_balance': 150}]]]
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: new balance reduction | {'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 |
| regression: new balance reduction, partial-repair probe | {'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 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': 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 / 99142404f8db41b25fce13335a2bdeeaf32bb9fa5eafd1977b3a6d1f93042e16
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.398826+00:00.
Case digest / 3a157f5861ee7b1754edd5e0320437890b36b7d10e2608b66ebc852c12d49b1d