FA-60096 / Inventory cost layering / Open access
Standard cost material variances: allowance for scrapped units · case 01
Usage variance hides material wasted on scrapped units.
ROOT CAUSE
Standard allowed quantity is granted for good plus scrapped units.
VERIFIED REPAIR
Allow standard material for good units only.
Unsuccessful approach: Adding scrapped units as a flat quantity allowance still grants material for scrap.
Case contract
Input {std_price, std_qty (per good unit), good_units, scrap_units, purchases:[[qty,total_cost]], used}. The price variance is isolated at purchase: sum(total_cost - qty*std_price). Standard allowed quantity is std_qty*good_units (scrap earns no allowance). Usage variance = (used - allowed)*std_price. Labels: positive "U", negative "F", zero "-". Return {ppv, ppv_label, usage, usage_label, allowed}.
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):
ppv = sum(tc - q * x['std_price'] for q, tc in x['purchases'])
allowed = x['std_qty'] * (x['good_units'] + x['scrap_units'])
usage = (x['used'] - allowed) * x['std_price']
lab = lambda v: 'U' if v > 0 else ('F' if v < 0 else '-')
return {'ppv': ppv, 'ppv_label': lab(ppv), 'usage': usage, 'usage_label': lab(usage), 'allowed': allowed}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8401]], 'used': 33}, {'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 21, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 40}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 42}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1301]], 'used': 26}, {'ppv': 201, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 4, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 6}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2110], [5, 700]], 'used': 11}, {'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8402]], 'used': 33}, {'ppv': 402, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 22, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 42}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 44}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1302]], 'used': 26}, {'ppv': 202, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 5, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 7}, {'ppv': 0, 'ppv_label': '-', 'usage': 90, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2120], [5, 700]], 'used': 11}, {'ppv': -180, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8403]], 'used': 33}, {'ppv': 403, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 23, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 44}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 46}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1303]], 'used': 26}, {'ppv': 203, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 6, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 180, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2130], [5, 700]], 'used': 11}, {'ppv': -170, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8404]], 'used': 33}, {'ppv': 404, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 24, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 46}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 48}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1304]], 'used': 26}, {'ppv': 204, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 7, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 9}, {'ppv': 0, 'ppv_label': '-', 'usage': 270, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2140], [5, 700]], 'used': 11}, {'ppv': -160, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8405]], 'used': 33}, {'ppv': 405, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 25, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 48}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 50}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1305]], 'used': 26}, {'ppv': 205, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 8, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 10}, {'ppv': 0, 'ppv_label': '-', 'usage': 360, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2150], [5, 700]], 'used': 11}, {'ppv': -150, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]]]
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 |
|---|---|---|---|
| unfavorable price | {'allowed': 33, 'ppv': 401, 'ppv_label': 'U', 'usage': 0, 'usage_label': '-'} | {'allowed': 30, 'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | Failed |
| favorable usage | {'allowed': 42, 'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F'} | {'allowed': 42, 'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F'} | Passed |
| two purchases | {'allowed': 28, 'ppv': 201, 'ppv_label': 'U', 'usage': -200, 'usage_label': 'F'} | {'allowed': 20, 'ppv': 201, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | Failed |
| exact standard | {'allowed': 8, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | {'allowed': 8, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | Passed |
| scrap heavy | {'allowed': 50, 'ppv': 250, 'ppv_label': 'U', 'usage': -250, 'usage_label': 'F'} | {'allowed': 30, 'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U'} | Failed |
| no purchases | {'allowed': 8, 'ppv': 0, 'ppv_label': '-', 'usage': -180, 'usage_label': 'F'} | {'allowed': 6, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | Failed |
| mixed signs | {'allowed': 15, 'ppv': -190, 'ppv_label': 'F', 'usage': -480, 'usage_label': 'F'} | {'allowed': 12, 'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F'} | Failed |
SHA-256 / 9f837156bf58e982b3477aea68093b4f27fb29df3003c54d1aa59c571d22d38d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
ppv = sum(tc - q * x['std_price'] for q, tc in x['purchases'])
allowed = x['std_qty'] * x['good_units'] + x['scrap_units']
usage = (x['used'] - allowed) * x['std_price']
lab = lambda v: 'U' if v > 0 else ('F' if v < 0 else '-')
return {'ppv': ppv, 'ppv_label': lab(ppv), 'usage': usage, 'usage_label': lab(usage), 'allowed': allowed}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8401]], 'used': 33}, {'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 21, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 40}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 42}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1301]], 'used': 26}, {'ppv': 201, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 4, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 6}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2110], [5, 700]], 'used': 11}, {'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8402]], 'used': 33}, {'ppv': 402, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 22, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 42}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 44}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1302]], 'used': 26}, {'ppv': 202, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 5, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 7}, {'ppv': 0, 'ppv_label': '-', 'usage': 90, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2120], [5, 700]], 'used': 11}, {'ppv': -180, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8403]], 'used': 33}, {'ppv': 403, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 23, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 44}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 46}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1303]], 'used': 26}, {'ppv': 203, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 6, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 180, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2130], [5, 700]], 'used': 11}, {'ppv': -170, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8404]], 'used': 33}, {'ppv': 404, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 24, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 46}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 48}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1304]], 'used': 26}, {'ppv': 204, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 7, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 9}, {'ppv': 0, 'ppv_label': '-', 'usage': 270, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2140], [5, 700]], 'used': 11}, {'ppv': -160, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8405]], 'used': 33}, {'ppv': 405, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 25, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 48}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 50}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1305]], 'used': 26}, {'ppv': 205, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 8, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 10}, {'ppv': 0, 'ppv_label': '-', 'usage': 360, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2150], [5, 700]], 'used': 11}, {'ppv': -150, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]]]
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 |
|---|---|---|---|
| unfavorable price | {'allowed': 31, 'ppv': 401, 'ppv_label': 'U', 'usage': 400, 'usage_label': 'U'} | {'allowed': 30, 'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | Failed |
| favorable usage | {'allowed': 42, 'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F'} | {'allowed': 42, 'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F'} | Passed |
| two purchases | {'allowed': 22, 'ppv': 201, 'ppv_label': 'U', 'usage': 400, 'usage_label': 'U'} | {'allowed': 20, 'ppv': 201, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | Failed |
| exact standard | {'allowed': 8, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | {'allowed': 8, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | Passed |
| scrap heavy | {'allowed': 34, 'ppv': 250, 'ppv_label': 'U', 'usage': 550, 'usage_label': 'U'} | {'allowed': 30, 'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U'} | Failed |
| no purchases | {'allowed': 7, 'ppv': 0, 'ppv_label': '-', 'usage': -90, 'usage_label': 'F'} | {'allowed': 6, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | Failed |
| mixed signs | {'allowed': 13, 'ppv': -190, 'ppv_label': 'F', 'usage': -240, 'usage_label': 'F'} | {'allowed': 12, 'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F'} | Failed |
SHA-256 / 42b1ffa6a2aa4563feacfb2a69bcf455492dfcbb85a3d831f4c090edea93792c
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
ppv = sum(tc - q * x['std_price'] for q, tc in x['purchases'])
allowed = x['std_qty'] * x['good_units']
usage = (x['used'] - allowed) * x['std_price']
lab = lambda v: 'U' if v > 0 else ('F' if v < 0 else '-')
return {'ppv': ppv, 'ppv_label': lab(ppv), 'usage': usage, 'usage_label': lab(usage), 'allowed': allowed}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8401]], 'used': 33}, {'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 21, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 40}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 42}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1301]], 'used': 26}, {'ppv': 201, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 4, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 6}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2110], [5, 700]], 'used': 11}, {'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8402]], 'used': 33}, {'ppv': 402, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 22, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 42}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 44}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1302]], 'used': 26}, {'ppv': 202, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 5, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 7}, {'ppv': 0, 'ppv_label': '-', 'usage': 90, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2120], [5, 700]], 'used': 11}, {'ppv': -180, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8403]], 'used': 33}, {'ppv': 403, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 23, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 44}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 46}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1303]], 'used': 26}, {'ppv': 203, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 6, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 180, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2130], [5, 700]], 'used': 11}, {'ppv': -170, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8404]], 'used': 33}, {'ppv': 404, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 24, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 46}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 48}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1304]], 'used': 26}, {'ppv': 204, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 7, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 9}, {'ppv': 0, 'ppv_label': '-', 'usage': 270, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2140], [5, 700]], 'used': 11}, {'ppv': -160, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]], [['unfavorable price', {'std_price': 200, 'std_qty': 3, 'good_units': 10, 'scrap_units': 1, 'purchases': [[40, 8405]], 'used': 33}, {'ppv': 405, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 30}], ['favorable usage', {'std_price': 150, 'std_qty': 2, 'good_units': 25, 'scrap_units': 0, 'purchases': [[50, 7000]], 'used': 48}, {'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F', 'allowed': 50}], ['two purchases', {'std_price': 100, 'std_qty': 4, 'good_units': 5, 'scrap_units': 2, 'purchases': [[10, 900], [10, 1305]], 'used': 26}, {'ppv': 205, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U', 'allowed': 20}], ['exact standard', {'std_price': 75, 'std_qty': 1, 'good_units': 8, 'scrap_units': 0, 'purchases': [[8, 600]], 'used': 8}, {'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-', 'allowed': 8}], ['scrap heavy', {'std_price': 50, 'std_qty': 5, 'good_units': 6, 'scrap_units': 8, 'purchases': [[60, 3300], [5, 200]], 'used': 45}, {'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U', 'allowed': 30}], ['no purchases', {'std_price': 90, 'std_qty': 2, 'good_units': 3, 'scrap_units': 1, 'purchases': [], 'used': 10}, {'ppv': 0, 'ppv_label': '-', 'usage': 360, 'usage_label': 'U', 'allowed': 6}], ['mixed signs', {'std_price': 120, 'std_qty': 3, 'good_units': 4, 'scrap_units': 1, 'purchases': [[20, 2150], [5, 700]], 'used': 11}, {'ppv': -150, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F', 'allowed': 12}]]]
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 |
|---|---|---|---|
| unfavorable price | {'allowed': 30, 'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | {'allowed': 30, 'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | Passed |
| favorable usage | {'allowed': 42, 'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F'} | {'allowed': 42, 'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F'} | Passed |
| two purchases | {'allowed': 20, 'ppv': 201, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | {'allowed': 20, 'ppv': 201, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | Passed |
| exact standard | {'allowed': 8, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | {'allowed': 8, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | Passed |
| scrap heavy | {'allowed': 30, 'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U'} | {'allowed': 30, 'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U'} | Passed |
| no purchases | {'allowed': 6, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | {'allowed': 6, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | Passed |
| mixed signs | {'allowed': 12, 'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F'} | {'allowed': 12, 'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F'} | Passed |
SHA-256 / 8a558d1f9f927d39bf72a22098f39712a55ef4d0ea493447667cfd650e59d78f
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:42.419462+00:00.
Case digest / d0b5ceccc65831eaa61fc797e0d4dbb9b010e6b39c0d3a47122e430705867a0c