FAILURE MAP
← Case archive

FA-95971 / Postal address normalization / Open access

Alternating letter-digit postal code: forbidden letters are checked only at the first position · case 01

"K1U 4B1" is accepted although U is forbidden everywhere.

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

ROOT CAUSE

The forbidden-letter test is restricted to index 0.

VERIFIED REPAIR

Apply the D F I O Q U test to every letter position.

Unsuccessful approach: Checking every position with a set that omits U still accepts "K1U 4B1".

Case contract

Strip and uppercase. A 7-character input with a space at index 3 loses the space. The result must be 6 characters alternating ASCII letter, digit, letter, digit, letter, digit. Letters D F I O Q U are forbidden everywhere; W and Z are forbidden in the first position only. Return "L9L 9L9" or None.

Why this case matters

Six-character alternating codes are typed with and without the space; rejecting or accepting the wrong letters silently drops or misroutes mail.

1 / The failure

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

N = 1
observations = []
def solve(x):
    s = x.strip().upper()
    if len(s) == 7 and s[3] == ' ':
        s = s[:3] + s[4:]
    if len(s) != 6:
        return None
    for i, c in enumerate(s):
        if i % 2 == 0:
            if not ('A' <= c <= 'Z') or (i == 0 and c in 'DFIOQU'):
                return None
        elif not c.isdigit():
            return None
    if s[0] in 'WZ':
        return None
    return s[:3] + ' ' + s[3:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['compact code gets its space', 'K1A4B1', 'K1A 4B1'], ['spaced lowercase code', 'k1a 4b1', 'K1A 4B1'], ['hyphen separator rejected', 'K1A-4B1', None], ['forbidden letter in third position', 'K1U 4B1', None], ['Z not allowed first', 'Z1A 4B1', None], ['W allowed after the first position', 'K1W 4B1', 'K1W 4B1'], ['seven characters without space rejected', 'K1A4B1C', None], ['five characters rejected', 'K1A4B', None]], [['compact code gets its space', 'K2A5B2', 'K2A 5B2'], ['spaced lowercase code', 'k2a 5b2', 'K2A 5B2'], ['hyphen separator rejected', 'K2A-5B2', None], ['forbidden letter in third position', 'K2U 5B2', None], ['Z not allowed first', 'Z2A 5B2', None], ['W allowed after the first position', 'K2W 5B2', 'K2W 5B2'], ['seven characters without space rejected', 'K2A5B2C', None], ['five characters rejected', 'K2A5B', None]], [['compact code gets its space', 'K3A6B3', 'K3A 6B3'], ['spaced lowercase code', 'k3a 6b3', 'K3A 6B3'], ['hyphen separator rejected', 'K3A-6B3', None], ['forbidden letter in third position', 'K3U 6B3', None], ['Z not allowed first', 'Z3A 6B3', None], ['W allowed after the first position', 'K3W 6B3', 'K3W 6B3'], ['seven characters without space rejected', 'K3A6B3C', None], ['five characters rejected', 'K3A6B', None]], [['compact code gets its space', 'K4A7B4', 'K4A 7B4'], ['spaced lowercase code', 'k4a 7b4', 'K4A 7B4'], ['hyphen separator rejected', 'K4A-7B4', None], ['forbidden letter in third position', 'K4U 7B4', None], ['Z not allowed first', 'Z4A 7B4', None], ['W allowed after the first position', 'K4W 7B4', 'K4W 7B4'], ['seven characters without space rejected', 'K4A7B4C', None], ['five characters rejected', 'K4A7B', None]], [['compact code gets its space', 'K5A8B5', 'K5A 8B5'], ['spaced lowercase code', 'k5a 8b5', 'K5A 8B5'], ['hyphen separator rejected', 'K5A-8B5', None], ['forbidden letter in third position', 'K5U 8B5', None], ['Z not allowed first', 'Z5A 8B5', None], ['W allowed after the first position', 'K5W 8B5', 'K5W 8B5'], ['seven characters without space rejected', 'K5A8B5C', None], ['five characters rejected', 'K5A8B', None]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), 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
