FA-95576 / Shipping rate zone lookup / Open access
Injection zone: distance truncated · case 01
Destinations a fraction of a mile past a band edge are rated in the cheaper zone.
ROOT CAUSE
Distance uses the integer square root without rounding up the remainder.
VERIFIED REPAIR
Round the straight-line distance up to a whole mile.
Unsuccessful approach: Rounding to nearest keeps distances just over a band in the lower zone.
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
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 = [[['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 4', [[0, 3], [['IL', 301, 41, 300]]], ['IL', 4, 304]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['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 8', [[5, 0], [['GA', 300, 40, 300]]], ['GA', 3, 298]], ['generated mix 19', [[5, 0], [['OH', 40, 1, 900], ['NJ', 2000, 150, 100], ['IL', 290, 0, 100], ['NJ', 40, 400, 100]]], ['OH', 1, 36]], ['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 18', [[5, 3], [['IL', 30, 41, 300], ['IL', 120, 400, 300]]], ['IL', 1, 46]]], [['generated mix 18', [[5, 3], [['IL', 30, 41, 300], ['IL', 120, 400, 300]]], ['IL', 1, 46]], ['generated mix 25', [[0, 0], [['GA', 30, 1, 300]]], ['GA', 1, 31]], ['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 25', [[0, 0], [['GA', 30, 1, 300]]], ['GA', 1, 31]], ['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 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| just over | ['A', 1, 50] | ['A', 2, 51] | Failed |
| generated mix 4 | ['IL', 4, 303] | ['IL', 4, 304] | Failed |
| exact 50 miles | ['A', 1, 50] | ['A', 1, 50] | 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, 5] | ['NJ', 1, 6] | Failed |
| generated mix 15 | ['IL', 1, 47] | ['IL', 1, 48] | Failed |
SHA-256 / 888435d5ffde89affb8690ad3d8d1ce94f779341b7b7ed748b6cd1798b452eb3
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 = round(sq ** 0.5)
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 = [[['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 4', [[0, 3], [['IL', 301, 41, 300]]], ['IL', 4, 304]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['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 8', [[5, 0], [['GA', 300, 40, 300]]], ['GA', 3, 298]], ['generated mix 19', [[5, 0], [['OH', 40, 1, 900], ['NJ', 2000, 150, 100], ['IL', 290, 0, 100], ['NJ', 40, 400, 100]]], ['OH', 1, 36]], ['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 18', [[5, 3], [['IL', 30, 41, 300], ['IL', 120, 400, 300]]], ['IL', 1, 46]]], [['generated mix 18', [[5, 3], [['IL', 30, 41, 300], ['IL', 120, 400, 300]]], ['IL', 1, 46]], ['generated mix 25', [[0, 0], [['GA', 30, 1, 300]]], ['GA', 1, 31]], ['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 25', [[0, 0], [['GA', 30, 1, 300]]], ['GA', 1, 31]], ['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 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| just over | ['A', 2, 51] | ['A', 2, 51] | Passed |
| generated mix 4 | ['IL', 4, 303] | ['IL', 4, 304] | Failed |
| exact 50 miles | ['A', 1, 50] | ['A', 1, 50] | 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, 6] | ['NJ', 1, 6] | Passed |
| generated mix 15 | ['IL', 1, 47] | ['IL', 1, 48] | Failed |
SHA-256 / 2d774b87715b3160736ed36eae0194d2322dee60eaef12e1a1ce105fc569ab64
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 = [[['just over', [[0, 0], [['A', 30, 41, 500]]], ['A', 2, 51]], ['generated mix 4', [[0, 3], [['IL', 301, 41, 300]]], ['IL', 4, 304]], ['exact 50 miles', [[0, 0], [['A', 30, 40, 500]]], ['A', 1, 50]], ['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 8', [[5, 0], [['GA', 300, 40, 300]]], ['GA', 3, 298]], ['generated mix 19', [[5, 0], [['OH', 40, 1, 900], ['NJ', 2000, 150, 100], ['IL', 290, 0, 100], ['NJ', 40, 400, 100]]], ['OH', 1, 36]], ['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 18', [[5, 3], [['IL', 30, 41, 300], ['IL', 120, 400, 300]]], ['IL', 1, 46]]], [['generated mix 18', [[5, 3], [['IL', 30, 41, 300], ['IL', 120, 400, 300]]], ['IL', 1, 46]], ['generated mix 25', [[0, 0], [['GA', 30, 1, 300]]], ['GA', 1, 31]], ['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 25', [[0, 0], [['GA', 30, 1, 300]]], ['GA', 1, 31]], ['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 32', [[-10, 0], [['TX', 0, 1, 300], ['TX', 120, 40, 100], ['GA', 40, 400, 900]]], ['TX', 1, 11]], ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| just over | ['A', 2, 51] | ['A', 2, 51] | Passed |
| generated mix 4 | ['IL', 4, 304] | ['IL', 4, 304] | Passed |
| exact 50 miles | ['A', 1, 50] | ['A', 1, 50] | 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, 6] | ['NJ', 1, 6] | Passed |
| generated mix 15 | ['IL', 1, 48] | ['IL', 1, 48] | Passed |
SHA-256 / c55b590d29d2f0b9d0a18d0e36cf5b59d5da5334b23213a79d1322dc23a1d3c7
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.913643+00:00.
Case digest / ec47822dcff233fb8cb960c1e2d57d6258204f508ec3450c0757e312a6320eaa