FA-60021 / Inventory cost layering / Open access
Retail inventory method estimate: ratio rounding stage · case 01
Ending cost drifts by several cents from the exact ratio result.
ROOT CAUSE
Ending cost is computed from the rounded basis-point ratio instead of the exact cost/retail fraction.
VERIFIED REPAIR
Apply the exact fraction and round only the final ending cost.
Unsuccessful approach: Rounding the ratio to whole percent before applying it makes the drift larger, not smaller.
Case contract
Input totals for a period. Cost pool = begin_cost + purch_cost + freight_in - returns_cost. Retail pool = begin_retail + purch_retail - returns_retail + markups - markup_cancel. Net markdowns = markdowns - markdown_cancel. The conventional (LCM) ratio uses the retail pool before markdowns; the cost method ratio deducts net markdowns. Ending retail = retail pool - net markdowns - sales - employee_discounts. Ending cost = round-half-up(ending retail * cost pool / ratio denominator). Return {ratio_bp (rounded half up), ending_retail, ending_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):
cost_pool = x['begin_cost'] + x['purch_cost'] + x['freight_in'] - x['returns_cost']
retail_pool = x['begin_retail'] + x['purch_retail'] - x['returns_retail'] + x['markups'] - x['markup_cancel']
net_md = x['markdowns'] - x['markdown_cancel']
denom = retail_pool if x['method'] == 'conventional' else retail_pool - net_md
ending_retail = retail_pool - net_md - x['sales'] - x['employee_discounts']
ratio_bp = (2 * cost_pool * 10000 + denom) // (2 * denom)
ending_cost = (2 * ending_retail * ratio_bp + 10000) // 20000
return {'ratio_bp': ratio_bp, 'ending_retail': ending_retail, 'ending_cost': ending_cost}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 16490, 'ending_cost': 9670}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6122, 'ending_retail': 16490, 'ending_cost': 10096}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40001, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 21099, 'ending_cost': 12373}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8001, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6107, 'ending_retail': 10089, 'ending_cost': 6161}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5670, 'ending_retail': 17290, 'ending_cost': 9804}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1999, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6216, 'ending_retail': 12991, 'ending_cost': 8075}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3001, 'method': 'cost'}, {'ratio_bp': 6122, 'ending_retail': 14289, 'ending_cost': 8748}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 41400, 'ending_cost': 24278}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 16480, 'ending_cost': 9691}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6140, 'ending_retail': 16480, 'ending_cost': 10119}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40002, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 21098, 'ending_cost': 12407}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8002, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6127, 'ending_retail': 10078, 'ending_cost': 6175}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5687, 'ending_retail': 17280, 'ending_cost': 9826}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1998, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6233, 'ending_retail': 12982, 'ending_cost': 8091}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3002, 'method': 'cost'}, {'ratio_bp': 6140, 'ending_retail': 14278, 'ending_cost': 8767}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 41400, 'ending_cost': 24345}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 16470, 'ending_cost': 9712}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6158, 'ending_retail': 16470, 'ending_cost': 10143}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40003, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 21097, 'ending_cost': 12440}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8003, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6148, 'ending_retail': 10067, 'ending_cost': 6189}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5703, 'ending_retail': 17270, 'ending_cost': 9849}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1997, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6250, 'ending_retail': 12973, 'ending_cost': 8108}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3003, 'method': 'cost'}, {'ratio_bp': 6158, 'ending_retail': 14267, 'ending_cost': 8786}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 41400, 'ending_cost': 24412}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 16460, 'ending_cost': 9732}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6176, 'ending_retail': 16460, 'ending_cost': 10166}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40004, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 21096, 'ending_cost': 12474}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8004, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6168, 'ending_retail': 10056, 'ending_cost': 6202}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5719, 'ending_retail': 17260, 'ending_cost': 9871}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1996, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6267, 'ending_retail': 12964, 'ending_cost': 8124}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3004, 'method': 'cost'}, {'ratio_bp': 6176, 'ending_retail': 14256, 'ending_cost': 8805}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 41400, 'ending_cost': 24479}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 16450, 'ending_cost': 9753}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6194, 'ending_retail': 16450, 'ending_cost': 10189}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40005, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 21095, 'ending_cost': 12507}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8005, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6188, 'ending_retail': 10045, 'ending_cost': 6216}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5735, 'ending_retail': 17250, 'ending_cost': 9893}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1995, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6284, 'ending_retail': 12955, 'ending_cost': 8141}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3005, 'method': 'cost'}, {'ratio_bp': 6194, 'ending_retail': 14245, 'ending_cost': 8823}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20004, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 41396, 'ending_cost': 24543}]]]
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 |
|---|---|---|---|
| conventional | {'ending_cost': 9670, 'ending_retail': 16490, 'ratio_bp': 5864} | {'ending_cost': 9670, 'ending_retail': 16490, 'ratio_bp': 5864} | Passed |
| cost method | {'ending_cost': 10095, 'ending_retail': 16490, 'ratio_bp': 6122} | {'ending_cost': 10096, 'ending_retail': 16490, 'ratio_bp': 6122} | Failed |
| no markdowns | {'ending_cost': 12372, 'ending_retail': 21099, 'ratio_bp': 5864} | {'ending_cost': 12373, 'ending_retail': 21099, 'ratio_bp': 5864} | Failed |
| heavy returns | {'ending_cost': 6161, 'ending_retail': 10089, 'ratio_bp': 6107} | {'ending_cost': 6161, 'ending_retail': 10089, 'ratio_bp': 6107} | Passed |
| no freight | {'ending_cost': 9803, 'ending_retail': 17290, 'ratio_bp': 5670} | {'ending_cost': 9804, 'ending_retail': 17290, 'ratio_bp': 5670} | Failed |
| markup cancel | {'ending_cost': 8075, 'ending_retail': 12991, 'ratio_bp': 6216} | {'ending_cost': 8075, 'ending_retail': 12991, 'ratio_bp': 6216} | Passed |
| discounts heavy | {'ending_cost': 8748, 'ending_retail': 14289, 'ratio_bp': 6122} | {'ending_cost': 8748, 'ending_retail': 14289, 'ratio_bp': 6122} | Passed |
| large ending retail | {'ending_cost': 24277, 'ending_retail': 41400, 'ratio_bp': 5864} | {'ending_cost': 24278, 'ending_retail': 41400, 'ratio_bp': 5864} | Failed |
SHA-256 / d94cc907e25073416695e9d9a38e6e3a85d70d8d1eaeda642e8268e05d238a91
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cost_pool = x['begin_cost'] + x['purch_cost'] + x['freight_in'] - x['returns_cost']
retail_pool = x['begin_retail'] + x['purch_retail'] - x['returns_retail'] + x['markups'] - x['markup_cancel']
net_md = x['markdowns'] - x['markdown_cancel']
denom = retail_pool if x['method'] == 'conventional' else retail_pool - net_md
ending_retail = retail_pool - net_md - x['sales'] - x['employee_discounts']
ratio_bp = (2 * cost_pool * 10000 + denom) // (2 * denom)
ending_cost = (2 * ending_retail * ((ratio_bp + 50) // 100) + 100) // 200
return {'ratio_bp': ratio_bp, 'ending_retail': ending_retail, 'ending_cost': ending_cost}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 16490, 'ending_cost': 9670}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6122, 'ending_retail': 16490, 'ending_cost': 10096}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40001, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 21099, 'ending_cost': 12373}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8001, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6107, 'ending_retail': 10089, 'ending_cost': 6161}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5670, 'ending_retail': 17290, 'ending_cost': 9804}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1999, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6216, 'ending_retail': 12991, 'ending_cost': 8075}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3001, 'method': 'cost'}, {'ratio_bp': 6122, 'ending_retail': 14289, 'ending_cost': 8748}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 41400, 'ending_cost': 24278}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 16480, 'ending_cost': 9691}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6140, 'ending_retail': 16480, 'ending_cost': 10119}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40002, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 21098, 'ending_cost': 12407}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8002, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6127, 'ending_retail': 10078, 'ending_cost': 6175}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5687, 'ending_retail': 17280, 'ending_cost': 9826}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1998, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6233, 'ending_retail': 12982, 'ending_cost': 8091}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3002, 'method': 'cost'}, {'ratio_bp': 6140, 'ending_retail': 14278, 'ending_cost': 8767}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 41400, 'ending_cost': 24345}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 16470, 'ending_cost': 9712}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6158, 'ending_retail': 16470, 'ending_cost': 10143}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40003, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 21097, 'ending_cost': 12440}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8003, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6148, 'ending_retail': 10067, 'ending_cost': 6189}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5703, 'ending_retail': 17270, 'ending_cost': 9849}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1997, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6250, 'ending_retail': 12973, 'ending_cost': 8108}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3003, 'method': 'cost'}, {'ratio_bp': 6158, 'ending_retail': 14267, 'ending_cost': 8786}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 41400, 'ending_cost': 24412}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 16460, 'ending_cost': 9732}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6176, 'ending_retail': 16460, 'ending_cost': 10166}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40004, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 21096, 'ending_cost': 12474}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8004, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6168, 'ending_retail': 10056, 'ending_cost': 6202}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5719, 'ending_retail': 17260, 'ending_cost': 9871}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1996, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6267, 'ending_retail': 12964, 'ending_cost': 8124}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3004, 'method': 'cost'}, {'ratio_bp': 6176, 'ending_retail': 14256, 'ending_cost': 8805}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 41400, 'ending_cost': 24479}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 16450, 'ending_cost': 9753}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6194, 'ending_retail': 16450, 'ending_cost': 10189}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40005, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 21095, 'ending_cost': 12507}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8005, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6188, 'ending_retail': 10045, 'ending_cost': 6216}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5735, 'ending_retail': 17250, 'ending_cost': 9893}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1995, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6284, 'ending_retail': 12955, 'ending_cost': 8141}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3005, 'method': 'cost'}, {'ratio_bp': 6194, 'ending_retail': 14245, 'ending_cost': 8823}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20004, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 41396, 'ending_cost': 24543}]]]
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 |
|---|---|---|---|
| conventional | {'ending_cost': 9729, 'ending_retail': 16490, 'ratio_bp': 5864} | {'ending_cost': 9670, 'ending_retail': 16490, 'ratio_bp': 5864} | Failed |
| cost method | {'ending_cost': 10059, 'ending_retail': 16490, 'ratio_bp': 6122} | {'ending_cost': 10096, 'ending_retail': 16490, 'ratio_bp': 6122} | Failed |
| no markdowns | {'ending_cost': 12448, 'ending_retail': 21099, 'ratio_bp': 5864} | {'ending_cost': 12373, 'ending_retail': 21099, 'ratio_bp': 5864} | Failed |
| heavy returns | {'ending_cost': 6154, 'ending_retail': 10089, 'ratio_bp': 6107} | {'ending_cost': 6161, 'ending_retail': 10089, 'ratio_bp': 6107} | Failed |
| no freight | {'ending_cost': 9855, 'ending_retail': 17290, 'ratio_bp': 5670} | {'ending_cost': 9804, 'ending_retail': 17290, 'ratio_bp': 5670} | Failed |
| markup cancel | {'ending_cost': 8054, 'ending_retail': 12991, 'ratio_bp': 6216} | {'ending_cost': 8075, 'ending_retail': 12991, 'ratio_bp': 6216} | Failed |
| discounts heavy | {'ending_cost': 8716, 'ending_retail': 14289, 'ratio_bp': 6122} | {'ending_cost': 8748, 'ending_retail': 14289, 'ratio_bp': 6122} | Failed |
| large ending retail | {'ending_cost': 24426, 'ending_retail': 41400, 'ratio_bp': 5864} | {'ending_cost': 24278, 'ending_retail': 41400, 'ratio_bp': 5864} | Failed |
SHA-256 / 24577eb7e6f3b599c2ffbef5dbb79a42d29d195687b1679c6392b4cf3863e4b8
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cost_pool = x['begin_cost'] + x['purch_cost'] + x['freight_in'] - x['returns_cost']
retail_pool = x['begin_retail'] + x['purch_retail'] - x['returns_retail'] + x['markups'] - x['markup_cancel']
net_md = x['markdowns'] - x['markdown_cancel']
denom = retail_pool if x['method'] == 'conventional' else retail_pool - net_md
ending_retail = retail_pool - net_md - x['sales'] - x['employee_discounts']
ratio_bp = (2 * cost_pool * 10000 + denom) // (2 * denom)
ending_cost = (2 * ending_retail * cost_pool + denom) // (2 * denom)
return {'ratio_bp': ratio_bp, 'ending_retail': ending_retail, 'ending_cost': ending_cost}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 16490, 'ending_cost': 9670}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6122, 'ending_retail': 16490, 'ending_cost': 10096}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40001, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 21099, 'ending_cost': 12373}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8001, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6107, 'ending_retail': 10089, 'ending_cost': 6161}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5670, 'ending_retail': 17290, 'ending_cost': 9804}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1999, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6216, 'ending_retail': 12991, 'ending_cost': 8075}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3010, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3001, 'method': 'cost'}, {'ratio_bp': 6122, 'ending_retail': 14289, 'ending_cost': 8748}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30100, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5864, 'ending_retail': 41400, 'ending_cost': 24278}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 16480, 'ending_cost': 9691}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6140, 'ending_retail': 16480, 'ending_cost': 10119}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40002, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 21098, 'ending_cost': 12407}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8002, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6127, 'ending_retail': 10078, 'ending_cost': 6175}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5687, 'ending_retail': 17280, 'ending_cost': 9826}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1998, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6233, 'ending_retail': 12982, 'ending_cost': 8091}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3020, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3002, 'method': 'cost'}, {'ratio_bp': 6140, 'ending_retail': 14278, 'ending_cost': 8767}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30200, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5880, 'ending_retail': 41400, 'ending_cost': 24345}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 16470, 'ending_cost': 9712}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6158, 'ending_retail': 16470, 'ending_cost': 10143}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40003, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 21097, 'ending_cost': 12440}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8003, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6148, 'ending_retail': 10067, 'ending_cost': 6189}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5703, 'ending_retail': 17270, 'ending_cost': 9849}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1997, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6250, 'ending_retail': 12973, 'ending_cost': 8108}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3030, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3003, 'method': 'cost'}, {'ratio_bp': 6158, 'ending_retail': 14267, 'ending_cost': 8786}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30300, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5897, 'ending_retail': 41400, 'ending_cost': 24412}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 16460, 'ending_cost': 9732}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6176, 'ending_retail': 16460, 'ending_cost': 10166}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40004, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 21096, 'ending_cost': 12474}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8004, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6168, 'ending_retail': 10056, 'ending_cost': 6202}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5719, 'ending_retail': 17260, 'ending_cost': 9871}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1996, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6267, 'ending_retail': 12964, 'ending_cost': 8124}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3040, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3004, 'method': 'cost'}, {'ratio_bp': 6176, 'ending_retail': 14256, 'ending_cost': 8805}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30400, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5913, 'ending_retail': 41400, 'ending_cost': 24479}]], [['conventional', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 16450, 'ending_cost': 9753}], ['cost method', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6194, 'ending_retail': 16450, 'ending_cost': 10189}], ['no markdowns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 0, 'markdown_cancel': 0, 'sales': 40005, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 21095, 'ending_cost': 12507}], ['heavy returns', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 5000, 'returns_retail': 8005, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'cost'}, {'ratio_bp': 6188, 'ending_retail': 10045, 'ending_cost': 6216}], ['no freight', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 0, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 0, 'method': 'conventional'}, {'ratio_bp': 5735, 'ending_retail': 17250, 'ending_cost': 9893}], ['markup cancel', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 2000, 'markup_cancel': 1995, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 6284, 'ending_retail': 12955, 'ending_cost': 8141}], ['discounts heavy', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 3050, 'markdown_cancel': 400, 'sales': 42000, 'employee_discounts': 3005, 'method': 'cost'}, {'ratio_bp': 6194, 'ending_retail': 14245, 'ending_cost': 8823}], ['large ending retail', {'begin_cost': 6000, 'begin_retail': 10000, 'purch_cost': 30500, 'purch_retail': 50000, 'freight_in': 1200, 'returns_cost': 1000, 'returns_retail': 1600, 'markups': 4000, 'markup_cancel': 500, 'markdowns': 100, 'markdown_cancel': 400, 'sales': 20004, 'employee_discounts': 800, 'method': 'conventional'}, {'ratio_bp': 5929, 'ending_retail': 41396, 'ending_cost': 24543}]]]
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 |
|---|---|---|---|
| conventional | {'ending_cost': 9670, 'ending_retail': 16490, 'ratio_bp': 5864} | {'ending_cost': 9670, 'ending_retail': 16490, 'ratio_bp': 5864} | Passed |
| cost method | {'ending_cost': 10096, 'ending_retail': 16490, 'ratio_bp': 6122} | {'ending_cost': 10096, 'ending_retail': 16490, 'ratio_bp': 6122} | Passed |
| no markdowns | {'ending_cost': 12373, 'ending_retail': 21099, 'ratio_bp': 5864} | {'ending_cost': 12373, 'ending_retail': 21099, 'ratio_bp': 5864} | Passed |
| heavy returns | {'ending_cost': 6161, 'ending_retail': 10089, 'ratio_bp': 6107} | {'ending_cost': 6161, 'ending_retail': 10089, 'ratio_bp': 6107} | Passed |
| no freight | {'ending_cost': 9804, 'ending_retail': 17290, 'ratio_bp': 5670} | {'ending_cost': 9804, 'ending_retail': 17290, 'ratio_bp': 5670} | Passed |
| markup cancel | {'ending_cost': 8075, 'ending_retail': 12991, 'ratio_bp': 6216} | {'ending_cost': 8075, 'ending_retail': 12991, 'ratio_bp': 6216} | Passed |
| discounts heavy | {'ending_cost': 8748, 'ending_retail': 14289, 'ratio_bp': 6122} | {'ending_cost': 8748, 'ending_retail': 14289, 'ratio_bp': 6122} | Passed |
| large ending retail | {'ending_cost': 24278, 'ending_retail': 41400, 'ratio_bp': 5864} | {'ending_cost': 24278, 'ending_retail': 41400, 'ratio_bp': 5864} | Passed |
SHA-256 / 270464d38b3421c656d2694d7112a5cdc7d4b8dc2b14425a651ccc86ebd8a729
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:41.751339+00:00.
Case digest / 8c19c03d999e920968c99507722619d79d8c7fdab4819f6aa3e45a49809c5a44