compact code gets its spaceK1A 4B1K1A 4B1Passed
spaced lowercase codeK1A 4B1K1A 4B1Passed
hyphen separator rejectedNoneNonePassed
forbidden letter in third positionK1U 4B1NoneFailed
Z not allowed firstNoneNonePassed
W allowed after the first positionK1W 4B1K1W 4B1Passed
seven characters without space rejectedNoneNonePassed
five characters rejectedNoneNonePassed

SHA-256 / f7ce5519bf5cd21ffa7859326e515999fb057135a33793aee2716fb6d312e83b

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    s = x.strip().upper()
    if len(s) == 7 and s[3] == ' ':
        s = s[:3] + s[4:]
    if len(s) != 6:
        return None
    for i, c in enumerate(s):
        if i % 2 == 0:
            if not ('A' <= c <= 'Z') or c in 'DFIOQ':
                return None
        elif not c.isdigit():
            return None
    if s[0] in 'WZ':
        return None
    return s[:3] + ' ' + s[3:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['compact code gets its space', 'K1A4B1', 'K1A 4B1'], ['spaced lowercase code', 'k1a 4b1', 'K1A 4B1'], ['hyphen separator rejected', 'K1A-4B1', None], ['forbidden letter in third position', 'K1U 4B1', None], ['Z not allowed first', 'Z1A 4B1', None], ['W allowed after the first position', 'K1W 4B1', 'K1W 4B1'], ['seven characters without space rejected', 'K1A4B1C', None], ['five characters rejected', 'K1A4B', None]], [['compact code gets its space', 'K2A5B2', 'K2A 5B2'], ['spaced lowercase code', 'k2a 5b2', 'K2A 5B2'], ['hyphen separator rejected', 'K2A-5B2', None], ['forbidden letter in third position', 'K2U 5B2', None], ['Z not allowed first', 'Z2A 5B2', None], ['W allowed after the first position', 'K2W 5B2', 'K2W 5B2'], ['seven characters without space rejected', 'K2A5B2C', None], ['five characters rejected', 'K2A5B', None]], [['compact code gets its space', 'K3A6B3', 'K3A 6B3'], ['spaced lowercase code', 'k3a 6b3', 'K3A 6B3'], ['hyphen separator rejected', 'K3A-6B3', None], ['forbidden letter in third position', 'K3U 6B3', None], ['Z not allowed first', 'Z3A 6B3', None], ['W allowed after the first position', 'K3W 6B3', 'K3W 6B3'], ['seven characters without space rejected', 'K3A6B3C', None], ['five characters rejected', 'K3A6B', None]], [['compact code gets its space', 'K4A7B4', 'K4A 7B4'], ['spaced lowercase code', 'k4a 7b4', 'K4A 7B4'], ['hyphen separator rejected', 'K4A-7B4', None], ['forbidden letter in third position', 'K4U 7B4', None], ['Z not allowed first', 'Z4A 7B4', None], ['W allowed after the first position', 'K4W 7B4', 'K4W 7B4'], ['seven characters without space rejected', 'K4A7B4C', None], ['five characters rejected', 'K4A7B', None]], [['compact code gets its space', 'K5A8B5', 'K5A 8B5'], ['spaced lowercase code', 'k5a 8b5', 'K5A 8B5'], ['hyphen separator rejected', 'K5A-8B5', None], ['forbidden letter in third position', 'K5U 8B5', None], ['Z not allowed first', 'Z5A 8B5', None], ['W allowed after the first position', 'K5W 8B5', 'K5W 8B5'], ['seven characters without space rejected', 'K5A8B5C', None], ['five characters rejected', 'K5A8B', None]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), 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
compact code gets its spaceK1A 4B1K1A 4B1Passed
spaced lowercase codeK1A 4B1K1A 4B1Passed
hyphen separator rejectedNoneNonePassed
forbidden letter in third positionK1U 4B1NoneFailed
Z not allowed firstNoneNonePassed
W allowed after the first positionK1W 4B1K1W 4B1Passed
seven characters without space rejectedNoneNonePassed
five characters rejectedNoneNonePassed

