FA-58306 / Double-entry ledger accounting / Open access
Payroll journal entry: pre-tax deduction scope · case 01
Income tax is withheld on benefit contributions that are pre-tax.
ROOT CAUSE
The income tax base ignores the pre-tax deduction.
VERIFIED REPAIR
Reduce only the income tax base by the pre-tax benefit.
Unsuccessful approach: Moving the deduction to the social wage base shelters wages from social tax instead.
Case contract
x = {'gross': [[employee, cents]] (an employee may appear twice), 'ytd': prior year-to-date gross, 'wage_base', 'ss_bp', 'med_bp', 'itax_bp', 'benefit': {employee: pre-tax deduction per paycheck}}. Per paycheck: social wages = min(gross, max(0, wage_base - ytd)), ytd then increases by gross; social tax = round(social wages * ss_bp / 10000), medicare = round(gross * med_bp / 10000) (no cap), income tax = round((gross - benefit) * itax_bp / 10000), all half-up; net = gross - social - medicare - income tax - benefit. The employer matches social and medicare. Return {'wage_expense', 'tax_expense', 'cash', 'withholding', 'benefits'} where withholding holds employee and employer taxes.
Why this case matters
Ledger software must keep debits equal to credits and apply normal-balance, period and cutoff rules exactly; small sign or boundary slips silently misstate financial statements.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def rnd(n, d):
q, r = divmod(n, d)
return q + (1 if 2 * r >= d else 0)
ytd = dict(x['ytd'])
wage = tax_exp = cash = withholding = benefits = 0
for emp, g in x['gross']:
ben = x['benefit'].get(emp, 0)
social = min(g, max(0, x['wage_base'] - ytd.get(emp, 0)))
ytd[emp] = ytd.get(emp, 0) + g
ss = rnd(social * x['ss_bp'], 10000)
med = rnd(g * x['med_bp'], 10000)
itax = rnd(g * x['itax_bp'], 10000)
employer = ss + med
wage += g
tax_exp += employer
cash += g - ss - med - itax - ben
withholding += ss + med + itax + employer
benefits += ben
return {'wage_expense': wage, 'tax_expense': tax_exp, 'cash': cash, 'withholding': withholding, 'benefits': benefits}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: pre-tax deduction scope', {'gross': [['di', 1234], ['cy', 50000], ['bob', 50000], ['di', 80000]], 'ytd': {'di': 15000000, 'cy': 16800000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 12345, 'cy': 0, 'bob': 5000}}, {'wage_expense': 181234, 'tax_expense': 13865, 'cash': 104339, 'withholding': 61070, 'benefits': 29690}], ['control 1', {'gross': [['ann', 333333], ['ann', 200000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'ann': 0}}, {'wage_expense': 533333, 'tax_expense': 7733, 'cash': 461600, 'withholding': 79466, 'benefits': 0}], ['control 2', {'gross': [['ann', 250000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 0}}, {'wage_expense': 250000, 'tax_expense': 3625, 'cash': 191375, 'withholding': 62250, 'benefits': 0}], ['control 3', {'gross': [['cy', 100000], ['bob', 1234]], 'ytd': {'cy': 17000000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'cy': 0, 'bob': 0}}, {'wage_expense': 101234, 'tax_expense': 1545, 'cash': 89566, 'withholding': 13213, 'benefits': 0}], ['control 4', {'gross': [['bob', 333333]], 'ytd': {'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'bob': 0}}, {'wage_expense': 333333, 'tax_expense': 8553, 'cash': 284780, 'withholding': 57106, 'benefits': 0}], ['control 5', {'gross': [['cy', 333333], ['ann', 50000], ['bob', 100000]], 'ytd': {'cy': 15000000, 'ann': 16800000, 'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0, 'ann': 0, 'bob': 0}}, {'wage_expense': 483333, 'tax_expense': 36975, 'cash': 340025, 'withholding': 180283, 'benefits': 0}], ['control 6', {'gross': [['cy', 250000], ['cy', 80000]], 'ytd': {'cy': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 330000, 'tax_expense': 14705, 'cash': 242695, 'withholding': 102010, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 1234], ['bob', 100000], ['di', 50000], ['ann', 80000]], 'ytd': {'ann': 15000000, 'bob': 0, 'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 0, 'bob': 12345, 'di': 12345}}, {'wage_expense': 231234, 'tax_expense': 14590, 'cash': 146515, 'withholding': 74619, 'benefits': 24690}], ['control 1', {'gross': [['bob', 50000], ['bob', 80000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 91455, 'withholding': 48490, 'benefits': 0}], ['control 2', {'gross': [['cy', 50000], ['cy', 80000]], 'ytd': {'cy': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 91455, 'withholding': 48490, 'benefits': 0}], ['control 3', {'gross': [['cy', 250000], ['bob', 333333]], 'ytd': {'cy': 16800000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'cy': 0, 'bob': 0}}, {'wage_expense': 583333, 'tax_expense': 15898, 'cash': 497435, 'withholding': 101796, 'benefits': 0}], ['control 4', {'gross': [['ann', 1234], ['di', 333333], ['bob', 50000], ['ann', 80000]], 'ytd': {'ann': 16800000, 'di': 15000000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0, 'di': 0, 'bob': 0}}, {'wage_expense': 464567, 'tax_expense': 34223, 'cash': 383888, 'withholding': 114902, 'benefits': 0}], ['control 5', {'gross': [['cy', 50000]], 'ytd': {'cy': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 50000, 'tax_expense': 3825, 'cash': 35175, 'withholding': 18650, 'benefits': 0}], ['control 6', {'gross': [['di', 333333], ['di', 80000]], 'ytd': {'di': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 413333, 'tax_expense': 31620, 'cash': 290780, 'withholding': 154173, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 250000], ['di', 333333], ['ann', 200000]], 'ytd': {'ann': 17000000, 'di': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 5000, 'di': 12345}}, {'wage_expense': 783333, 'tax_expense': 32025, 'cash': 652864, 'withholding': 140149, 'benefits': 22345}], ['control 1', {'gross': [['cy', 250000]], 'ytd': {'cy': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'cy': 0}}, {'wage_expense': 250000, 'tax_expense': 19125, 'cash': 200875, 'withholding': 68250, 'benefits': 0}], ['control 2', {'gross': [['cy', 250000], ['cy', 200000]], 'ytd': {'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 450000, 'tax_expense': 10245, 'cash': 340755, 'withholding': 119490, 'benefits': 0}], ['control 3', {'gross': [['ann', 250000], ['ann', 200000]], 'ytd': {'ann': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 450000, 'tax_expense': 16445, 'cash': 388555, 'withholding': 77890, 'benefits': 0}], ['control 4', {'gross': [['ann', 50000], ['ann', 80000]], 'ytd': {'ann': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 107055, 'withholding': 32890, 'benefits': 0}], ['control 5', {'gross': [['bob', 333333], ['di', 1234]], 'ytd': {'bob': 15000000, 'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 0, 'di': 0}}, {'wage_expense': 334567, 'tax_expense': 25518, 'cash': 275593, 'withholding': 84492, 'benefits': 0}], ['control 6', {'gross': [['bob', 100000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'bob': 0}}, {'wage_expense': 100000, 'tax_expense': 7650, 'cash': 80350, 'withholding': 27300, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['bob', 100000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 5000}}, {'wage_expense': 100000, 'tax_expense': 7650, 'cash': 77850, 'withholding': 24800, 'benefits': 5000}], ['control 1', {'gross': [['ann', 100000]], 'ytd': {'ann': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'ann': 0}}, {'wage_expense': 100000, 'tax_expense': 5170, 'cash': 82830, 'withholding': 22340, 'benefits': 0}], ['control 2', {'gross': [['bob', 250000], ['bob', 80000]], 'ytd': {'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0}}, {'wage_expense': 330000, 'tax_expense': 8505, 'cash': 248895, 'withholding': 89610, 'benefits': 0}], ['control 3', {'gross': [['di', 333333], ['di', 80000]], 'ytd': {'di': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 413333, 'tax_expense': 15913, 'cash': 306487, 'withholding': 122759, 'benefits': 0}], ['control 4', {'gross': [['cy', 100000]], 'ytd': {'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 100000, 'tax_expense': 5170, 'cash': 72830, 'withholding': 32340, 'benefits': 0}], ['control 5', {'gross': [['di', 1234]], 'ytd': {'di': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'di': 0}}, {'wage_expense': 1234, 'tax_expense': 95, 'cash': 1016, 'withholding': 313, 'benefits': 0}], ['control 6', {'gross': [['ann', 1234], ['ann', 80000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 81234, 'tax_expense': 1178, 'cash': 71933, 'withholding': 10479, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 333333], ['bob', 250000], ['cy', 1234]], 'ytd': {'ann': 0, 'bob': 16700000, 'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 5000, 'bob': 12345, 'cy': 0}}, {'wage_expense': 584567, 'tax_expense': 39140, 'cash': 403294, 'withholding': 203068, 'benefits': 17345}], ['control 1', {'gross': [['di', 1234], ['bob', 333333], ['di', 80000]], 'ytd': {'di': 15000000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0, 'bob': 0}}, {'wage_expense': 414567, 'tax_expense': 31715, 'cash': 291648, 'withholding': 154634, 'benefits': 0}], ['control 2', {'gross': [['bob', 333333], ['bob', 200000]], 'ytd': {'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 0}}, {'wage_expense': 533333, 'tax_expense': 40800, 'cash': 439200, 'withholding': 134933, 'benefits': 0}], ['control 3', {'gross': [['bob', 100000], ['ann', 100000], ['bob', 200000]], 'ytd': {'bob': 16800000, 'ann': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0, 'ann': 0}}, {'wage_expense': 400000, 'tax_expense': 15720, 'cash': 296280, 'withholding': 119440, 'benefits': 0}], ['control 4', {'gross': [['di', 1234], ['di', 80000]], 'ytd': {'di': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'di': 0}}, {'wage_expense': 81234, 'tax_expense': 6215, 'cash': 65271, 'withholding': 22178, 'benefits': 0}], ['control 5', {'gross': [['cy', 100000], ['di', 50000], ['bob', 250000]], 'ytd': {'cy': 16800000, 'di': 16800000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0, 'di': 0, 'bob': 0}}, {'wage_expense': 400000, 'tax_expense': 28120, 'cash': 283880, 'withholding': 144240, 'benefits': 0}], ['control 6', {'gross': [['di', 250000]], 'ytd': {'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 250000, 'tax_expense': 3625, 'cash': 191375, 'withholding': 62250, 'benefits': 0}]]]
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: pre-tax deduction scope | {'benefits': 29690, 'cash': 97808, 'tax_expense': 13865, 'wage_expense': 181234, 'withholding': 67601} | {'benefits': 29690, 'cash': 104339, 'tax_expense': 13865, 'wage_expense': 181234, 'withholding': 61070} | Failed |
| control 1 | {'benefits': 0, 'cash': 461600, 'tax_expense': 7733, 'wage_expense': 533333, 'withholding': 79466} | {'benefits': 0, 'cash': 461600, 'tax_expense': 7733, 'wage_expense': 533333, 'withholding': 79466} | Passed |
| control 2 | {'benefits': 0, 'cash': 191375, 'tax_expense': 3625, 'wage_expense': 250000, 'withholding': 62250} | {'benefits': 0, 'cash': 191375, 'tax_expense': 3625, 'wage_expense': 250000, 'withholding': 62250} | Passed |
| control 3 | {'benefits': 0, 'cash': 89566, 'tax_expense': 1545, 'wage_expense': 101234, 'withholding': 13213} | {'benefits': 0, 'cash': 89566, 'tax_expense': 1545, 'wage_expense': 101234, 'withholding': 13213} | Passed |
| control 4 | {'benefits': 0, 'cash': 284780, 'tax_expense': 8553, 'wage_expense': 333333, 'withholding': 57106} | {'benefits': 0, 'cash': 284780, 'tax_expense': 8553, 'wage_expense': 333333, 'withholding': 57106} | Passed |
| control 5 | {'benefits': 0, 'cash': 340025, 'tax_expense': 36975, 'wage_expense': 483333, 'withholding': 180283} | {'benefits': 0, 'cash': 340025, 'tax_expense': 36975, 'wage_expense': 483333, 'withholding': 180283} | Passed |
| control 6 | {'benefits': 0, 'cash': 242695, 'tax_expense': 14705, 'wage_expense': 330000, 'withholding': 102010} | {'benefits': 0, 'cash': 242695, 'tax_expense': 14705, 'wage_expense': 330000, 'withholding': 102010} | Passed |
SHA-256 / 3ec1b6427b36db785f366560fcbaf6366b668c196cafbff136172a43e95de272
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def rnd(n, d):
q, r = divmod(n, d)
return q + (1 if 2 * r >= d else 0)
ytd = dict(x['ytd'])
wage = tax_exp = cash = withholding = benefits = 0
for emp, g in x['gross']:
ben = x['benefit'].get(emp, 0)
social = min(g - ben, max(0, x['wage_base'] - ytd.get(emp, 0)))
ytd[emp] = ytd.get(emp, 0) + g
ss = rnd(social * x['ss_bp'], 10000)
med = rnd(g * x['med_bp'], 10000)
itax = rnd(g * x['itax_bp'], 10000)
employer = ss + med
wage += g
tax_exp += employer
cash += g - ss - med - itax - ben
withholding += ss + med + itax + employer
benefits += ben
return {'wage_expense': wage, 'tax_expense': tax_exp, 'cash': cash, 'withholding': withholding, 'benefits': benefits}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: pre-tax deduction scope', {'gross': [['di', 1234], ['cy', 50000], ['bob', 50000], ['di', 80000]], 'ytd': {'di': 15000000, 'cy': 16800000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 12345, 'cy': 0, 'bob': 5000}}, {'wage_expense': 181234, 'tax_expense': 13865, 'cash': 104339, 'withholding': 61070, 'benefits': 29690}], ['control 1', {'gross': [['ann', 333333], ['ann', 200000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'ann': 0}}, {'wage_expense': 533333, 'tax_expense': 7733, 'cash': 461600, 'withholding': 79466, 'benefits': 0}], ['control 2', {'gross': [['ann', 250000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 0}}, {'wage_expense': 250000, 'tax_expense': 3625, 'cash': 191375, 'withholding': 62250, 'benefits': 0}], ['control 3', {'gross': [['cy', 100000], ['bob', 1234]], 'ytd': {'cy': 17000000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'cy': 0, 'bob': 0}}, {'wage_expense': 101234, 'tax_expense': 1545, 'cash': 89566, 'withholding': 13213, 'benefits': 0}], ['control 4', {'gross': [['bob', 333333]], 'ytd': {'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'bob': 0}}, {'wage_expense': 333333, 'tax_expense': 8553, 'cash': 284780, 'withholding': 57106, 'benefits': 0}], ['control 5', {'gross': [['cy', 333333], ['ann', 50000], ['bob', 100000]], 'ytd': {'cy': 15000000, 'ann': 16800000, 'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0, 'ann': 0, 'bob': 0}}, {'wage_expense': 483333, 'tax_expense': 36975, 'cash': 340025, 'withholding': 180283, 'benefits': 0}], ['control 6', {'gross': [['cy', 250000], ['cy', 80000]], 'ytd': {'cy': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 330000, 'tax_expense': 14705, 'cash': 242695, 'withholding': 102010, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 1234], ['bob', 100000], ['di', 50000], ['ann', 80000]], 'ytd': {'ann': 15000000, 'bob': 0, 'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 0, 'bob': 12345, 'di': 12345}}, {'wage_expense': 231234, 'tax_expense': 14590, 'cash': 146515, 'withholding': 74619, 'benefits': 24690}], ['control 1', {'gross': [['bob', 50000], ['bob', 80000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 91455, 'withholding': 48490, 'benefits': 0}], ['control 2', {'gross': [['cy', 50000], ['cy', 80000]], 'ytd': {'cy': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 91455, 'withholding': 48490, 'benefits': 0}], ['control 3', {'gross': [['cy', 250000], ['bob', 333333]], 'ytd': {'cy': 16800000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'cy': 0, 'bob': 0}}, {'wage_expense': 583333, 'tax_expense': 15898, 'cash': 497435, 'withholding': 101796, 'benefits': 0}], ['control 4', {'gross': [['ann', 1234], ['di', 333333], ['bob', 50000], ['ann', 80000]], 'ytd': {'ann': 16800000, 'di': 15000000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0, 'di': 0, 'bob': 0}}, {'wage_expense': 464567, 'tax_expense': 34223, 'cash': 383888, 'withholding': 114902, 'benefits': 0}], ['control 5', {'gross': [['cy', 50000]], 'ytd': {'cy': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 50000, 'tax_expense': 3825, 'cash': 35175, 'withholding': 18650, 'benefits': 0}], ['control 6', {'gross': [['di', 333333], ['di', 80000]], 'ytd': {'di': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 413333, 'tax_expense': 31620, 'cash': 290780, 'withholding': 154173, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 250000], ['di', 333333], ['ann', 200000]], 'ytd': {'ann': 17000000, 'di': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 5000, 'di': 12345}}, {'wage_expense': 783333, 'tax_expense': 32025, 'cash': 652864, 'withholding': 140149, 'benefits': 22345}], ['control 1', {'gross': [['cy', 250000]], 'ytd': {'cy': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'cy': 0}}, {'wage_expense': 250000, 'tax_expense': 19125, 'cash': 200875, 'withholding': 68250, 'benefits': 0}], ['control 2', {'gross': [['cy', 250000], ['cy', 200000]], 'ytd': {'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 450000, 'tax_expense': 10245, 'cash': 340755, 'withholding': 119490, 'benefits': 0}], ['control 3', {'gross': [['ann', 250000], ['ann', 200000]], 'ytd': {'ann': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 450000, 'tax_expense': 16445, 'cash': 388555, 'withholding': 77890, 'benefits': 0}], ['control 4', {'gross': [['ann', 50000], ['ann', 80000]], 'ytd': {'ann': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 107055, 'withholding': 32890, 'benefits': 0}], ['control 5', {'gross': [['bob', 333333], ['di', 1234]], 'ytd': {'bob': 15000000, 'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 0, 'di': 0}}, {'wage_expense': 334567, 'tax_expense': 25518, 'cash': 275593, 'withholding': 84492, 'benefits': 0}], ['control 6', {'gross': [['bob', 100000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'bob': 0}}, {'wage_expense': 100000, 'tax_expense': 7650, 'cash': 80350, 'withholding': 27300, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['bob', 100000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 5000}}, {'wage_expense': 100000, 'tax_expense': 7650, 'cash': 77850, 'withholding': 24800, 'benefits': 5000}], ['control 1', {'gross': [['ann', 100000]], 'ytd': {'ann': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'ann': 0}}, {'wage_expense': 100000, 'tax_expense': 5170, 'cash': 82830, 'withholding': 22340, 'benefits': 0}], ['control 2', {'gross': [['bob', 250000], ['bob', 80000]], 'ytd': {'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0}}, {'wage_expense': 330000, 'tax_expense': 8505, 'cash': 248895, 'withholding': 89610, 'benefits': 0}], ['control 3', {'gross': [['di', 333333], ['di', 80000]], 'ytd': {'di': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 413333, 'tax_expense': 15913, 'cash': 306487, 'withholding': 122759, 'benefits': 0}], ['control 4', {'gross': [['cy', 100000]], 'ytd': {'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 100000, 'tax_expense': 5170, 'cash': 72830, 'withholding': 32340, 'benefits': 0}], ['control 5', {'gross': [['di', 1234]], 'ytd': {'di': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'di': 0}}, {'wage_expense': 1234, 'tax_expense': 95, 'cash': 1016, 'withholding': 313, 'benefits': 0}], ['control 6', {'gross': [['ann', 1234], ['ann', 80000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 81234, 'tax_expense': 1178, 'cash': 71933, 'withholding': 10479, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 333333], ['bob', 250000], ['cy', 1234]], 'ytd': {'ann': 0, 'bob': 16700000, 'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 5000, 'bob': 12345, 'cy': 0}}, {'wage_expense': 584567, 'tax_expense': 39140, 'cash': 403294, 'withholding': 203068, 'benefits': 17345}], ['control 1', {'gross': [['di', 1234], ['bob', 333333], ['di', 80000]], 'ytd': {'di': 15000000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0, 'bob': 0}}, {'wage_expense': 414567, 'tax_expense': 31715, 'cash': 291648, 'withholding': 154634, 'benefits': 0}], ['control 2', {'gross': [['bob', 333333], ['bob', 200000]], 'ytd': {'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 0}}, {'wage_expense': 533333, 'tax_expense': 40800, 'cash': 439200, 'withholding': 134933, 'benefits': 0}], ['control 3', {'gross': [['bob', 100000], ['ann', 100000], ['bob', 200000]], 'ytd': {'bob': 16800000, 'ann': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0, 'ann': 0}}, {'wage_expense': 400000, 'tax_expense': 15720, 'cash': 296280, 'withholding': 119440, 'benefits': 0}], ['control 4', {'gross': [['di', 1234], ['di', 80000]], 'ytd': {'di': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'di': 0}}, {'wage_expense': 81234, 'tax_expense': 6215, 'cash': 65271, 'withholding': 22178, 'benefits': 0}], ['control 5', {'gross': [['cy', 100000], ['di', 50000], ['bob', 250000]], 'ytd': {'cy': 16800000, 'di': 16800000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0, 'di': 0, 'bob': 0}}, {'wage_expense': 400000, 'tax_expense': 28120, 'cash': 283880, 'withholding': 144240, 'benefits': 0}], ['control 6', {'gross': [['di', 250000]], 'ytd': {'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 250000, 'tax_expense': 3625, 'cash': 191375, 'withholding': 62250, 'benefits': 0}]]]
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: pre-tax deduction scope | {'benefits': 29690, 'cash': 99649, 'tax_expense': 12024, 'wage_expense': 181234, 'withholding': 63919} | {'benefits': 29690, 'cash': 104339, 'tax_expense': 13865, 'wage_expense': 181234, 'withholding': 61070} | Failed |
| control 1 | {'benefits': 0, 'cash': 461600, 'tax_expense': 7733, 'wage_expense': 533333, 'withholding': 79466} | {'benefits': 0, 'cash': 461600, 'tax_expense': 7733, 'wage_expense': 533333, 'withholding': 79466} | Passed |
| control 2 | {'benefits': 0, 'cash': 191375, 'tax_expense': 3625, 'wage_expense': 250000, 'withholding': 62250} | {'benefits': 0, 'cash': 191375, 'tax_expense': 3625, 'wage_expense': 250000, 'withholding': 62250} | Passed |
| control 3 | {'benefits': 0, 'cash': 89566, 'tax_expense': 1545, 'wage_expense': 101234, 'withholding': 13213} | {'benefits': 0, 'cash': 89566, 'tax_expense': 1545, 'wage_expense': 101234, 'withholding': 13213} | Passed |
| control 4 | {'benefits': 0, 'cash': 284780, 'tax_expense': 8553, 'wage_expense': 333333, 'withholding': 57106} | {'benefits': 0, 'cash': 284780, 'tax_expense': 8553, 'wage_expense': 333333, 'withholding': 57106} | Passed |
| control 5 | {'benefits': 0, 'cash': 340025, 'tax_expense': 36975, 'wage_expense': 483333, 'withholding': 180283} | {'benefits': 0, 'cash': 340025, 'tax_expense': 36975, 'wage_expense': 483333, 'withholding': 180283} | Passed |
| control 6 | {'benefits': 0, 'cash': 242695, 'tax_expense': 14705, 'wage_expense': 330000, 'withholding': 102010} | {'benefits': 0, 'cash': 242695, 'tax_expense': 14705, 'wage_expense': 330000, 'withholding': 102010} | Passed |
SHA-256 / d76fd62b47e29b6ec8c4db7e7baf6a0bbc6104724baf1dc6810216b507c792d5
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def rnd(n, d):
q, r = divmod(n, d)
return q + (1 if 2 * r >= d else 0)
ytd = dict(x['ytd'])
wage = tax_exp = cash = withholding = benefits = 0
for emp, g in x['gross']:
ben = x['benefit'].get(emp, 0)
social = min(g, max(0, x['wage_base'] - ytd.get(emp, 0)))
ytd[emp] = ytd.get(emp, 0) + g
ss = rnd(social * x['ss_bp'], 10000)
med = rnd(g * x['med_bp'], 10000)
itax = rnd((g - ben) * x['itax_bp'], 10000)
employer = ss + med
wage += g
tax_exp += employer
cash += g - ss - med - itax - ben
withholding += ss + med + itax + employer
benefits += ben
return {'wage_expense': wage, 'tax_expense': tax_exp, 'cash': cash, 'withholding': withholding, 'benefits': benefits}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: pre-tax deduction scope', {'gross': [['di', 1234], ['cy', 50000], ['bob', 50000], ['di', 80000]], 'ytd': {'di': 15000000, 'cy': 16800000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 12345, 'cy': 0, 'bob': 5000}}, {'wage_expense': 181234, 'tax_expense': 13865, 'cash': 104339, 'withholding': 61070, 'benefits': 29690}], ['control 1', {'gross': [['ann', 333333], ['ann', 200000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'ann': 0}}, {'wage_expense': 533333, 'tax_expense': 7733, 'cash': 461600, 'withholding': 79466, 'benefits': 0}], ['control 2', {'gross': [['ann', 250000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 0}}, {'wage_expense': 250000, 'tax_expense': 3625, 'cash': 191375, 'withholding': 62250, 'benefits': 0}], ['control 3', {'gross': [['cy', 100000], ['bob', 1234]], 'ytd': {'cy': 17000000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'cy': 0, 'bob': 0}}, {'wage_expense': 101234, 'tax_expense': 1545, 'cash': 89566, 'withholding': 13213, 'benefits': 0}], ['control 4', {'gross': [['bob', 333333]], 'ytd': {'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'bob': 0}}, {'wage_expense': 333333, 'tax_expense': 8553, 'cash': 284780, 'withholding': 57106, 'benefits': 0}], ['control 5', {'gross': [['cy', 333333], ['ann', 50000], ['bob', 100000]], 'ytd': {'cy': 15000000, 'ann': 16800000, 'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0, 'ann': 0, 'bob': 0}}, {'wage_expense': 483333, 'tax_expense': 36975, 'cash': 340025, 'withholding': 180283, 'benefits': 0}], ['control 6', {'gross': [['cy', 250000], ['cy', 80000]], 'ytd': {'cy': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 330000, 'tax_expense': 14705, 'cash': 242695, 'withholding': 102010, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 1234], ['bob', 100000], ['di', 50000], ['ann', 80000]], 'ytd': {'ann': 15000000, 'bob': 0, 'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 0, 'bob': 12345, 'di': 12345}}, {'wage_expense': 231234, 'tax_expense': 14590, 'cash': 146515, 'withholding': 74619, 'benefits': 24690}], ['control 1', {'gross': [['bob', 50000], ['bob', 80000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 91455, 'withholding': 48490, 'benefits': 0}], ['control 2', {'gross': [['cy', 50000], ['cy', 80000]], 'ytd': {'cy': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 91455, 'withholding': 48490, 'benefits': 0}], ['control 3', {'gross': [['cy', 250000], ['bob', 333333]], 'ytd': {'cy': 16800000, 'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'cy': 0, 'bob': 0}}, {'wage_expense': 583333, 'tax_expense': 15898, 'cash': 497435, 'withholding': 101796, 'benefits': 0}], ['control 4', {'gross': [['ann', 1234], ['di', 333333], ['bob', 50000], ['ann', 80000]], 'ytd': {'ann': 16800000, 'di': 15000000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0, 'di': 0, 'bob': 0}}, {'wage_expense': 464567, 'tax_expense': 34223, 'cash': 383888, 'withholding': 114902, 'benefits': 0}], ['control 5', {'gross': [['cy', 50000]], 'ytd': {'cy': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 50000, 'tax_expense': 3825, 'cash': 35175, 'withholding': 18650, 'benefits': 0}], ['control 6', {'gross': [['di', 333333], ['di', 80000]], 'ytd': {'di': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 413333, 'tax_expense': 31620, 'cash': 290780, 'withholding': 154173, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 250000], ['di', 333333], ['ann', 200000]], 'ytd': {'ann': 17000000, 'di': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 5000, 'di': 12345}}, {'wage_expense': 783333, 'tax_expense': 32025, 'cash': 652864, 'withholding': 140149, 'benefits': 22345}], ['control 1', {'gross': [['cy', 250000]], 'ytd': {'cy': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'cy': 0}}, {'wage_expense': 250000, 'tax_expense': 19125, 'cash': 200875, 'withholding': 68250, 'benefits': 0}], ['control 2', {'gross': [['cy', 250000], ['cy', 200000]], 'ytd': {'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 450000, 'tax_expense': 10245, 'cash': 340755, 'withholding': 119490, 'benefits': 0}], ['control 3', {'gross': [['ann', 250000], ['ann', 200000]], 'ytd': {'ann': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 450000, 'tax_expense': 16445, 'cash': 388555, 'withholding': 77890, 'benefits': 0}], ['control 4', {'gross': [['ann', 50000], ['ann', 80000]], 'ytd': {'ann': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 130000, 'tax_expense': 9945, 'cash': 107055, 'withholding': 32890, 'benefits': 0}], ['control 5', {'gross': [['bob', 333333], ['di', 1234]], 'ytd': {'bob': 15000000, 'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 0, 'di': 0}}, {'wage_expense': 334567, 'tax_expense': 25518, 'cash': 275593, 'withholding': 84492, 'benefits': 0}], ['control 6', {'gross': [['bob', 100000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'bob': 0}}, {'wage_expense': 100000, 'tax_expense': 7650, 'cash': 80350, 'withholding': 27300, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['bob', 100000]], 'ytd': {'bob': 15000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 5000}}, {'wage_expense': 100000, 'tax_expense': 7650, 'cash': 77850, 'withholding': 24800, 'benefits': 5000}], ['control 1', {'gross': [['ann', 100000]], 'ytd': {'ann': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'ann': 0}}, {'wage_expense': 100000, 'tax_expense': 5170, 'cash': 82830, 'withholding': 22340, 'benefits': 0}], ['control 2', {'gross': [['bob', 250000], ['bob', 80000]], 'ytd': {'bob': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0}}, {'wage_expense': 330000, 'tax_expense': 8505, 'cash': 248895, 'withholding': 89610, 'benefits': 0}], ['control 3', {'gross': [['di', 333333], ['di', 80000]], 'ytd': {'di': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 413333, 'tax_expense': 15913, 'cash': 306487, 'withholding': 122759, 'benefits': 0}], ['control 4', {'gross': [['cy', 100000]], 'ytd': {'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0}}, {'wage_expense': 100000, 'tax_expense': 5170, 'cash': 72830, 'withholding': 32340, 'benefits': 0}], ['control 5', {'gross': [['di', 1234]], 'ytd': {'di': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'di': 0}}, {'wage_expense': 1234, 'tax_expense': 95, 'cash': 1016, 'withholding': 313, 'benefits': 0}], ['control 6', {'gross': [['ann', 1234], ['ann', 80000]], 'ytd': {'ann': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'ann': 0}}, {'wage_expense': 81234, 'tax_expense': 1178, 'cash': 71933, 'withholding': 10479, 'benefits': 0}]], [['regression: pre-tax deduction scope', {'gross': [['ann', 333333], ['bob', 250000], ['cy', 1234]], 'ytd': {'ann': 0, 'bob': 16700000, 'cy': 16800000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'ann': 5000, 'bob': 12345, 'cy': 0}}, {'wage_expense': 584567, 'tax_expense': 39140, 'cash': 403294, 'withholding': 203068, 'benefits': 17345}], ['control 1', {'gross': [['di', 1234], ['bob', 333333], ['di', 80000]], 'ytd': {'di': 15000000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0, 'bob': 0}}, {'wage_expense': 414567, 'tax_expense': 31715, 'cash': 291648, 'withholding': 154634, 'benefits': 0}], ['control 2', {'gross': [['bob', 333333], ['bob', 200000]], 'ytd': {'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1000, 'benefit': {'bob': 0}}, {'wage_expense': 533333, 'tax_expense': 40800, 'cash': 439200, 'withholding': 134933, 'benefits': 0}], ['control 3', {'gross': [['bob', 100000], ['ann', 100000], ['bob', 200000]], 'ytd': {'bob': 16800000, 'ann': 16700000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'bob': 0, 'ann': 0}}, {'wage_expense': 400000, 'tax_expense': 15720, 'cash': 296280, 'withholding': 119440, 'benefits': 0}], ['control 4', {'gross': [['di', 1234], ['di', 80000]], 'ytd': {'di': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 1200, 'benefit': {'di': 0}}, {'wage_expense': 81234, 'tax_expense': 6215, 'cash': 65271, 'withholding': 22178, 'benefits': 0}], ['control 5', {'gross': [['cy', 100000], ['di', 50000], ['bob', 250000]], 'ytd': {'cy': 16800000, 'di': 16800000, 'bob': 0}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'cy': 0, 'di': 0, 'bob': 0}}, {'wage_expense': 400000, 'tax_expense': 28120, 'cash': 283880, 'withholding': 144240, 'benefits': 0}], ['control 6', {'gross': [['di', 250000]], 'ytd': {'di': 17000000}, 'wage_base': 16860000, 'ss_bp': 620, 'med_bp': 145, 'itax_bp': 2200, 'benefit': {'di': 0}}, {'wage_expense': 250000, 'tax_expense': 3625, 'cash': 191375, 'withholding': 62250, 'benefits': 0}]]]
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: pre-tax deduction scope | {'benefits': 29690, 'cash': 104339, 'tax_expense': 13865, 'wage_expense': 181234, 'withholding': 61070} | {'benefits': 29690, 'cash': 104339, 'tax_expense': 13865, 'wage_expense': 181234, 'withholding': 61070} | Passed |
| control 1 | {'benefits': 0, 'cash': 461600, 'tax_expense': 7733, 'wage_expense': 533333, 'withholding': 79466} | {'benefits': 0, 'cash': 461600, 'tax_expense': 7733, 'wage_expense': 533333, 'withholding': 79466} | Passed |
| control 2 | {'benefits': 0, 'cash': 191375, 'tax_expense': 3625, 'wage_expense': 250000, 'withholding': 62250} | {'benefits': 0, 'cash': 191375, 'tax_expense': 3625, 'wage_expense': 250000, 'withholding': 62250} | Passed |
| control 3 | {'benefits': 0, 'cash': 89566, 'tax_expense': 1545, 'wage_expense': 101234, 'withholding': 13213} | {'benefits': 0, 'cash': 89566, 'tax_expense': 1545, 'wage_expense': 101234, 'withholding': 13213} | Passed |
| control 4 | {'benefits': 0, 'cash': 284780, 'tax_expense': 8553, 'wage_expense': 333333, 'withholding': 57106} | {'benefits': 0, 'cash': 284780, 'tax_expense': 8553, 'wage_expense': 333333, 'withholding': 57106} | Passed |
| control 5 | {'benefits': 0, 'cash': 340025, 'tax_expense': 36975, 'wage_expense': 483333, 'withholding': 180283} | {'benefits': 0, 'cash': 340025, 'tax_expense': 36975, 'wage_expense': 483333, 'withholding': 180283} | Passed |
| control 6 | {'benefits': 0, 'cash': 242695, 'tax_expense': 14705, 'wage_expense': 330000, 'withholding': 102010} | {'benefits': 0, 'cash': 242695, 'tax_expense': 14705, 'wage_expense': 330000, 'withholding': 102010} | Passed |
SHA-256 / a01156398223582ec17de4f9436cdcb21cea1b86fa406aad9dfd680be2451a84
Verification & scope
A deterministic bounded teaching model with stipulated toy bookkeeping rules stated in the contract; amounts are integer cents; it makes no claim of conformance to any accounting 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:25.437851+00:00.
Case digest / 9f0781527eb8b2a35755a7bb85b36ffe478655779ea88437165dddd39eba4edc