FAILURE MAP
← Case archive

FA-95701 / Shipping rate zone lookup / Open access

Rate shopping: service rejected at its weight limit · case 01

A parcel weighing exactly a service maximum is not offered that service.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The weight filter is inclusive at max_lb.

VERIFIED REPAIR

Exclude a service only when weight exceeds its maximum.

Unsuccessful approach: Truncating the weight lets 50.5 lb parcels through a 50 lb service.

Case contract

quotes [[carrier, service, price_cents, transit_days, max_lb]]. Eligible when weight <= max_lb, transit <= deadline and the carrier is not excluded (case-insensitive). Choose lowest price, then fewest days, then carrier, then service. Return [carrier, service, price] or None.

Why this case matters

Rate shopping chooses the cheapest eligible carrier service for a delivery promise.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(quotes, weight, deadline, excluded):
    excl = {e.lower() for e in excluded}
    best = None
    for carrier, service, price, days, max_lb in quotes:
        if weight >= max_lb or days > deadline:
            continue
        if carrier.lower() in excl:
            continue
        key = (price, days, carrier, service)
        if best is None or key < best:
            best = key
    return [best[2], best[3], best[0]] if best else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weight at limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 2', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['faster on price tie', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, []], ['USP', 'PRIORITY', 1200]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 7', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]]], [['generated mix 55', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 7, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 17', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['upx', 'FDX']], None], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 8', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['generated mix 16', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['dhl']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 20', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 3, ['dhl']], ['USP', 'PRIORITY', 1200]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['excluded lowercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['excluded mixed case', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 21', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 1, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 29', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 3, ['Usp']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 69', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 7, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]], ['generated mix 16', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['dhl']], ['FDX', 'EXPRESS', 2500]], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['generated mix 31', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 1, ['upx', 'FDX']], None], ['generated mix 39', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 5, []], ['USP', 'PRIORITY', 1200]]], [['generated mix 52', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, ['upx', 'FDX']], ['DHL', 'GROUND', 1100]], ['generated mix 63', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['excluded lowercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['excluded mixed case', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['faster on price tie', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, []], ['USP', 'PRIORITY', 1200]], ['weight at limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 41', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 6, []], ['FDX', 'EXPRESS', 2500]], ['generated mix 49', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['dhl']], None]]]
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 fixtureActualExpectedOutcome
weight at limit['USP', 'PRIORITY', 1200]['DHL', 'GROUND', 1100]Failed
generated mix 2['FDX', 'EXPRESS', 2500]['FDX', 'EXPRESS', 2500]Passed
faster on price tie['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
weight over limit['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
excluded uppercase['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
nothingNoneNonePassed
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 7['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed

SHA-256 / 70155933a959c584a1ae7931078c02a835818e703eb399c418a10d41a615abe9

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(quotes, weight, deadline, excluded):
    excl = {e.lower() for e in excluded}
    best = None
    for carrier, service, price, days, max_lb in quotes:
        if int(weight) > max_lb or days > deadline:
            continue
        if carrier.lower() in excl:
            continue
        key = (price, days, carrier, service)
        if best is None or key < best:
            best = key
    return [best[2], best[3], best[0]] if best else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weight at limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 2', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['faster on price tie', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, []], ['USP', 'PRIORITY', 1200]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 7', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]]], [['generated mix 55', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 7, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 17', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['upx', 'FDX']], None], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 8', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['generated mix 16', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['dhl']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 20', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 3, ['dhl']], ['USP', 'PRIORITY', 1200]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['excluded lowercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['excluded mixed case', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 21', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 1, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 29', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 3, ['Usp']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 69', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 7, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]], ['generated mix 16', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['dhl']], ['FDX', 'EXPRESS', 2500]], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['generated mix 31', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 1, ['upx', 'FDX']], None], ['generated mix 39', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 5, []], ['USP', 'PRIORITY', 1200]]], [['generated mix 52', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, ['upx', 'FDX']], ['DHL', 'GROUND', 1100]], ['generated mix 63', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['excluded lowercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['excluded mixed case', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['faster on price tie', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, []], ['USP', 'PRIORITY', 1200]], ['weight at limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 41', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 6, []], ['FDX', 'EXPRESS', 2500]], ['generated mix 49', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['dhl']], None]]]
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 fixtureActualExpectedOutcome
weight at limit['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 2['UPX', 'GROUND', 1200]['FDX', 'EXPRESS', 2500]Failed
faster on price tie['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
weight over limit['DHL', 'GROUND', 1100]['USP', 'PRIORITY', 1200]Failed
excluded uppercase['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
nothingNoneNonePassed
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 7['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed

SHA-256 / afdcb835e4bd7f728c1e3f8d20b05be6159ba362b95c81519701f4269bc2d17f

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(quotes, weight, deadline, excluded):
    excl = {e.lower() for e in excluded}
    best = None
    for carrier, service, price, days, max_lb in quotes:
        if weight > max_lb or days > deadline:
            continue
        if carrier.lower() in excl:
            continue
        key = (price, days, carrier, service)
        if best is None or key < best:
            best = key
    return [best[2], best[3], best[0]] if best else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weight at limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 2', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['faster on price tie', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, []], ['USP', 'PRIORITY', 1200]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 7', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]]], [['generated mix 55', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 7, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 17', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['upx', 'FDX']], None], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 8', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['generated mix 16', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['dhl']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 20', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 3, ['dhl']], ['USP', 'PRIORITY', 1200]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['excluded lowercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['excluded mixed case', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 21', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 1, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 29', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 3, ['Usp']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 69', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 7, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]], ['generated mix 16', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 7, ['dhl']], ['FDX', 'EXPRESS', 2500]], ['deadline inclusive', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, []], ['DHL', 'GROUND', 1100]], ['weight over limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 6, []], ['USP', 'PRIORITY', 1200]], ['excluded uppercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['DHL']], ['USP', 'PRIORITY', 1200]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['generated mix 31', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 1, ['upx', 'FDX']], None], ['generated mix 39', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 5, []], ['USP', 'PRIORITY', 1200]]], [['generated mix 52', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, ['upx', 'FDX']], ['DHL', 'GROUND', 1100]], ['generated mix 63', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['excluded lowercase', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 6, ['dhl']], ['USP', 'PRIORITY', 1200]], ['excluded mixed case', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['faster on price tie', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, []], ['USP', 'PRIORITY', 1200]], ['weight at limit', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 6, []], ['DHL', 'GROUND', 1100]], ['generated mix 41', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 6, []], ['FDX', 'EXPRESS', 2500]], ['generated mix 49', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['dhl']], None]]]
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 fixtureActualExpectedOutcome
weight at limit['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 2['FDX', 'EXPRESS', 2500]['FDX', 'EXPRESS', 2500]Passed
faster on price tie['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
weight over limit['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
excluded uppercase['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
nothingNoneNonePassed
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 7['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed

SHA-256 / 2e53967ab7321f0d051e1577c252f94c2ca22660b8d4a2a5136c228b9317d9f6

Verification & scope

Stipulated quote list; no service guarantees or surcharges. 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:16.133362+00:00.

Case digest / 695d1f960b697d99ff4c1bb6e15de25efb889c2b4f32ae44d4e31079d2b57263