FAILURE MAP
← Case archive

FA-95696 / Shipping rate zone lookup / Open access

Rate shopping: service arriving on deadline excluded · case 01

A cheaper service that arrives exactly on the promised day is skipped.

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

ROOT CAUSE

The transit filter treats the deadline day as late.

VERIFIED REPAIR

Accept services whose transit days are at most the deadline.

Unsuccessful approach: Allowing one extra day accepts late services.

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 = [[['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 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 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]], ['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 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 26', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 0, ['DHL']], 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 59', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 44', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 0, []], None], ['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 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]], ['generated mix 27', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 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]], ['generated mix 70', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['Usp']], None], ['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]], ['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 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 35', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 1, ['dhl']], ['FDX', 'EXPRESS', 2500]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['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]], ['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 43', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 7, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 51', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 1, ['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
deadline inclusive['USP', 'PRIORITY', 1200]['DHL', 'GROUND', 1100]Failed
excluded mixed case['FDX', 'EXPRESS', 2500]['UPX', 'GROUND', 1200]Failed
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
weight at limit['USP', 'PRIORITY', 1200]['DHL', 'GROUND', 1100]Failed
generated mix 6['FDX', 'EXPRESS', 2500]['FDX', 'EXPRESS', 2500]Passed
generated mix 14['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed

SHA-256 / cb0453824d9fe5b54172714053d5a06522aca4a5e7d4d90b68900272588a1357

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 - 1 > 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 = [[['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 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 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]], ['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 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 26', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 0, ['DHL']], 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 59', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 44', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 0, []], None], ['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 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]], ['generated mix 27', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 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]], ['generated mix 70', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['Usp']], None], ['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]], ['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 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 35', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 1, ['dhl']], ['FDX', 'EXPRESS', 2500]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['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]], ['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 43', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 7, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 51', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 1, ['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
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
excluded mixed case['DHL', 'GROUND', 1100]['UPX', 'GROUND', 1200]Failed
faster on price tie['DHL', 'GROUND', 1100]['USP', 'PRIORITY', 1200]Failed
weight over limit['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 1200]Passed
excluded uppercase['USP', 'PRIORITY', 1200]['USP', 'PRIORITY', 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 / 5ef5f76d971429012ec5d4dad32b4da0fef365104719c1b08e4e264708468a59

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 = [[['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 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 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]], ['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 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 26', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 0, ['DHL']], 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 59', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70, 5, ['Usp']], ['UPX', 'GROUND', 1200]], ['generated mix 44', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 0, []], None], ['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 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]], ['generated mix 27', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 1, 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]], ['generated mix 70', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 0, ['Usp']], None], ['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]], ['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 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 35', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 50, 1, ['dhl']], ['FDX', 'EXPRESS', 2500]], ['nothing', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 10, 0, []], None], ['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]], ['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 43', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 120, 7, ['Usp']], ['FDX', 'EXPRESS', 2500]], ['generated mix 51', [[['UPX', 'GROUND', 1200, 5, 70], ['FDX', 'EXPRESS', 2500, 1, 150], ['USP', 'PRIORITY', 1200, 3, 70], ['DHL', 'GROUND', 1100, 6, 50]], 70.2, 1, ['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
deadline inclusive['DHL', 'GROUND', 1100]['DHL', 'GROUND', 1100]Passed
excluded mixed case['UPX', 'GROUND', 1200]['UPX', 'GROUND', 1200]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
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 / 7c8f4a728b6df4ebe39f7b18128ada4e1f7ff7e9e3cc2d13eb1177ea6b618526

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

Case digest / 18d53ae83b7d5a35a6c5a3d35b9b30f62bb05dba5416a572f55ced714542c8f6