SHA-256 / b9109bae8fa03c67a7d0a73b1f0083766d604cc34e307f3fbba50d3f48913287

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    s = x.strip().upper()
    if len(s) == 7 and s[3] == ' ':
        s = s[:3] + s[4:]
    if len(s) != 6:
        return None
    for i, c in enumerate(s):
        if i % 2 == 0:
            if not ('A' <= c <= 'Z') or c in 'DFIOQU':
                return None
        elif not c.isdigit():
            return None
    if s[0] in 'WZ':
        return None
    return s[:3] + ' ' + s[3:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['compact code gets its space', 'K1A4B1', 'K1A 4B1'], ['spaced lowercase code', 'k1a 4b1', 'K1A 4B1'], ['hyphen separator rejected', 'K1A-4B1', None], ['forbidden letter in third position', 'K1U 4B1', None], ['Z not allowed first', 'Z1A 4B1', None], ['W allowed after the first position', 'K1W 4B1', 'K1W 4B1'], ['seven characters without space rejected', 'K1A4B1C', None], ['five characters rejected', 'K1A4B', None]], [['compact code gets its space', 'K2A5B2', 'K2A 5B2'], ['spaced lowercase code', 'k2a 5b2', 'K2A 5B2'], ['hyphen separator rejected', 'K2A-5B2', None], ['forbidden letter in third position', 'K2U 5B2', None], ['Z not allowed first', 'Z2A 5B2', None], ['W allowed after the first position', 'K2W 5B2', 'K2W 5B2'], ['seven characters without space rejected', 'K2A5B2C', None], ['five characters rejected', 'K2A5B', None]], [['compact code gets its space', 'K3A6B3', 'K3A 6B3'], ['spaced lowercase code', 'k3a 6b3', 'K3A 6B3'], ['hyphen separator rejected', 'K3A-6B3', None], ['forbidden letter in third position', 'K3U 6B3', None], ['Z not allowed first', 'Z3A 6B3', None], ['W allowed after the first position', 'K3W 6B3', 'K3W 6B3'], ['seven characters without space rejected', 'K3A6B3C', None], ['five characters rejected', 'K3A6B', None]], [['compact code gets its space', 'K4A7B4', 'K4A 7B4'], ['spaced lowercase code', 'k4a 7b4', 'K4A 7B4'], ['hyphen separator rejected', 'K4A-7B4', None], ['forbidden letter in third position', 'K4U 7B4', None], ['Z not allowed first', 'Z4A 7B4', None], ['W allowed after the first position', 'K4W 7B4', 'K4W 7B4'], ['seven characters without space rejected', 'K4A7B4C', None], ['five characters rejected', 'K4A7B', None]], [['compact code gets its space', 'K5A8B5', 'K5A 8B5'], ['spaced lowercase code', 'k5a 8b5', 'K5A 8B5'], ['hyphen separator rejected', 'K5A-8B5', None], ['forbidden letter in third position', 'K5U 8B5', None], ['Z not allowed first', 'Z5A 8B5', None], ['W allowed after the first position', 'K5W 8B5', 'K5W 8B5'], ['seven characters without space rejected', 'K5A8B5C', None], ['five characters rejected', 'K5A8B', None]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), 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
compact code gets its spaceK1A 4B1K1A 4B1Passed
spaced lowercase codeK1A 4B1K1A 4B1Passed
hyphen separator rejectedNoneNonePassed
forbidden letter in third positionNoneNonePassed
Z not allowed firstNoneNonePassed
W allowed after the first positionK1W 4B1K1W 4B1Passed
seven characters without space rejectedNoneNonePassed
five characters rejectedNoneNonePassed

SHA-256 / efed72eebe37599a741807a10ff6734557c6a7af68cd635f0291205c1a1853e3

Verification & scope

A deterministic toy contract over synthetic, obviously fictitious addresses. The rules are stipulated for this model only and make no claim of conformance with any postal authority standard. 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:18.595735+00:00.

Case digest / 16ca6f02cd54695a1db632d4edcd7b52ee5708930e2f0e83eb258c27232a30bf