FA-95756 / Shipping rate zone lookup / Open access
Region matrix: intra-region shipments unrated · case 01
Shipments within one region fall through to the matrix and return NO_ZONE.
ROOT CAUSE
The same-region zone 2 rule is missing.
VERIFIED REPAIR
Return zone 2 when both ZIP3s map to the same region.
Unsuccessful approach: Rating intra-region shipments as local zone 1 undercharges them.
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'
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], ['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], ['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], ['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], ['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]], [['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 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], ['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], ['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], ['generated mix 9', ['60001', '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]]], 'NO_ZONE'], ['generated mix 17', ['19999', '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]]], 'NO_ZONE']], [['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 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], ['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], ['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], ['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'], ['generated mix 20', ['10001', '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]]], 'NO_ZONE'], ['generated mix 28', ['96001', '59901', [[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 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 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], ['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], ['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 31', ['59901', '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 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]], [['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], ['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], ['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], ['generated mix 42', ['01001', '89901', [[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]]], 8], ['generated mix 50', ['19901', '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 58', ['01001', '01001', [[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]]]
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 |
|---|---|---|---|
| same region | NO_ZONE | 2 | Failed |
| generated mix 14 | NO_ZONE | 2 | Failed |
| same zip3 | 1 | 1 | Passed |
| reverse pair | 4 | 4 | Passed |
| reverse listing | 5 | 5 | Passed |
| local outside regions | 1 | 1 | Passed |
| listed pair | 4 | 4 | Passed |
| generated mix 6 | 1 | 1 | Passed |
SHA-256 / 7c9c57c4556f1fef20b92e9275f73ffba5bd88f5ce06e8bdf42e89ff1860d9bb
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 1
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], ['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], ['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], ['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], ['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]], [['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 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], ['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], ['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], ['generated mix 9', ['60001', '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]]], 'NO_ZONE'], ['generated mix 17', ['19999', '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]]], 'NO_ZONE']], [['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 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], ['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], ['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], ['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'], ['generated mix 20', ['10001', '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]]], 'NO_ZONE'], ['generated mix 28', ['96001', '59901', [[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 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 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], ['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], ['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 31', ['59901', '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 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]], [['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], ['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], ['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], ['generated mix 42', ['01001', '89901', [[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]]], 8], ['generated mix 50', ['19901', '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 58', ['01001', '01001', [[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]]]
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 |
|---|---|---|---|
| same region | 1 | 2 | Failed |
| generated mix 14 | 1 | 2 | Failed |
| same zip3 | 1 | 1 | Passed |
| reverse pair | 4 | 4 | Passed |
| reverse listing | 5 | 5 | Passed |
| local outside regions | 1 | 1 | Passed |
| listed pair | 4 | 4 | Passed |
| generated mix 6 | 1 | 1 | Passed |
SHA-256 / 0419de056445c97a2aa2384e635c90bbd92b419166a5378a12ab19b8fd148db2
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], ['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], ['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], ['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], ['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]], [['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 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], ['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], ['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], ['generated mix 9', ['60001', '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]]], 'NO_ZONE'], ['generated mix 17', ['19999', '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]]], 'NO_ZONE']], [['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 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], ['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], ['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], ['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'], ['generated mix 20', ['10001', '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]]], 'NO_ZONE'], ['generated mix 28', ['96001', '59901', [[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 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 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], ['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], ['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 31', ['59901', '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 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]], [['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], ['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], ['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], ['generated mix 42', ['01001', '89901', [[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]]], 8], ['generated mix 50', ['19901', '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 58', ['01001', '01001', [[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]]]
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 |
|---|---|---|---|
| same region | 2 | 2 | Passed |
| generated mix 14 | 2 | 2 | Passed |
| same zip3 | 1 | 1 | Passed |
| reverse pair | 4 | 4 | Passed |
| reverse listing | 5 | 5 | Passed |
| local outside regions | 1 | 1 | Passed |
| listed pair | 4 | 4 | Passed |
| generated mix 6 | 1 | 1 | Passed |
SHA-256 / 9a538dd51b80b29f60f132aba3915178daaa0a7cc476bbddd4f7083f7d91066e
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.518895+00:00.
Case digest / bc86901bb838f4684dd21e2800e64c7d3f03857fe58e424caf02ce0718fc5cda