FA-95566 / Shipping rate zone lookup / Open access
Hundredweight: charge cents truncated · case 01
Hundredweight charges come out a cent low on fractional results.
ROOT CAUSE
The cwt charge is floored instead of rounded up.
VERIFIED REPAIR
Round the charge up to the next cent.
Unsuccessful approach: Rounding to nearest still drops fractions below one half cent.
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 = [[['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 3', [[101.2, 101.2, 100.2, 100.2, 110.2], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [517, 32148]], ['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]], ['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 6', [[10, 10.4, 10.4], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 32]]], [['generated mix 31', [[100.5, 99.9], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [201, 11339]], ['generated mix 43', [[99.5, 99.5, 100.5, 99.9, 109.5], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [511, 23057]], ['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 7', [[40.5, 50.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 92]], ['generated mix 15', [[40.5, 40.5], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 82]]], [['generated mix 51', [[66.3, 66.7, 66.3, 66.7, 67.3, 66.7, 76.3, 67.3, 67.3, 76.3, 66.3, 67.3, 66.7, 66.3, 67.3, 76.3, 66.7, 67.3, 67.3, 66.3, 76.3, 66.3, 66.3, 76.3, 67.3], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [1733, 119699]], ['generated mix 53', [[150, 151], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [301, 20791]], ['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 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]], ['generated mix 26', [[20], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 20]]], [['generated mix 64', [[41.5, 40.9, 50.5, 40.9, 40.9], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], [216, 9746]], ['generated mix 76', [[150.4, 150, 151, 151, 150.4, 160, 150, 160, 150.4, 151, 150, 160, 150, 150.4, 150, 150, 160, 150, 150, 160], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], [3057, 172446]], ['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 29', [[151], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 151]], ['generated mix 37', [[1.4, 11, 11], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 24]]], [['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 4', [[100.2, 101.2, 100.60000000000001, 100.2, 100.60000000000001, 110.2, 110.2, 100.2, 100.2, 100.60000000000001, 101.2, 100.60000000000001, 110.2, 100.60000000000001, 101.2, 101.2, 100.2, 110.2, 110.2, 100.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [2074, 143252]], ['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]], ['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 42', [[76.3, 76.3, 66.3], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [221, 18000]], ['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, 8154] | [202, 8155] | Failed |
| generated mix 3 | [517, 32147] | [517, 32148] | Failed |
| threshold via rounding | [200, 8074] | [200, 8074] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | [200, 9024] | [200, 9024] | Passed |
| rounded pieces reach average | [250, 14102] | [250, 14103] | Failed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 6 | ['PARCEL', 32] | ['PARCEL', 32] | Passed |
SHA-256 / 7408a089fdf4aacdc46f453f2650f2bc6baa99207d383299921b821896b74231
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 total < 200 or total < 10 * n:
return ['PARCEL', total]
rate = rates[zone - 2]
charge = round(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]], ['generated mix 3', [[101.2, 101.2, 100.2, 100.2, 110.2], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [517, 32148]], ['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]], ['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 6', [[10, 10.4, 10.4], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 32]]], [['generated mix 31', [[100.5, 99.9], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [201, 11339]], ['generated mix 43', [[99.5, 99.5, 100.5, 99.9, 109.5], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [511, 23057]], ['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 7', [[40.5, 50.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 92]], ['generated mix 15', [[40.5, 40.5], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 82]]], [['generated mix 51', [[66.3, 66.7, 66.3, 66.7, 67.3, 66.7, 76.3, 67.3, 67.3, 76.3, 66.3, 67.3, 66.7, 66.3, 67.3, 76.3, 66.7, 67.3, 67.3, 66.3, 76.3, 66.3, 66.3, 76.3, 67.3], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [1733, 119699]], ['generated mix 53', [[150, 151], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [301, 20791]], ['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 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]], ['generated mix 26', [[20], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 20]]], [['generated mix 64', [[41.5, 40.9, 50.5, 40.9, 40.9], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], [216, 9746]], ['generated mix 76', [[150.4, 150, 151, 151, 150.4, 160, 150, 160, 150.4, 151, 150, 160, 150, 150.4, 150, 150, 160, 150, 150, 160], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], [3057, 172446]], ['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 29', [[151], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 151]], ['generated mix 37', [[1.4, 11, 11], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 24]]], [['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 4', [[100.2, 101.2, 100.60000000000001, 100.2, 100.60000000000001, 110.2, 110.2, 100.2, 100.2, 100.60000000000001, 101.2, 100.60000000000001, 110.2, 100.60000000000001, 101.2, 101.2, 100.2, 110.2, 110.2, 100.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [2074, 143252]], ['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]], ['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 42', [[76.3, 76.3, 66.3], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [221, 18000]], ['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 |
| generated mix 3 | [517, 32147] | [517, 32148] | Failed |
| threshold via rounding | [200, 8074] | [200, 8074] | Passed |
| light average | ['PARCEL', 200] | ['PARCEL', 200] | Passed |
| average exactly 10 | [200, 9024] | [200, 9024] | Passed |
| rounded pieces reach average | [250, 14102] | [250, 14103] | Failed |
| single piece | ['PARCEL', 250] | ['PARCEL', 250] | Passed |
| generated mix 6 | ['PARCEL', 32] | ['PARCEL', 32] | Passed |
SHA-256 / d5b664ae81e3b12d9a4a72176805bab10f6aeb7b1b3be73acbf7cd01bbdc0d2b
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]], ['generated mix 3', [[101.2, 101.2, 100.2, 100.2, 110.2], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [517, 32148]], ['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]], ['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 6', [[10, 10.4, 10.4], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], ['PARCEL', 32]]], [['generated mix 31', [[100.5, 99.9], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [201, 11339]], ['generated mix 43', [[99.5, 99.5, 100.5, 99.9, 109.5], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [511, 23057]], ['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 7', [[40.5, 50.5], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], ['PARCEL', 92]], ['generated mix 15', [[40.5, 40.5], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 82]]], [['generated mix 51', [[66.3, 66.7, 66.3, 66.7, 67.3, 66.7, 76.3, 67.3, 67.3, 76.3, 66.3, 67.3, 66.7, 66.3, 67.3, 76.3, 66.7, 67.3, 67.3, 66.3, 76.3, 66.3, 66.3, 76.3, 67.3], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 3000], [1733, 119699]], ['generated mix 53', [[150, 151], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [301, 20791]], ['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 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]], ['generated mix 26', [[20], 8, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 20]]], [['generated mix 64', [[41.5, 40.9, 50.5, 40.9, 40.9], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], [216, 9746]], ['generated mix 76', [[150.4, 150, 151, 151, 150.4, 160, 150, 160, 150.4, 151, 150, 160, 150, 150.4, 150, 150, 160, 150, 150, 160], 5, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 500], [3057, 172446]], ['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 29', [[151], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], ['PARCEL', 151]], ['generated mix 37', [[1.4, 11, 11], 6, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], ['PARCEL', 24]]], [['per piece round', [[100.2, 100.2], 2, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 1500], [202, 8155]], ['generated mix 4', [[100.2, 101.2, 100.60000000000001, 100.2, 100.60000000000001, 110.2, 110.2, 100.2, 100.2, 100.60000000000001, 101.2, 100.60000000000001, 110.2, 100.60000000000001, 101.2, 101.2, 100.2, 110.2, 110.2, 100.2], 7, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [2074, 143252]], ['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]], ['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 42', [[76.3, 76.3, 66.3], 3, [4037, 4512, 5093, 5641, 6218, 6907, 7555], 6000], [221, 18000]], ['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 |
| generated mix 3 | [517, 32148] | [517, 32148] | Passed |
| threshold via rounding | [200, 8074] | [200, 8074] | 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 6 | ['PARCEL', 32] | ['PARCEL', 32] | Passed |
SHA-256 / 636380edc7658b2134ca04924bcc6b60f5c74c4726fe3861cc9fdb0bc38681aa
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.913741+00:00.
Case digest / 27ed43373a5a6c01f18786cd448097680166127109200bab3260c4ba0361f57f