FAILURE MAP
← Case archive

FA-95591 / Shipping rate zone lookup / Open access

Injection zone: grid distance instead of straight line · case 01

Diagonal destinations are rated one or two zones too far.

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

ROOT CAUSE

Distance is the sum of axis offsets (Manhattan) rather than straight line.

THE FAILURE

Distance is the sum of axis offsets (Manhattan) rather than straight line.

Unsuccessful approach: Subtracting the destination x from the hub y compares the wrong axis.

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 = (abs(x - dest[0]) + abs(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 = [[['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['generated mix 2', [[-10, 3], [['IL', 2000, 41, 100], ['TX', 590, 150, 300]]], ['TX', 5, 618]], ['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]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['generated mix 7', [[5, 3], [['NJ', 0, 41, 300], ['NJ', 100, 400, 300], ['NJ', 0, 0, 100]]], ['NJ', 1, 6]], ['generated mix 15', [[5, 0], [['IL', 30, 40, 300], ['IL', 1500, 150, 300]]], ['IL', 1, 48]]], [['generated mix 6', [[0, 0], [['PA', 2000, 150, 100], ['OH', 40, 400, 300], ['IL', 290, 40, 300]]], ['IL', 3, 293]], ['generated mix 13', [[5, 0], [['GA', 301, 1, 300], ['PA', 1000, 400, 900], ['NJ', 300, 0, 100]]], ['NJ', 3, 295]], ['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]], ['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]], ['generated mix 10', [[5, 0], [['GA', 2000, 400, 900], ['IL', 1500, 41, 300]]], ['IL', 7, 1496]], ['generated mix 19', [[5, 0], [['OH', 40, 1, 900], ['NJ', 2000, 150, 100], ['IL', 290, 0, 100], ['NJ', 40, 400, 100]]], ['OH', 1, 36]]], [['generated mix 15', [[5, 0], [['IL', 30, 40, 300], ['IL', 1500, 150, 300]]], ['IL', 1, 48]], ['generated mix 24', [[0, 3], [['PA', 40, 40, 300], ['TX', 1000, 150, 900]]], ['PA', 2, 55]], ['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 21', [[5, 0], [['GA', 590, 41, 100], ['GA', 1500, 400, 900], ['PA', 100, 1, 100], ['GA', 2000, 40, 100]]], ['PA', 2, 96]], ['generated mix 30', [[-10, 3], [['OH', 0, 41, 300], ['PA', 300, 1, 300], ['NJ', 290, 40, 300]]], ['OH', 1, 40]]], [['generated mix 27', [[5, 0], [['IL', 0, 40, 900], ['NJ', 590, 150, 300], ['IL', 300, 41, 300]]], ['IL', 1, 41]], ['generated mix 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['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 33', [[0, 3], [['GA', 1500, 150, 900], ['OH', 30, 1, 300]]], ['OH', 1, 31]], ['generated mix 41', [[0, 3], [['OH', 30, 0, 300], ['PA', 1500, 0, 300]]], ['OH', 1, 31]]], [['generated mix 35', [[0, 0], [['GA', 301, 1, 300], ['NJ', 40, 150, 900]]], ['NJ', 3, 156]], ['generated mix 41', [[0, 3], [['OH', 30, 0, 300], ['PA', 1500, 0, 300]]], ['OH', 1, 31]], ['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
exact 50 miles['A', 2, 70]['A', 1, 50]Failed
generated mix 2['TX', 5, 747]['TX', 5, 618]Failed
just over['A', 2, 71]['A', 2, 51]Failed
zone beats linehaul['A', 1, 40]['A', 1, 40]Passed
far['A', 8, 2000]['A', 8, 2000]Passed
linehaul tiebreak['B', 2, 120]['B', 2, 120]Passed
generated mix 7['NJ', 1, 8]['NJ', 1, 6]Failed
generated mix 15['IL', 2, 65]['IL', 1, 48]Failed

SHA-256 / 1708696c0adb4ca379cfdeba9dd7560bf3d415a5c04404b9fd8a2cbe9f30d5aa

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[0]) ** 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 = [[['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['generated mix 2', [[-10, 3], [['IL', 2000, 41, 100], ['TX', 590, 150, 300]]], ['TX', 5, 618]], ['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]], ['linehaul tiebreak', [[0, 0], [['A', 100, 0, 900], ['B', 0, 120, 300]]], ['B', 2, 120]], ['generated mix 7', [[5, 3], [['NJ', 0, 41, 300], ['NJ', 100, 400, 300], ['NJ', 0, 0, 100]]], ['NJ', 1, 6]], ['generated mix 15', [[5, 0], [['IL', 30, 40, 300], ['IL', 1500, 150, 300]]], ['IL', 1, 48]]], [['generated mix 6', [[0, 0], [['PA', 2000, 150, 100], ['OH', 40, 400, 300], ['IL', 290, 40, 300]]], ['IL', 3, 293]], ['generated mix 13', [[5, 0], [['GA', 301, 1, 300], ['PA', 1000, 400, 900], ['NJ', 300, 0, 100]]], ['NJ', 3, 295]], ['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]], ['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]], ['generated mix 10', [[5, 0], [['GA', 2000, 400, 900], ['IL', 1500, 41, 300]]], ['IL', 7, 1496]], ['generated mix 19', [[5, 0], [['OH', 40, 1, 900], ['NJ', 2000, 150, 100], ['IL', 290, 0, 100], ['NJ', 40, 400, 100]]], ['OH', 1, 36]]], [['generated mix 15', [[5, 0], [['IL', 30, 40, 300], ['IL', 1500, 150, 300]]], ['IL', 1, 48]], ['generated mix 24', [[0, 3], [['PA', 40, 40, 300], ['TX', 1000, 150, 900]]], ['PA', 2, 55]], ['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 21', [[5, 0], [['GA', 590, 41, 100], ['GA', 1500, 400, 900], ['PA', 100, 1, 100], ['GA', 2000, 40, 100]]], ['PA', 2, 96]], ['generated mix 30', [[-10, 3], [['OH', 0, 41, 300], ['PA', 300, 1, 300], ['NJ', 290, 40, 300]]], ['OH', 1, 40]]], [['generated mix 27', [[5, 0], [['IL', 0, 40, 900], ['NJ', 590, 150, 300], ['IL', 300, 41, 300]]], ['IL', 1, 41]], ['generated mix 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['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 33', [[0, 3], [['GA', 1500, 150, 900], ['OH', 30, 1, 300]]], ['OH', 1, 31]], ['generated mix 41', [[0, 3], [['OH', 30, 0, 300], ['PA', 1500, 0, 300]]], ['OH', 1, 31]]], [['generated mix 35', [[0, 0], [['GA', 301, 1, 300], ['NJ', 40, 150, 900]]], ['NJ', 3, 156]], ['generated mix 41', [[0, 3], [['OH', 30, 0, 300], ['PA', 1500, 0, 300]]], ['OH', 1, 31]], ['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
exact 50 miles['A', 1, 50]['A', 1, 50]Passed
generated mix 2['TX', 5, 621]['TX', 5, 618]Failed
just over['A', 2, 51]['A', 2, 51]Passed
zone beats linehaul['A', 1, 40]['A', 1, 40]Passed
far['A', 8, 2000]['A', 8, 2000]Passed
linehaul tiebreak['B', 2, 120]['B', 2, 120]Passed
generated mix 7['NJ', 1, 8]['NJ', 1, 6]Failed
generated mix 15['IL', 1, 44]['IL', 1, 48]Failed

SHA-256 / 42b860eac65a3da05afd014076dce5b5b8ee9e78afe76560e617091bb4b27773

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / ffab26f3d6c83981ed3bf1d1c93b8d27ae37a2e089f4b6149293d4aab5363aa4