FA-95546 / Shipping rate zone lookup / Open access
Hundredweight: weight rounded at shipment level · case 01
Multi-piece shipments are under-billed because fractional pounds are pooled before rounding.
ROOT CAUSE
Rounding up is applied to the summed weight instead of to each piece.
VERIFIED REPAIR
Round every piece up to a whole pound, then sum.
Unsuccessful approach: Rounding pieces to nearest drops fractions below one half.
Case contract
pieces lb; each piece rounds up to a whole lb and the shipment total is their sum. Qualifies when there are at least 2 pieces, total >= 200 lb and average piece weight >= 10 lb (total >= 10*n); otherwise ["PARCEL", total]. Charge = ceil(total * cents per cwt / 100) for zone (rates list zones 2-8), at least min_piece * pieces. Return [total, charge].
Why this case matters
Hundredweight programs price qualifying multi-piece shipments by aggregate weight.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pieces, zone, rates, min_piece):
ws = list(pieces)
total = math.ceil(sum(ws))
n = len(ws)
if n < 2 or total < 200 or total < 10 * n:
return ['PARCEL', total]
rate = rates[zone - 2]
charge = -(-total * rate // 100)
return [total, max(charge, min_piece * n)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['two exact', [[100, 100], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 15110]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 6', [[10, 10.4, 10.4], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 32]]], [['generated mix 9', [[19.2, 19.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 40]], ['generated mix 5', [[1.4, 11], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 13]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 8', [[11, 10.4], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 22]], ['generated mix 17', [[11, 10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 21]]], [['generated mix 25', [[10.2, 9.6], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 21]], ['generated mix 10', [[9.2, 9.6], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 20]], ['many one pound pieces', [[120, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], ['PARCEL', 210]], ['two exact', [[100, 100], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 15110]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['generated mix 19', [[66.7, 66.3], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 134]], ['generated mix 28', [[1.4, 2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 4]]], [['generated mix 40', [[66.7, 76.3], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 144]], ['generated mix 18', [[20, 11, 10, 10.4, 10, 10, 10, 10, 10.4, 10, 20, 11, 10, 11, 20, 10, 11, 10.4, 10.4, 10.4, 10, 20, 11, 10, 20], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [310, 37500]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['many one pound pieces', [[120, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], ['PARCEL', 210]], ['generated mix 30', [[40.5, 40.5, 40.5, 40.9, 50.5, 50.5, 40.5, 40.9, 40.9, 40.5, 41.5, 40.9, 40.9, 41.5, 50.5, 50.5, 40.5, 40.9, 50.5, 50.5], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [882, 39796]], ['generated mix 38', [[10.4, 10, 10, 20, 11, 11, 10, 10, 11, 10.4, 20, 20, 11, 11, 11, 10, 20, 10, 10.4, 11], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [250, 30000]]], [['generated mix 47', [[66.7, 76.3, 66.3, 67.3, 66.7], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [346, 21515]], ['generated mix 25', [[10.2, 9.6], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 21]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 41', [[50.5, 50.5, 41.5, 40.9, 50.5, 50.5, 40.9, 40.9, 41.5, 50.5, 50.5, 50.5, 50.5, 40.5, 40.9, 40.9, 50.5, 40.9, 40.5, 41.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [913, 51503]], ['generated mix 50', [[150, 150], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [300, 13536]]]]
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 |
|---|---|---|---|
| per piece round | [201, 8115] | [202, 8155] | Failed |
| rounded pieces reach average | ['PARCEL', 230] | [250, 14103] | Failed |
| threshold via rounding | [200, 8074] | [200, 8074] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | [200, 9024] | [200, 9024] | Passed |
| two exact | [200, 15110] | [200, 15110] | Passed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 6 | ['PARCEL', 31] | ['PARCEL', 32] | Failed |
SHA-256 / e2b4bee488e95faf892a43859e713035e724c712995b7f20ed75310d93d25495
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pieces, zone, rates, min_piece):
ws = [round(w) for w in pieces]
total = sum(ws)
n = len(ws)
if n < 2 or total < 200 or total < 10 * n:
return ['PARCEL', total]
rate = rates[zone - 2]
charge = -(-total * rate // 100)
return [total, max(charge, min_piece * n)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['two exact', [[100, 100], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 15110]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 6', [[10, 10.4, 10.4], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 32]]], [['generated mix 9', [[19.2, 19.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 40]], ['generated mix 5', [[1.4, 11], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 13]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 8', [[11, 10.4], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 22]], ['generated mix 17', [[11, 10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 21]]], [['generated mix 25', [[10.2, 9.6], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 21]], ['generated mix 10', [[9.2, 9.6], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 20]], ['many one pound pieces', [[120, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], ['PARCEL', 210]], ['two exact', [[100, 100], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 15110]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['generated mix 19', [[66.7, 66.3], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 134]], ['generated mix 28', [[1.4, 2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 4]]], [['generated mix 40', [[66.7, 76.3], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 144]], ['generated mix 18', [[20, 11, 10, 10.4, 10, 10, 10, 10, 10.4, 10, 20, 11, 10, 11, 20, 10, 11, 10.4, 10.4, 10.4, 10, 20, 11, 10, 20], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [310, 37500]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['many one pound pieces', [[120, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], ['PARCEL', 210]], ['generated mix 30', [[40.5, 40.5, 40.5, 40.9, 50.5, 50.5, 40.5, 40.9, 40.9, 40.5, 41.5, 40.9, 40.9, 41.5, 50.5, 50.5, 40.5, 40.9, 50.5, 50.5], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [882, 39796]], ['generated mix 38', [[10.4, 10, 10, 20, 11, 11, 10, 10, 11, 10.4, 20, 20, 11, 11, 11, 10, 20, 10, 10.4, 11], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [250, 30000]]], [['generated mix 47', [[66.7, 76.3, 66.3, 67.3, 66.7], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [346, 21515]], ['generated mix 25', [[10.2, 9.6], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 21]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 41', [[50.5, 50.5, 41.5, 40.9, 50.5, 50.5, 40.9, 40.9, 41.5, 50.5, 50.5, 50.5, 50.5, 40.5, 40.9, 40.9, 50.5, 40.9, 40.5, 41.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [913, 51503]], ['generated mix 50', [[150, 150], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [300, 13536]]]]
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 |
|---|---|---|---|
| per piece round | [200, 8074] | [202, 8155] | Failed |
| rounded pieces reach average | ['PARCEL', 225] | [250, 14103] | Failed |
| threshold via rounding | [200, 8074] | [200, 8074] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | [200, 9024] | [200, 9024] | Passed |
| two exact | [200, 15110] | [200, 15110] | Passed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 6 | ['PARCEL', 30] | ['PARCEL', 32] | Failed |
SHA-256 / 4ab08190212730ea0277ee3ecd2f4b57e3528bb0ff8caac3ec33d794213a4e08
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(pieces, zone, rates, min_piece):
ws = [math.ceil(w) for w in pieces]
total = sum(ws)
n = len(ws)
if n < 2 or total < 200 or total < 10 * n:
return ['PARCEL', total]
rate = rates[zone - 2]
charge = -(-total * rate // 100)
return [total, max(charge, min_piece * n)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['two exact', [[100, 100], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 15110]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 6', [[10, 10.4, 10.4], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 32]]], [['generated mix 9', [[19.2, 19.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 40]], ['generated mix 5', [[1.4, 11], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 13]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 8', [[11, 10.4], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 22]], ['generated mix 17', [[11, 10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 21]]], [['generated mix 25', [[10.2, 9.6], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 21]], ['generated mix 10', [[9.2, 9.6], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 20]], ['many one pound pieces', [[120, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], ['PARCEL', 210]], ['two exact', [[100, 100], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 15110]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['generated mix 19', [[66.7, 66.3], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 134]], ['generated mix 28', [[1.4, 2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 4]]], [['generated mix 40', [[66.7, 76.3], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 144]], ['generated mix 18', [[20, 11, 10, 10.4, 10, 10, 10, 10, 10.4, 10, 20, 11, 10, 11, 20, 10, 11, 10.4, 10.4, 10.4, 10, 20, 11, 10, 20], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [310, 37500]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['many one pound pieces', [[120, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], ['PARCEL', 210]], ['generated mix 30', [[40.5, 40.5, 40.5, 40.9, 50.5, 50.5, 40.5, 40.9, 40.9, 40.5, 41.5, 40.9, 40.9, 41.5, 50.5, 50.5, 40.5, 40.9, 50.5, 50.5], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [882, 39796]], ['generated mix 38', [[10.4, 10, 10, 20, 11, 11, 10, 10, 11, 10.4, 20, 20, 11, 11, 11, 10, 20, 10, 10.4, 11], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [250, 30000]]], [['generated mix 47', [[66.7, 76.3, 66.3, 67.3, 66.7], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [346, 21515]], ['generated mix 25', [[10.2, 9.6], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 21]], ['light average', [[150, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 200]], ['average exactly 10', [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [200, 9024]], ['rounded pieces reach average', [[9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2, 9.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 100], [250, 14103]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 41', [[50.5, 50.5, 41.5, 40.9, 50.5, 50.5, 40.9, 40.9, 41.5, 50.5, 50.5, 50.5, 50.5, 40.5, 40.9, 40.9, 50.5, 40.9, 40.5, 41.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [913, 51503]], ['generated mix 50', [[150, 150], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [300, 13536]]]]
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 |
|---|---|---|---|
| per piece round | [202, 8155] | [202, 8155] | Passed |
| rounded pieces reach average | [250, 14103] | [250, 14103] | Passed |
| threshold via rounding | [200, 8074] | [200, 8074] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | [200, 9024] | [200, 9024] | Passed |
| two exact | [200, 15110] | [200, 15110] | Passed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 6 | ['PARCEL', 32] | ['PARCEL', 32] | Passed |
SHA-256 / ee7ab2ac6f1f6a04cff6fe7cc6b286286818024c40eae485844d2a4da0ae80fc
Verification & scope
Stipulated qualification and rate rules. 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:14.618546+00:00.
Case digest / eaceb7ee7f0ca9d6dd4a66819de94cfee006d7b524dda0fce4e867874e7268e0