FAILURE MAP
← Case archive

FA-95751 / Shipping rate zone lookup / Open access

Region matrix: region end ZIP3 unassigned · case 01

ZIP3s at the upper edge of a region are treated as unknown.

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

ROOT CAUSE

The region range upper bound is exclusive.

VERIFIED REPAIR

Region ranges include both ends.

Unsuccessful approach: Excluding the lower bound instead drops each region first ZIP3.

Case contract

origin and dest are five-digit ZIP strings. Same ZIP3 -> zone 1. regions [[lo3, hi3, region]] inclusive. Unknown region -> "NO_ZONE". Same region -> zone 2. Otherwise the matrix [[region_a, region_b, zone]] lists each pair once and applies in both directions; unlisted pair -> "NO_ZONE".

Why this case matters

Regional carriers rate by origin and destination region matrices.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(origin, dest, regions, matrix):
    def region(z3):
        for lo, hi, r in regions:
            if lo <= z3 < hi:
                return r
        return None
    o = int(origin[:3])
    d = int(dest[:3])
    if o == d:
        return 1
    ro, rd = region(o), region(d)
    if ro is None or rd is None:
        return 'NO_ZONE'
    if ro == rd:
        return 2
    for a, b, zone in matrix:
        if (a, b) == (ro, rd) or (a, b) == (rd, ro):
            return zone
    return 'NO_ZONE'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 6', ['20001', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 14', ['60001', '79901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2]], [['generated mix 30', ['19999', '39999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 22', ['40001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['local outside regions', ['96001', '96002', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 8', ['96001', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['generated mix 16', ['79901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 40', ['89901', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['generated mix 39', ['60001', '79901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['region edges', ['19901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 19', ['96001', '96001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 27', ['96001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 61', ['10001', '19901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 52', ['19901', '40001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['local outside regions', ['96001', '96002', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 30', ['19999', '39999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 38', ['79901', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 78', ['39999', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 75', ['30001', '80001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 7], ['region edges', ['19901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 41', ['79901', '96001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['generated mix 49', ['20001', '40001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4]]]
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
same regionNO_ZONE2Failed
reverse listing55Passed
same zip311Passed
reverse pair44Passed
unlisted pairNO_ZONENO_ZONEPassed
listed pair44Passed
generated mix 611Passed
generated mix 14NO_ZONE2Failed

SHA-256 / a7668aca495a6c651eea31d22c214d6cefff76daeebf572046fb0267a656e1c5

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(origin, dest, regions, matrix):
    def region(z3):
        for lo, hi, r in regions:
            if lo < z3 <= hi:
                return r
        return None
    o = int(origin[:3])
    d = int(dest[:3])
    if o == d:
        return 1
    ro, rd = region(o), region(d)
    if ro is None or rd is None:
        return 'NO_ZONE'
    if ro == rd:
        return 2
    for a, b, zone in matrix:
        if (a, b) == (ro, rd) or (a, b) == (rd, ro):
            return zone
    return 'NO_ZONE'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 6', ['20001', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 14', ['60001', '79901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2]], [['generated mix 30', ['19999', '39999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 22', ['40001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['local outside regions', ['96001', '96002', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 8', ['96001', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['generated mix 16', ['79901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 40', ['89901', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['generated mix 39', ['60001', '79901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['region edges', ['19901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 19', ['96001', '96001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 27', ['96001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 61', ['10001', '19901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 52', ['19901', '40001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['local outside regions', ['96001', '96002', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 30', ['19999', '39999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 38', ['79901', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 78', ['39999', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 75', ['30001', '80001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 7], ['region edges', ['19901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 41', ['79901', '96001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['generated mix 49', ['20001', '40001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4]]]
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
same region22Passed
reverse listingNO_ZONE5Failed
same zip311Passed
reverse pair44Passed
unlisted pairNO_ZONENO_ZONEPassed
listed pair44Passed
generated mix 611Passed
generated mix 14NO_ZONE2Failed

SHA-256 / d2ad773652b3766991f1c40e9a4711b8cc17b5bbf0542906954e799356e5365f

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(origin, dest, regions, matrix):
    def region(z3):
        for lo, hi, r in regions:
            if lo <= z3 <= hi:
                return r
        return None
    o = int(origin[:3])
    d = int(dest[:3])
    if o == d:
        return 1
    ro, rd = region(o), region(d)
    if ro is None or rd is None:
        return 'NO_ZONE'
    if ro == rd:
        return 2
    for a, b, zone in matrix:
        if (a, b) == (ro, rd) or (a, b) == (rd, ro):
            return zone
    return 'NO_ZONE'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 6', ['20001', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 14', ['60001', '79901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2]], [['generated mix 30', ['19999', '39999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 22', ['40001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['local outside regions', ['96001', '96002', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 8', ['96001', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['generated mix 16', ['79901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 40', ['89901', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['generated mix 39', ['60001', '79901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['region edges', ['19901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 19', ['96001', '96001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 27', ['96001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 61', ['10001', '19901', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 52', ['19901', '40001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['same region', ['10001', '19999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['reverse pair', ['30001', '10001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['reverse listing', ['80001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 5], ['local outside regions', ['96001', '96002', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['generated mix 30', ['19999', '39999', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 38', ['79901', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE']], [['generated mix 78', ['39999', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 2], ['generated mix 75', ['30001', '80001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 7], ['region edges', ['19901', '20001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['unlisted pair', ['10001', '60001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['same zip3', ['10001', '10099', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 1], ['listed pair', ['10001', '30001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4], ['generated mix 41', ['79901', '96001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 'NO_ZONE'], ['generated mix 49', ['20001', '40001', [[0, 199, 'NE'], [200, 399, 'SE'], [400, 599, 'MW'], [600, 799, 'SC'], [800, 899, 'W']], [['NE', 'SE', 4], ['NE', 'MW', 5], ['NE', 'W', 8], ['SE', 'MW', 4], ['MW', 'W', 6], ['SE', 'W', 7], ['SC', 'W', 5]]], 4]]]
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
same region22Passed
reverse listing55Passed
same zip311Passed
reverse pair44Passed
unlisted pairNO_ZONENO_ZONEPassed
listed pair44Passed
generated mix 611Passed
generated mix 1422Passed

SHA-256 / 8cbe8091c1b333d3115cfafa7b4a7b6f9c4f7b23efe942722967dfd5dfef2111

Verification & scope

Stipulated regions and matrix. 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.517162+00:00.

Case digest / df7d0bc712cab13ba75feb7d7582cf4961beaa6ea71d5fda8609e8f6e8357376