FA-60091 / Inventory cost layering / Open access
Standard cost material variances: price variance isolation point · case 01
Purchase price variance changes with consumption even though it should be fixed when material is bought.
ROOT CAUSE
The price variance compares total purchase cost with standard cost of the quantity used, mixing usage into price.
VERIFIED REPAIR
Compute price variance per purchase: total cost - purchased qty * standard price.
Unsuccessful approach: Using only the latest purchase line drops the variance on earlier receipts.
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 for q, tc in x['purchases']) - x['used'] * x['std_price']
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': 1801, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | {'allowed': 30, 'ppv': 401, 'ppv_label': 'U', 'usage': 600, 'usage_label': 'U'} | Failed |
| favorable usage | {'allowed': 42, 'ppv': 1000, 'ppv_label': 'U', 'usage': -300, 'usage_label': 'F'} | {'allowed': 42, 'ppv': -500, 'ppv_label': 'F', 'usage': -300, 'usage_label': 'F'} | Failed |
| two purchases | {'allowed': 20, 'ppv': -399, 'ppv_label': 'F', 'usage': 600, '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': 30, 'ppv': 1250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U'} | {'allowed': 30, 'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U'} | Failed |
| no purchases | {'allowed': 6, 'ppv': -540, 'ppv_label': 'F', 'usage': 0, 'usage_label': '-'} | {'allowed': 6, 'ppv': 0, 'ppv_label': '-', 'usage': 0, 'usage_label': '-'} | Failed |
| mixed signs | {'allowed': 12, 'ppv': 1490, 'ppv_label': 'U', 'usage': -120, 'usage_label': 'F'} | {'allowed': 12, 'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F'} | Failed |
SHA-256 / 5da11642623ae0c6a8e4fdd1e1f377eb2b9d3b64c8b4e78707048f23fbde1041
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'][-1:])
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': 301, 'ppv_label': 'U', 'usage': 600, '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': 30, 'ppv': -50, 'ppv_label': 'F', 'usage': 750, 'usage_label': 'U'} | {'allowed': 30, 'ppv': 250, 'ppv_label': 'U', 'usage': 750, 'usage_label': 'U'} | Failed |
| 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': 100, 'ppv_label': 'U', 'usage': -120, 'usage_label': 'F'} | {'allowed': 12, 'ppv': -190, 'ppv_label': 'F', 'usage': -120, 'usage_label': 'F'} | Failed |
SHA-256 / eb1e37e3f1cad8462f362e6b6d321acd33335e2d08ec80b0350cfc470d72781c
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.422153+00:00.
Case digest / d52ce7ee63f00376cafdd01f068ed3dbb9a637ceef4efd92914d7f19ddfc4e80