FAILURE MAP
← Case archive

FA-95586 / Shipping rate zone lookup / Open access

Injection zone: cheapest linehaul beats lower zone · case 01

Parcels are injected at the cheapest hub even when it lands them in a higher delivery zone.

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

ROOT CAUSE

The ranking key puts linehaul before zone.

VERIFIED REPAIR

Rank by zone, then linehaul, then name.

Unsuccessful approach: Ranking by name before linehaul ignores linehaul costs among same-zone hubs.

Case contract

dest [x, y] and points [[name, x, y, linehaul_cents]] on a mile grid. Distance = straight line rounded up to a whole mile. Zone bands (miles, inclusive upper): 50, 150, 300, 600, 1000, 1400, 1800 -> zones 1-7, beyond -> 8. Choose the point with the lowest zone, then linehaul, then name. Return [name, zone, miles] or None.

Why this case matters

Zone skipping injects parcels at the hub that minimizes delivery zone and linehaul.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(dest, points):
    BANDS = [50, 150, 300, 600, 1000, 1400, 1800]
    def zone_for(m):
        for i, lim in enumerate(BANDS):
            if m <= lim:
                return i + 1
        return 8
    best = None
    for name, x, y, lh in points:
        sq = (x - dest[0]) ** 2 + (y - dest[1]) ** 2
        s = math.isqrt(sq)
        miles = s + (1 if s * s < sq else 0)
        z = zone_for(miles)
        key = (lh, z, name)
        if best is None or key < best[0]:
            best = (key, [name, z, miles])
    return best[1] if best else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['zone beats linehaul', [[0, 0], [['A', 40, 0, 900], ['B', 0, 120, 300]]], ['A', 1, 40]], ['generated mix 13', [[5, 0], [['GA', 301, 1, 300], ['PA', 1000, 400, 900], ['NJ', 300, 0, 100]]], ['NJ', 3, 295]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 6', [[0, 0], [['PA', 2000, 150, 100], ['OH', 40, 400, 300], ['IL', 290, 40, 300]]], ['IL', 3, 293]], ['generated mix 15', [[5, 0], [['IL', 30, 40, 300], ['IL', 1500, 150, 300]]], ['IL', 1, 48]]], [['generated mix 23', [[0, 0], [['OH', 120, 0, 300], ['OH', 290, 41, 100], ['TX', 30, 41, 300]]], ['OH', 2, 120]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 9', [[-10, 3], [['PA', 120, 1, 900], ['IL', 301, 0, 100], ['IL', 100, 41, 100], ['IL', 0, 0, 900]]], ['IL', 1, 11]], ['generated mix 17', [[5, 3], [['NJ', 301, 0, 900], ['GA', 590, 150, 100], ['PA', 1000, 1, 100], ['TX', 120, 40, 300]]], ['TX', 2, 121]], ['generated mix 26', [[-10, 3], [['PA', 1000, 400, 300], ['PA', 300, 400, 300], ['OH', 300, 400, 100], ['OH', 100, 0, 300]]], ['OH', 2, 111]]], [['generated mix 38', [[0, 3], [['OH', 1000, 0, 100], ['IL', 0, 41, 300], ['PA', 30, 400, 300], ['NJ', 1000, 0, 900]]], ['IL', 1, 38]], ['generated mix 34', [[0, 0], [['GA', 301, 400, 300], ['OH', 120, 400, 100], ['NJ', 1000, 400, 300], ['NJ', 2000, 150, 300]]], ['OH', 4, 418]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['zone beats linehaul', [[0, 0], [['A', 40, 0, 900], ['B', 0, 120, 300]]], ['A', 1, 40]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['generated mix 20', [[5, 3], [['GA', 0, 1, 900], ['PA', 120, 400, 300], ['OH', 590, 41, 300], ['OH', 30, 1, 300]]], ['OH', 1, 26]], ['generated mix 28', [[0, 3], [['NJ', 1500, 150, 300]]], ['NJ', 7, 1508]]], [['generated mix 62', [[5, 3], [['PA', 0, 40, 900], ['TX', 1500, 150, 300], ['IL', 1000, 0, 900]]], ['PA', 1, 38]], ['generated mix 29', [[5, 0], [['IL', 300, 150, 300], ['TX', 301, 400, 100]]], ['TX', 4, 498]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['generated mix 40', [[-10, 3], [['PA', 300, 1, 300], ['PA', 120, 150, 900]]], ['PA', 3, 197]]], [['generated mix 1', [[-10, 0], [['TX', 300, 400, 900], ['GA', 120, 150, 900], ['NJ', 1500, 40, 300], ['NJ', 590, 40, 300]]], ['GA', 3, 199]], ['generated mix 20', [[5, 3], [['GA', 0, 1, 900], ['PA', 120, 400, 300], ['OH', 590, 41, 300], ['OH', 30, 1, 300]]], ['OH', 1, 26]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['generated mix 44', [[0, 3], [['NJ', 590, 1, 300], ['PA', 300, 40, 900]]], ['NJ', 4, 591]], ['generated mix 52', [[-10, 0], [['IL', 290, 400, 300]]], ['IL', 4, 500]]]]
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
zone beats linehaul['B', 2, 120]['A', 1, 40]Failed
generated mix 13['NJ', 3, 295]['NJ', 3, 295]Passed
exact 50 miles['A', 1, 50]['A', 1, 50]Passed
linehaul tiebreak['B', 2, 120]['B', 2, 120]Passed
far['A', 8, 2000]['A', 8, 2000]Passed
just over['A', 2, 51]['A', 2, 51]Passed
generated mix 6['PA', 8, 2006]['IL', 3, 293]Failed
generated mix 15['IL', 1, 48]['IL', 1, 48]Passed

SHA-256 / 05907ec7bd7c4da163cf9e0cfcf19ac3a1e319a82f5ed3b0d91207c116263edb

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(dest, points):
    BANDS = [50, 150, 300, 600, 1000, 1400, 1800]
    def zone_for(m):
        for i, lim in enumerate(BANDS):
            if m <= lim:
                return i + 1
        return 8
    best = None
    for name, x, y, lh in points:
        sq = (x - dest[0]) ** 2 + (y - dest[1]) ** 2
        s = math.isqrt(sq)
        miles = s + (1 if s * s < sq else 0)
        z = zone_for(miles)
        key = (z, name, lh)
        if best is None or key < best[0]:
            best = (key, [name, z, miles])
    return best[1] if best else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['zone beats linehaul', [[0, 0], [['A', 40, 0, 900], ['B', 0, 120, 300]]], ['A', 1, 40]], ['generated mix 13', [[5, 0], [['GA', 301, 1, 300], ['PA', 1000, 400, 900], ['NJ', 300, 0, 100]]], ['NJ', 3, 295]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 6', [[0, 0], [['PA', 2000, 150, 100], ['OH', 40, 400, 300], ['IL', 290, 40, 300]]], ['IL', 3, 293]], ['generated mix 15', [[5, 0], [['IL', 30, 40, 300], ['IL', 1500, 150, 300]]], ['IL', 1, 48]]], [['generated mix 23', [[0, 0], [['OH', 120, 0, 300], ['OH', 290, 41, 100], ['TX', 30, 41, 300]]], ['OH', 2, 120]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 9', [[-10, 3], [['PA', 120, 1, 900], ['IL', 301, 0, 100], ['IL', 100, 41, 100], ['IL', 0, 0, 900]]], ['IL', 1, 11]], ['generated mix 17', [[5, 3], [['NJ', 301, 0, 900], ['GA', 590, 150, 100], ['PA', 1000, 1, 100], ['TX', 120, 40, 300]]], ['TX', 2, 121]], ['generated mix 26', [[-10, 3], [['PA', 1000, 400, 300], ['PA', 300, 400, 300], ['OH', 300, 400, 100], ['OH', 100, 0, 300]]], ['OH', 2, 111]]], [['generated mix 38', [[0, 3], [['OH', 1000, 0, 100], ['IL', 0, 41, 300], ['PA', 30, 400, 300], ['NJ', 1000, 0, 900]]], ['IL', 1, 38]], ['generated mix 34', [[0, 0], [['GA', 301, 400, 300], ['OH', 120, 400, 100], ['NJ', 1000, 400, 300], ['NJ', 2000, 150, 300]]], ['OH', 4, 418]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['zone beats linehaul', [[0, 0], [['A', 40, 0, 900], ['B', 0, 120, 300]]], ['A', 1, 40]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['generated mix 20', [[5, 3], [['GA', 0, 1, 900], ['PA', 120, 400, 300], ['OH', 590, 41, 300], ['OH', 30, 1, 300]]], ['OH', 1, 26]], ['generated mix 28', [[0, 3], [['NJ', 1500, 150, 300]]], ['NJ', 7, 1508]]], [['generated mix 62', [[5, 3], [['PA', 0, 40, 900], ['TX', 1500, 150, 300], ['IL', 1000, 0, 900]]], ['PA', 1, 38]], ['generated mix 29', [[5, 0], [['IL', 300, 150, 300], ['TX', 301, 400, 100]]], ['TX', 4, 498]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['generated mix 40', [[-10, 3], [['PA', 300, 1, 300], ['PA', 120, 150, 900]]], ['PA', 3, 197]]], [['generated mix 1', [[-10, 0], [['TX', 300, 400, 900], ['GA', 120, 150, 900], ['NJ', 1500, 40, 300], ['NJ', 590, 40, 300]]], ['GA', 3, 199]], ['generated mix 20', [[5, 3], [['GA', 0, 1, 900], ['PA', 120, 400, 300], ['OH', 590, 41, 300], ['OH', 30, 1, 300]]], ['OH', 1, 26]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['generated mix 44', [[0, 3], [['NJ', 590, 1, 300], ['PA', 300, 40, 900]]], ['NJ', 4, 591]], ['generated mix 52', [[-10, 0], [['IL', 290, 400, 300]]], ['IL', 4, 500]]]]
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
zone beats linehaul['A', 1, 40]['A', 1, 40]Passed
generated mix 13['GA', 3, 297]['NJ', 3, 295]Failed
exact 50 miles['A', 1, 50]['A', 1, 50]Passed
linehaul tiebreak['A', 2, 100]['B', 2, 120]Failed
far['A', 8, 2000]['A', 8, 2000]Passed
just over['A', 2, 51]['A', 2, 51]Passed
generated mix 6['IL', 3, 293]['IL', 3, 293]Passed
generated mix 15['IL', 1, 48]['IL', 1, 48]Passed

SHA-256 / c918ebf9bc2a2b0795f2a0cff2747f08172e562f9013096405d85c3e3310afd9

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(dest, points):
    BANDS = [50, 150, 300, 600, 1000, 1400, 1800]
    def zone_for(m):
        for i, lim in enumerate(BANDS):
            if m <= lim:
                return i + 1
        return 8
    best = None
    for name, x, y, lh in points:
        sq = (x - dest[0]) ** 2 + (y - dest[1]) ** 2
        s = math.isqrt(sq)
        miles = s + (1 if s * s < sq else 0)
        z = zone_for(miles)
        key = (z, lh, name)
        if best is None or key < best[0]:
            best = (key, [name, z, miles])
    return best[1] if best else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['zone beats linehaul', [[0, 0], [['A', 40, 0, 900], ['B', 0, 120, 300]]], ['A', 1, 40]], ['generated mix 13', [[5, 0], [['GA', 301, 1, 300], ['PA', 1000, 400, 900], ['NJ', 300, 0, 100]]], ['NJ', 3, 295]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 6', [[0, 0], [['PA', 2000, 150, 100], ['OH', 40, 400, 300], ['IL', 290, 40, 300]]], ['IL', 3, 293]], ['generated mix 15', [[5, 0], [['IL', 30, 40, 300], ['IL', 1500, 150, 300]]], ['IL', 1, 48]]], [['generated mix 23', [[0, 0], [['OH', 120, 0, 300], ['OH', 290, 41, 100], ['TX', 30, 41, 300]]], ['OH', 2, 120]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 9', [[-10, 3], [['PA', 120, 1, 900], ['IL', 301, 0, 100], ['IL', 100, 41, 100], ['IL', 0, 0, 900]]], ['IL', 1, 11]], ['generated mix 17', [[5, 3], [['NJ', 301, 0, 900], ['GA', 590, 150, 100], ['PA', 1000, 1, 100], ['TX', 120, 40, 300]]], ['TX', 2, 121]], ['generated mix 26', [[-10, 3], [['PA', 1000, 400, 300], ['PA', 300, 400, 300], ['OH', 300, 400, 100], ['OH', 100, 0, 300]]], ['OH', 2, 111]]], [['generated mix 38', [[0, 3], [['OH', 1000, 0, 100], ['IL', 0, 41, 300], ['PA', 30, 400, 300], ['NJ', 1000, 0, 900]]], ['IL', 1, 38]], ['generated mix 34', [[0, 0], [['GA', 301, 400, 300], ['OH', 120, 400, 100], ['NJ', 1000, 400, 300], ['NJ', 2000, 150, 300]]], ['OH', 4, 418]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['zone beats linehaul', [[0, 0], [['A', 40, 0, 900], ['B', 0, 120, 300]]], ['A', 1, 40]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['generated mix 20', [[5, 3], [['GA', 0, 1, 900], ['PA', 120, 400, 300], ['OH', 590, 41, 300], ['OH', 30, 1, 300]]], ['OH', 1, 26]], ['generated mix 28', [[0, 3], [['NJ', 1500, 150, 300]]], ['NJ', 7, 1508]]], [['generated mix 62', [[5, 3], [['PA', 0, 40, 900], ['TX', 1500, 150, 300], ['IL', 1000, 0, 900]]], ['PA', 1, 38]], ['generated mix 29', [[5, 0], [['IL', 300, 150, 300], ['TX', 301, 400, 100]]], ['TX', 4, 498]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['no points', [[0, 0], []], None], ['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['generated mix 40', [[-10, 3], [['PA', 300, 1, 300], ['PA', 120, 150, 900]]], ['PA', 3, 197]]], [['generated mix 1', [[-10, 0], [['TX', 300, 400, 900], ['GA', 120, 150, 900], ['NJ', 1500, 40, 300], ['NJ', 590, 40, 300]]], ['GA', 3, 199]], ['generated mix 20', [[5, 3], [['GA', 0, 1, 900], ['PA', 120, 400, 300], ['OH', 590, 41, 300], ['OH', 30, 1, 300]]], ['OH', 1, 26]], ['far', [[0, 0], [['A', 2000, 0, 1]]], ['A', 8, 2000]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['name tiebreak', [[0, 0], [['Z', 10, 0, 100], ['M', 0, 10, 100]]], ['M', 1, 10]], ['generated mix 44', [[0, 3], [['NJ', 590, 1, 300], ['PA', 300, 40, 900]]], ['NJ', 4, 591]], ['generated mix 52', [[-10, 0], [['IL', 290, 400, 300]]], ['IL', 4, 500]]]]
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
zone beats linehaul['A', 1, 40]['A', 1, 40]Passed
generated mix 13['NJ', 3, 295]['NJ', 3, 295]Passed
exact 50 miles['A', 1, 50]['A', 1, 50]Passed
linehaul tiebreak['B', 2, 120]['B', 2, 120]Passed
far['A', 8, 2000]['A', 8, 2000]Passed
just over['A', 2, 51]['A', 2, 51]Passed
generated mix 6['IL', 3, 293]['IL', 3, 293]Passed
generated mix 15['IL', 1, 48]['IL', 1, 48]Passed

SHA-256 / bfd00c5827c3477e9ced2973bc9c1c9e2ca650a2a481b8ba323bbe6c6217623b

Verification & scope

Grid distance stand-in; not geodesic distances. 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.998851+00:00.

Case digest / df70ca5ae88ba7a8a62adba3c6caaf1cc87edec34e11bc3f89526714d48eb298