FA-95551 / Shipping rate zone lookup / Open access
Hundredweight: 200 lb shipment disqualified · case 01
A shipment totalling exactly 200 billed pounds is rated as parcels.
ROOT CAUSE
The minimum weight test excludes 200 lb itself.
VERIFIED REPAIR
Qualify when the rounded total is at least 200 lb.
Unsuccessful approach: Testing the unrounded sum disqualifies shipments that reach 200 lb only after per-piece rounding.
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 = [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 = [[['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['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]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 5', [[1.4, 11], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 13]], ['generated mix 13', [[10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 10]]], [['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]], ['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]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['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 9', [[19.2, 19.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 40]], ['generated mix 17', [[11, 10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 21]]], [['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]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['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]], ['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['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]], ['generated mix 20', [[110.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 111]], ['generated mix 28', [[1.4, 2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 4]]], [['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['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]], ['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]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 31', [[100.5, 99.9], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [201, 11339]], ['generated mix 39', [[40.9, 40.9, 50.5, 40.5, 40.5, 40.5, 40.5, 40.5, 50.5, 40.9, 41.5, 50.5, 40.9, 40.9, 50.5, 40.5, 50.5, 41.5, 40.5, 50.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [882, 60000]]], [['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['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]], ['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 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 49', [[67.3, 67.3], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 136]], ['generated mix 57', [[151, 150, 150.4, 151, 151, 160, 150, 150, 150, 151, 150, 160, 150.4, 150, 160, 151, 150.4, 150.4, 160, 151], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [3050, 210664]]]]
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 |
|---|---|---|---|
| threshold via rounding | ['PARCEL', 200] | [200, 8074] | Failed |
| per piece round | [202, 8155] | [202, 8155] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | ['PARCEL', 200] | [200, 9024] | Failed |
| rounded pieces reach average | [250, 14103] | [250, 14103] | Passed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 5 | ['PARCEL', 13] | ['PARCEL', 13] | Passed |
| generated mix 13 | ['PARCEL', 10] | ['PARCEL', 10] | Passed |
SHA-256 / bba123230ad40bb7479abfee6c0c5b3193f891a02710d374e85420a38410d4d2
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 = [math.ceil(w) for w in pieces]
total = sum(ws)
n = len(ws)
if n < 2 or sum(pieces) < 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 = [[['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['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]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 5', [[1.4, 11], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 13]], ['generated mix 13', [[10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 10]]], [['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]], ['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]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['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 9', [[19.2, 19.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 40]], ['generated mix 17', [[11, 10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 21]]], [['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]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['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]], ['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['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]], ['generated mix 20', [[110.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 111]], ['generated mix 28', [[1.4, 2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 4]]], [['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['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]], ['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]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 31', [[100.5, 99.9], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [201, 11339]], ['generated mix 39', [[40.9, 40.9, 50.5, 40.5, 40.5, 40.5, 40.5, 40.5, 50.5, 40.9, 41.5, 50.5, 40.9, 40.9, 50.5, 40.5, 50.5, 41.5, 40.5, 50.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [882, 60000]]], [['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['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]], ['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 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 49', [[67.3, 67.3], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 136]], ['generated mix 57', [[151, 150, 150.4, 151, 151, 160, 150, 150, 150, 151, 150, 160, 150.4, 150, 160, 151, 150.4, 150.4, 160, 151], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [3050, 210664]]]]
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 |
|---|---|---|---|
| threshold via rounding | ['PARCEL', 200] | [200, 8074] | Failed |
| per piece round | [202, 8155] | [202, 8155] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | [200, 9024] | [200, 9024] | Passed |
| rounded pieces reach average | [250, 14103] | [250, 14103] | Passed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 5 | ['PARCEL', 13] | ['PARCEL', 13] | Passed |
| generated mix 13 | ['PARCEL', 10] | ['PARCEL', 10] | Passed |
SHA-256 / bc41192e5ae385b3a296829e9bf694b88757e828435deb64c9aff047adb4f629
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 = [[['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['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]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 5', [[1.4, 11], 4, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 13]], ['generated mix 13', [[10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 10]]], [['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]], ['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]], ['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['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 9', [[19.2, 19.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 40]], ['generated mix 17', [[11, 10], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 21]]], [['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]], ['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['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]], ['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['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]], ['generated mix 20', [[110.2], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 111]], ['generated mix 28', [[1.4, 2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 4]]], [['minimum charge', [[100, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 5000], [200, 10000]], ['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]], ['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]], ['single piece', [[250], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 250]], ['generated mix 31', [[100.5, 99.9], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [201, 11339]], ['generated mix 39', [[40.9, 40.9, 50.5, 40.5, 40.5, 40.5, 40.5, 40.5, 50.5, 40.9, 41.5, 50.5, 40.9, 40.9, 50.5, 40.5, 50.5, 41.5, 40.5, 50.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [882, 60000]]], [['threshold via rounding', [[99.5, 100], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [200, 8074]], ['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]], ['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 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 49', [[67.3, 67.3], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 136]], ['generated mix 57', [[151, 150, 150.4, 151, 151, 160, 150, 150, 150, 151, 150, 160, 150.4, 150, 160, 151, 150.4, 150.4, 160, 151], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [3050, 210664]]]]
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 |
|---|---|---|---|
| threshold via rounding | [200, 8074] | [200, 8074] | Passed |
| per piece round | [202, 8155] | [202, 8155] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | [200, 9024] | [200, 9024] | Passed |
| rounded pieces reach average | [250, 14103] | [250, 14103] | Passed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 5 | ['PARCEL', 13] | ['PARCEL', 13] | Passed |
| generated mix 13 | ['PARCEL', 10] | ['PARCEL', 10] | Passed |
SHA-256 / eb219ed8fd4e1ba99e5c9de45f7899603af5998e738b6f65c9be8e0185251592
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.786542+00:00.
Case digest / 00fb4941d839bc2926739d67592b411322b7607a78343081950f84773647951d