FA-60261 / Inventory cost layering / Open access
Production lot cost roll-up with yield: overhead application base · case 01
Overhead absorbed by a lot is tiny because the rate is applied to hours instead of labor cost.
ROOT CAUSE
Overhead uses labor hours as the base while the rate is stipulated as a percentage of labor cost.
VERIFIED REPAIR
Apply the overhead rate to labor cost.
Unsuccessful approach: Applying the rate to material cost uses a different allocation base.
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 = x['hours'] * 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': 13606, 'unit_cost': 142} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298} | Failed |
| abnormal loss | {'abnormal_units': 9, 'abnormal_value': 1440, 'total': 8001, 'unit_cost': 165} | {'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228} | Failed |
| better than normal | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 4011, 'unit_cost': 100} | {'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': 1020, 'total': 10205, 'unit_cost': 338} | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866} | Failed |
| recovery heavy | {'abnormal_units': 3, 'abnormal_value': 645, 'total': 12904, 'unit_cost': 214} | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325} | Failed |
SHA-256 / 35cea8e6cba170b7b0396475088a8f260e03abe039cd59bed1aab8dcc8694972
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 = mat * 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': 19000, 'unit_cost': 198} | {'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298} | Failed |
| abnormal loss | {'abnormal_units': 9, 'abnormal_value': 1620, 'total': 9000, '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': 6010, 'unit_cost': 150} | {'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': 1677, 'total': 16790, 'unit_cost': 558} | {'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866} | Failed |
| recovery heavy | {'abnormal_units': 3, 'abnormal_value': 861, 'total': 17220, 'unit_cost': 294} | {'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325} | Failed |
SHA-256 / b62307e615056b96567f58a5a6694e5216726b296591f921f55eb3d5495c9848
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.069351+00:00.
Case digest / 2497893c7ca4d464c6458359ce4fa2b84b984da84fb81a0adc477e48e63f0dc6