FA-95641 / Shipping rate zone lookup / Open access
Flat vs weight: fractional pound uses lower rate · case 01
A 3.2 lb parcel is priced at the 3 lb rate; sub-pound parcels wrap to the heaviest rate.
ROOT CAUSE
The rate index truncates weight instead of using the rounded-up billable pound.
VERIFIED REPAIR
Index the table with ceil(weight) - 1.
Unsuccessful approach: Clamping the truncated index fixes sub-pound wraparound but still underprices fractional pounds.
Case contract
boxes [[name, L, W, H, price]] inner dims; an item fits a flat box in any orientation and flat boxes accept up to 70 lb. Weight price = weight_rates[lb-1] with lb = ceil(weight) (min 1) when lb is within the table. Choose the cheapest option; on equal price prefer flat boxes, then name. Return [option, price] or ["NONE", 0].
Why this case matters
Shippers compare flat-rate packaging with zone weight pricing.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(dims, weight, boxes, weight_rates):
need = sorted(dims)
opts = []
for name, L, W, H, price in boxes:
if weight <= 70 and all(a <= b for a, b in zip(need, sorted([L, W, H]))):
opts.append((price, 0, name))
lb = max(1, math.ceil(weight))
if lb <= len(weight_rates):
opts.append((weight_rates[int(weight) - 1], 1, 'WEIGHT'))
if not opts:
return ['NONE', 0]
p, _, name = min(opts)
return [name, p]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['generated mix 8', [[2, 10, 11], 0.5, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]]], [['generated mix 23', [[2, 12, 1], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 31', [[5, 4, 7], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['generated mix 9', [[5, 4, 11], 9.1, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['generated mix 17', [[4, 5, 10], 0.5, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]]], [['generated mix 43', [[11, 10, 8], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 45', [[10, 4, 2], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 20', [[8, 7, 10], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['generated mix 28', [[12, 10, 5], 70.4, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]]], [['generated mix 58', [[7, 8, 5], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 72', [[5, 10, 7], 3.2, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['generated mix 31', [[5, 4, 7], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 39', [[10, 1, 11], 10, [['LARGE', 12, 12, 6, 2395], ['MEDIUM', 11, 8, 5, 1740], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['LARGE', 2395]]], [['generated mix 75', [[7, 5, 7], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 1', [[5, 7, 12], 5.5, [['LARGE', 12, 12, 6, 2395], ['MEDIUM', 11, 8, 5, 1740], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 2200]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['generated mix 43', [[11, 10, 8], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 51', [[2, 11, 11], 12, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['LARGE', 2395]]]]
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 |
|---|---|---|---|
| tie prefers flat | ['WEIGHT', 1900] | ['PADDED', 2200] | Failed |
| fraction rounds up | ['WEIGHT', 1350] | ['WEIGHT', 1600] | Failed |
| weight cheaper | ['WEIGHT', 900] | ['WEIGHT', 900] | Passed |
| 70 lb flat only | ['SMALL', 1045] | ['SMALL', 1045] | Passed |
| expensive box listed first | ['SMALL', 1045] | ['SMALL', 1045] | Passed |
| flat cheaper | ['MEDIUM', 1740] | ['MEDIUM', 1740] | Passed |
| over 70 | ['NONE', 0] | ['NONE', 0] | Passed |
| generated mix 8 | ['LARGE', 2395] | ['WEIGHT', 900] | Failed |
SHA-256 / 9ed7954022a2ad922b5d95f6c97ace51c4bf1fc14ece3f4e16f3b94c33ed15a2
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(dims, weight, boxes, weight_rates):
need = sorted(dims)
opts = []
for name, L, W, H, price in boxes:
if weight <= 70 and all(a <= b for a, b in zip(need, sorted([L, W, H]))):
opts.append((price, 0, name))
lb = max(1, math.ceil(weight))
if lb <= len(weight_rates):
opts.append((weight_rates[max(0, int(weight) - 1)], 1, 'WEIGHT'))
if not opts:
return ['NONE', 0]
p, _, name = min(opts)
return [name, p]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['generated mix 8', [[2, 10, 11], 0.5, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]]], [['generated mix 23', [[2, 12, 1], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 31', [[5, 4, 7], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['generated mix 9', [[5, 4, 11], 9.1, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['generated mix 17', [[4, 5, 10], 0.5, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]]], [['generated mix 43', [[11, 10, 8], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 45', [[10, 4, 2], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 20', [[8, 7, 10], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['generated mix 28', [[12, 10, 5], 70.4, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]]], [['generated mix 58', [[7, 8, 5], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 72', [[5, 10, 7], 3.2, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['generated mix 31', [[5, 4, 7], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 39', [[10, 1, 11], 10, [['LARGE', 12, 12, 6, 2395], ['MEDIUM', 11, 8, 5, 1740], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['LARGE', 2395]]], [['generated mix 75', [[7, 5, 7], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 1', [[5, 7, 12], 5.5, [['LARGE', 12, 12, 6, 2395], ['MEDIUM', 11, 8, 5, 1740], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 2200]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['generated mix 43', [[11, 10, 8], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 51', [[2, 11, 11], 12, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['LARGE', 2395]]]]
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 |
|---|---|---|---|
| tie prefers flat | ['WEIGHT', 1900] | ['PADDED', 2200] | Failed |
| fraction rounds up | ['WEIGHT', 1350] | ['WEIGHT', 1600] | Failed |
| weight cheaper | ['WEIGHT', 900] | ['WEIGHT', 900] | Passed |
| 70 lb flat only | ['SMALL', 1045] | ['SMALL', 1045] | Passed |
| expensive box listed first | ['SMALL', 1045] | ['SMALL', 1045] | Passed |
| flat cheaper | ['MEDIUM', 1740] | ['MEDIUM', 1740] | Passed |
| over 70 | ['NONE', 0] | ['NONE', 0] | Passed |
| generated mix 8 | ['WEIGHT', 900] | ['WEIGHT', 900] | Passed |
SHA-256 / 052b0a1994f051870515124a742a4fcf94fd9d98ad8a8e346ef96011ab988231
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(dims, weight, boxes, weight_rates):
need = sorted(dims)
opts = []
for name, L, W, H, price in boxes:
if weight <= 70 and all(a <= b for a, b in zip(need, sorted([L, W, H]))):
opts.append((price, 0, name))
lb = max(1, math.ceil(weight))
if lb <= len(weight_rates):
opts.append((weight_rates[lb - 1], 1, 'WEIGHT'))
if not opts:
return ['NONE', 0]
p, _, name = min(opts)
return [name, p]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['generated mix 8', [[2, 10, 11], 0.5, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]]], [['generated mix 23', [[2, 12, 1], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 31', [[5, 4, 7], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['generated mix 9', [[5, 4, 11], 9.1, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['generated mix 17', [[4, 5, 10], 0.5, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]]], [['generated mix 43', [[11, 10, 8], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 45', [[10, 4, 2], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['over 70', [[1, 1, 1], 70.5, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 20', [[8, 7, 10], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]], ['generated mix 28', [[12, 10, 5], 70.4, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['NONE', 0]]], [['generated mix 58', [[7, 8, 5], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 72', [[5, 10, 7], 3.2, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['expensive box listed first', [[1, 1, 1], 30, [['LARGE', 12, 12, 6, 2395], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['flat cheaper', [[4, 10, 7], 6, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['MEDIUM', 1740]], ['generated mix 31', [[5, 4, 7], 3.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['generated mix 39', [[10, 1, 11], 10, [['LARGE', 12, 12, 6, 2395], ['MEDIUM', 11, 8, 5, 1740], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['LARGE', 2395]]], [['generated mix 75', [[7, 5, 7], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 1', [[5, 7, 12], 5.5, [['LARGE', 12, 12, 6, 2395], ['MEDIUM', 11, 8, 5, 1740], ['SMALL', 8, 5, 2, 1045]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 2200]], ['fraction rounds up', [[11, 8, 5], 3.2, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1600]], ['weight cheaper', [[2, 8, 5], 1, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 900]], ['70 lb flat only', [[1, 1, 1], 70, [['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['SMALL', 1045]], ['tie prefers flat', [[1, 1, 1], 5.5, [['PADDED', 12, 9, 1, 2200]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['PADDED', 2200]], ['generated mix 43', [[11, 10, 8], 1.2, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['WEIGHT', 1100]], ['generated mix 51', [[2, 11, 11], 12, [['PADDED', 12, 9, 1, 2200], ['SMALL', 8, 5, 2, 1045], ['MEDIUM', 11, 8, 5, 1740], ['LARGE', 12, 12, 6, 2395]], [900, 1100, 1350, 1600, 1900, 2200, 2500, 2800, 3100, 3400]], ['LARGE', 2395]]]]
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 |
|---|---|---|---|
| tie prefers flat | ['PADDED', 2200] | ['PADDED', 2200] | Passed |
| fraction rounds up | ['WEIGHT', 1600] | ['WEIGHT', 1600] | Passed |
| weight cheaper | ['WEIGHT', 900] | ['WEIGHT', 900] | Passed |
| 70 lb flat only | ['SMALL', 1045] | ['SMALL', 1045] | Passed |
| expensive box listed first | ['SMALL', 1045] | ['SMALL', 1045] | Passed |
| flat cheaper | ['MEDIUM', 1740] | ['MEDIUM', 1740] | Passed |
| over 70 | ['NONE', 0] | ['NONE', 0] | Passed |
| generated mix 8 | ['WEIGHT', 900] | ['WEIGHT', 900] | Passed |
SHA-256 / 92ee354208a8e923a00d7a3b1b4ecb3ec5ff60ccac9858f8b8549b1eebf9754d
Verification & scope
Single zone weight table; stipulated flat box catalogue. 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:52:15.544912+00:00.
Case digest / e3e1917c3285dc6868e7bb4c3cf1e18807358eef47e34a85120eb00f18b95731