FA-60281 / Inventory cost layering / Open access
Production lot cost roll-up with yield: unit cost denominator · case 01
Good-unit cost is understated because the lot cost is spread over units that were scrapped.
ROOT CAUSE
Unit cost divides by input units instead of good units.
VERIFIED REPAIR
Divide net lot cost by good units.
Unsuccessful approach: Dividing by input minus normal loss still includes abnormal scrap in the denominator.
Case contract
Input {material:[[qty,unit]], hours, rate, oh_bp (of labor cost), input_units, good_units, recovery (per scrapped unit), normal_bp}. Total = material + labor + overhead. Scrap = input - good; normal loss = floor(input*normal_bp/10000); abnormal = max(0, scrap - normal) valued at floor(total/input) per unit and expensed. Scrap recovery credits every scrapped unit. Good-unit cost = round-half-up((total - recovery credit - abnormal value)/good); good_units == 0 returns {"error"}. Return {total, abnormal_units, abnormal_value, unit_cost}.
Why this case matters
Inventory valuation and cost-of-goods decisions depend on this rule.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
mat = sum(q * u for q, u in x['material'])
labor = x['hours'] * x['rate']
oh = labor * x['oh_bp'] // 10000
total = mat + labor + oh
if x['good_units'] == 0:
return {'error': 'no good output'}
scrap = x['input_units'] - x['good_units']
normal = x['input_units'] * x['normal_bp'] // 10000
abnormal = max(0, scrap - normal)
ab_value = abnormal * (total // x['input_units'])
credit = scrap * x['recovery']
net = total - credit - ab_value
unit = (2 * net + x['input_units']) // (2 * x['input_units'])
return {'total': total, 'abnormal_units': abnormal, 'abnormal_value': ab_value, 'unit_cost': unit}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 501}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 39, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 9, 'abnormal_value': 1980, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2010, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6020, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 4, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 26037, 'abnormal_units': 3, 'abnormal_value': 2601, 'unit_cost': 866}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 151, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 502}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 38, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 10, 'abnormal_value': 2200, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2020, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6040, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 5, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 31797, 'abnormal_units': 3, 'abnormal_value': 3177, 'unit_cost': 1058}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 152, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 503}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 37, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 11, 'abnormal_value': 2420, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2030, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6060, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 6, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 37557, 'abnormal_units': 3, 'abnormal_value': 3753, 'unit_cost': 1250}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 153, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 504}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 36, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 12, 'abnormal_value': 2640, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2040, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6080, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 7, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 43317, 'abnormal_units': 3, 'abnormal_value': 4329, 'unit_cost': 1442}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 154, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 505}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 35, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 13, 'abnormal_value': 2860, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2050, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6100, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 153}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 8, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 49077, 'abnormal_units': 3, 'abnormal_value': 4905, 'unit_cost': 1634}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 155, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal run | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 286} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298} | Failed |
| abnormal loss | {'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 178} | {'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228} | Failed |
| better than normal | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151} | Passed |
| no good units | {'error': 'no good output'} | {'error': 'no good output'} | Passed |
| high overhead | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 779} | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866} | Failed |
| recovery heavy | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 277} | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325} | Failed |
SHA-256 / 410a7406f33125e6c0851d2c22fb9ebcfad945c6f7d03580a7a29f6ebab2e192
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
mat = sum(q * u for q, u in x['material'])
labor = x['hours'] * x['rate']
oh = labor * x['oh_bp'] // 10000
total = mat + labor + oh
if x['good_units'] == 0:
return {'error': 'no good output'}
scrap = x['input_units'] - x['good_units']
normal = x['input_units'] * x['normal_bp'] // 10000
abnormal = max(0, scrap - normal)
ab_value = abnormal * (total // x['input_units'])
credit = scrap * x['recovery']
net = total - credit - ab_value
unit = (2 * net + x['input_units'] - normal) // (2 * (x['input_units'] - normal))
return {'total': total, 'abnormal_units': abnormal, 'abnormal_value': ab_value, 'unit_cost': unit}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 501}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 39, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 9, 'abnormal_value': 1980, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2010, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6020, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 4, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 26037, 'abnormal_units': 3, 'abnormal_value': 2601, 'unit_cost': 866}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 151, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 502}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 38, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 10, 'abnormal_value': 2200, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2020, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6040, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 5, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 31797, 'abnormal_units': 3, 'abnormal_value': 3177, 'unit_cost': 1058}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 152, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 503}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 37, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 11, 'abnormal_value': 2420, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2030, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6060, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 6, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 37557, 'abnormal_units': 3, 'abnormal_value': 3753, 'unit_cost': 1250}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 153, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 504}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 36, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 12, 'abnormal_value': 2640, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2040, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6080, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 7, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 43317, 'abnormal_units': 3, 'abnormal_value': 4329, 'unit_cost': 1442}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 154, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 505}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 35, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 13, 'abnormal_value': 2860, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2050, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6100, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 153}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 8, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 49077, 'abnormal_units': 3, 'abnormal_value': 4905, 'unit_cost': 1634}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 155, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal run | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 301} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298} | Failed |
| abnormal loss | {'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 186} | {'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228} | Failed |
| better than normal | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 167} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151} | Failed |
| no good units | {'error': 'no good output'} | {'error': 'no good output'} | Passed |
| high overhead | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 779} | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866} | Failed |
| recovery heavy | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 307} | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325} | Failed |
SHA-256 / 0e829ea20cdfec08691365140c58366dad9576b75e3eb2d8b16e4fda51baba31
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
mat = sum(q * u for q, u in x['material'])
labor = x['hours'] * x['rate']
oh = labor * x['oh_bp'] // 10000
total = mat + labor + oh
if x['good_units'] == 0:
return {'error': 'no good output'}
scrap = x['input_units'] - x['good_units']
normal = x['input_units'] * x['normal_bp'] // 10000
abnormal = max(0, scrap - normal)
ab_value = abnormal * (total // x['input_units'])
credit = scrap * x['recovery']
net = total - credit - ab_value
unit = (2 * net + x['good_units']) // (2 * x['good_units'])
return {'total': total, 'abnormal_units': abnormal, 'abnormal_value': ab_value, 'unit_cost': unit}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 501}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 39, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 9, 'abnormal_value': 1980, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2010, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6020, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 4, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 26037, 'abnormal_units': 3, 'abnormal_value': 2601, 'unit_cost': 866}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 151, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 502}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 38, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 10, 'abnormal_value': 2200, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2020, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6040, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 5, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 31797, 'abnormal_units': 3, 'abnormal_value': 3177, 'unit_cost': 1058}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 152, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 503}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 37, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 11, 'abnormal_value': 2420, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2030, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6060, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 6, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 37557, 'abnormal_units': 3, 'abnormal_value': 3753, 'unit_cost': 1250}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 153, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 504}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 36, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 12, 'abnormal_value': 2640, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2040, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6080, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 7, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 43317, 'abnormal_units': 3, 'abnormal_value': 4329, 'unit_cost': 1442}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 154, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 505}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 35, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 13, 'abnormal_value': 2860, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2050, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6100, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 153}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 8, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 49077, 'abnormal_units': 3, 'abnormal_value': 4905, 'unit_cost': 1634}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 155, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal run | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298} | Passed |
| abnormal loss | {'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228} | {'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228} | Passed |
| better than normal | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151} | Passed |
| no good units | {'error': 'no good output'} | {'error': 'no good output'} | Passed |
| high overhead | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866} | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866} | Passed |
| recovery heavy | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325} | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325} | Passed |
SHA-256 / b37fa334cbdc369b425e57129b69dd5f376bc747ff07b662935950fbc6958d92
Verification & scope
Stipulated bounded teaching model with explicit toy rules; not an accounting-standard implementation. 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:44.113255+00:00.
Case digest / 2f58936c995654c8a1a2b45e8120b9ebf88a64517acc46064803731323eb122c