FAILURE MAP
← Case archive

FA-95711 / Shipping rate zone lookup / Open access

Rate shopping: slower service wins price tie · case 01

Between equally priced services, the slower one is chosen.

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

ROOT CAUSE

The transit tie-break is negated.

VERIFIED REPAIR

Break price ties by fewest transit days.

Unsuccessful approach: Ignoring transit falls back to carrier name ordering.

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 = [[['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]], ['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]], ['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 6', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 5, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 14', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 5, ['DHL']], ['USP', 'PRIORITY', 1200]]], [['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 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]], ['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 10', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['Usp']], None], ['generated mix 18', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 5, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]]], [['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 19', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['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]], ['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]], ['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]], ['generated mix 28', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 1, ['DHL']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 71', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 47', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 5, ['DHL']], ['USP', 'PRIORITY', 1200]], ['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 30', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 5, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]], ['generated mix 38', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 6, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]]], [['generated mix 4', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 5, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 71', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['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 42', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 50', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['DHL']], ['FDX', 'EXPRESS', 2500]]]]
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
faster on price tie['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed
weight over limit['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
excluded lowercase['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed
excluded mixed case['UPX', 'GROUND', 1200]['UPX', 'GROUND', 1200]Passed
weight at limit['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 6['FDX', 'EXPRESS', 2500]['FDX', 'EXPRESS', 2500]Passed
generated mix 14['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed

SHA-256 / 2f79700fb2f973ba9455f45f3e48e4e27ce89322fd4f59611eccfac2b1fe5644

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 weight > max_lb or days > deadline:
            continue
        if carrier.lower() in excl:
            continue
        key = (price, 0, 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 = [[['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]], ['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]], ['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 6', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 5, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 14', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 5, ['DHL']], ['USP', 'PRIORITY', 1200]]], [['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 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]], ['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 10', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['Usp']], None], ['generated mix 18', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 5, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]]], [['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 19', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['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]], ['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]], ['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]], ['generated mix 28', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 1, ['DHL']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 71', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 47', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 5, ['DHL']], ['USP', 'PRIORITY', 1200]], ['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 30', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 5, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]], ['generated mix 38', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 6, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]]], [['generated mix 4', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 5, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 71', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['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 42', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 50', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['DHL']], ['FDX', 'EXPRESS', 2500]]]]
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
faster on price tie['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed
weight over limit['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
excluded lowercase['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed
excluded mixed case['UPX', 'GROUND', 1200]['UPX', 'GROUND', 1200]Passed
weight at limit['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 6['FDX', 'EXPRESS', 2500]['FDX', 'EXPRESS', 2500]Passed
generated mix 14['UPX', 'GROUND', 1200]['USP', 'PRIORITY', 1200]Failed

SHA-256 / 3c1c31eab77b5b435e531bae028b4c2e47ad5b4bed1be521cf3f4c609cc4694c

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 = [[['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]], ['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]], ['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 6', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 5, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 14', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 5, ['DHL']], ['USP', 'PRIORITY', 1200]]], [['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 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]], ['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 10', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['Usp']], None], ['generated mix 18', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 5, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]]], [['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 19', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 5, ['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]], ['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]], ['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]], ['generated mix 28', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 1, ['DHL']], ['FDX', 'EXPRESS', 2500]]], [['generated mix 71', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 47', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 5, ['DHL']], ['USP', 'PRIORITY', 1200]], ['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 30', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 5, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]], ['generated mix 38', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 6, ['upx', 'FDX']], ['USP', 'PRIORITY', 1200]]], [['generated mix 4', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 5, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 71', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['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 42', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50.5, 7, ['DHL']], ['USP', 'PRIORITY', 1200]], ['generated mix 50', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 6, ['DHL']], ['FDX', 'EXPRESS', 2500]]]]
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
faster on price tie['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
weight over limit['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
excluded lowercase['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
excluded mixed case['UPX', 'GROUND', 1200]['UPX', 'GROUND', 1200]Passed
weight at limit['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
generated mix 6['FDX', 'EXPRESS', 2500]['FDX', 'EXPRESS', 2500]Passed
generated mix 14['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed

SHA-256 / 4c2a900b069a4ebbbe196ee5103593d85d642d45e6f4c5a58d9758018583184e

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.172883+00:00.

Case digest / f1b85886a6c15e515fcb7bd456e9035701e2e3e3405a09cf03f0c715b9c52cc3