FA-96011 / Postal address normalization / Open access
Address label line wrapper: the last line is never emitted · case 01
The final words of every label disappear.
ROOT CAUSE
The pending line is not appended after the loop.
VERIFIED REPAIR
Append the pending line after the loop whenever it is non-empty.
Unsuccessful approach: Flushing only when the budget still has room hides the overflow caused by the last line.
Case contract
Input [text, width, max_lines]. Words are whitespace-separated. A word longer than width first flushes the current line, then is emitted in width-sized chunks, the final remainder continuing as an ordinary word. Words join with single spaces while the line length stays <= width. Return {"lines": the first max_lines lines, "overflow": whether more than max_lines lines were needed}.
Why this case matters
Label printers and carrier manifests cap line length and line count; an off-by-one silently truncates part of the address.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
text, width, max_lines = x
lines, cur = [], ''
for w in text.split():
while len(w) > width:
if cur:
lines.append(cur)
cur = ''
lines.append(w[:width])
w = w[width:]
if not cur:
cur = w
elif len(cur) + 1 + len(w) <= width:
cur = cur + ' ' + w
else:
lines.append(cur)
cur = w
return {'lines': lines[:max_lines], 'overflow': len(lines) > max_lines}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exact fit including the separator', ['ATTN ZORBLE', 11, 3], {'lines': ['ATTN ZORBLE'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLET', 11, 3], {'lines': ['ATTN', 'ZORBLET'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETO', 11, 2], {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETO DOCK ZORBLETON', 11, 3], {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVAL', 11, 5], {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False}], ['repeated spaces collapse', ['1 FAKE RD', 11, 2], {'lines': ['1 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLET', 12, 3], {'lines': ['ATTN ZORBLET'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETO', 12, 3], {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETON', 12, 2], {'lines': ['ATTN', 'ZORBLETON'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETON DOCK ZORBLETONV', 12, 3], {'lines': ['ATTN', 'ZORBLETON', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZ', 12, 5], {'lines': ['SUITE', 'ZORBLETONVAL', 'EZORBLETONVA', 'LEZ'], 'overflow': False}], ['repeated spaces collapse', ['2 FAKE RD', 12, 2], {'lines': ['2 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETO', 13, 3], {'lines': ['ATTN ZORBLETO'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETON', 13, 3], {'lines': ['ATTN', 'ZORBLETON'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONV', 13, 2], {'lines': ['ATTN', 'ZORBLETONV'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONV DOCK ZORBLETONVA', 13, 3], {'lines': ['ATTN', 'ZORBLETONV', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZOR', 13, 5], {'lines': ['SUITE', 'ZORBLETONVALE', 'ZORBLETONVALE', 'ZOR'], 'overflow': False}], ['repeated spaces collapse', ['3 FAKE RD', 13, 2], {'lines': ['3 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETON', 14, 3], {'lines': ['ATTN ZORBLETON'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETONV', 14, 3], {'lines': ['ATTN', 'ZORBLETONV'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONVA', 14, 2], {'lines': ['ATTN', 'ZORBLETONVA'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONVA DOCK ZORBLETONVAL', 14, 3], {'lines': ['ATTN', 'ZORBLETONVA', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZORBL', 14, 5], {'lines': ['SUITE', 'ZORBLETONVALEZ', 'ORBLETONVALEZO', 'RBL'], 'overflow': False}], ['repeated spaces collapse', ['4 FAKE RD', 14, 2], {'lines': ['4 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETONV', 15, 3], {'lines': ['ATTN ZORBLETONV'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETONVA', 15, 3], {'lines': ['ATTN', 'ZORBLETONVA'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONVAL', 15, 2], {'lines': ['ATTN', 'ZORBLETONVAL'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONVAL DOCK ZORBLETONVALE', 15, 3], {'lines': ['ATTN', 'ZORBLETONVAL', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZORBLET', 15, 5], {'lines': ['SUITE', 'ZORBLETONVALEZO', 'RBLETONVALEZORB', 'LET'], 'overflow': False}], ['repeated spaces collapse', ['5 FAKE RD', 15, 2], {'lines': ['5 FAKE RD'], 'overflow': False}]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| exact fit including the separator | {'lines': [], 'overflow': False} | {'lines': ['ATTN ZORBLE'], 'overflow': False} | Failed |
| one character over once the separator counts | {'lines': ['ATTN'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLET'], 'overflow': False} | Failed |
| exactly the line budget | {'lines': ['ATTN'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False} | Failed |
| more lines than the budget | {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': True} | Failed |
| overlong word after a short word | {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON'], 'overflow': False} | {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False} | Failed |
| repeated spaces collapse | {'lines': [], 'overflow': False} | {'lines': ['1 FAKE RD'], 'overflow': False} | Failed |
SHA-256 / 6dfadaa262e3963ee7cf74dbbbb8c1751086b9ae55307453f0d30bb36c15c03c
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
text, width, max_lines = x
lines, cur = [], ''
for w in text.split():
while len(w) > width:
if cur:
lines.append(cur)
cur = ''
lines.append(w[:width])
w = w[width:]
if not cur:
cur = w
elif len(cur) + 1 + len(w) <= width:
cur = cur + ' ' + w
else:
lines.append(cur)
cur = w
if cur and len(lines) < max_lines:
lines.append(cur)
return {'lines': lines[:max_lines], 'overflow': len(lines) > max_lines}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exact fit including the separator', ['ATTN ZORBLE', 11, 3], {'lines': ['ATTN ZORBLE'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLET', 11, 3], {'lines': ['ATTN', 'ZORBLET'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETO', 11, 2], {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETO DOCK ZORBLETON', 11, 3], {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVAL', 11, 5], {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False}], ['repeated spaces collapse', ['1 FAKE RD', 11, 2], {'lines': ['1 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLET', 12, 3], {'lines': ['ATTN ZORBLET'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETO', 12, 3], {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETON', 12, 2], {'lines': ['ATTN', 'ZORBLETON'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETON DOCK ZORBLETONV', 12, 3], {'lines': ['ATTN', 'ZORBLETON', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZ', 12, 5], {'lines': ['SUITE', 'ZORBLETONVAL', 'EZORBLETONVA', 'LEZ'], 'overflow': False}], ['repeated spaces collapse', ['2 FAKE RD', 12, 2], {'lines': ['2 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETO', 13, 3], {'lines': ['ATTN ZORBLETO'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETON', 13, 3], {'lines': ['ATTN', 'ZORBLETON'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONV', 13, 2], {'lines': ['ATTN', 'ZORBLETONV'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONV DOCK ZORBLETONVA', 13, 3], {'lines': ['ATTN', 'ZORBLETONV', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZOR', 13, 5], {'lines': ['SUITE', 'ZORBLETONVALE', 'ZORBLETONVALE', 'ZOR'], 'overflow': False}], ['repeated spaces collapse', ['3 FAKE RD', 13, 2], {'lines': ['3 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETON', 14, 3], {'lines': ['ATTN ZORBLETON'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETONV', 14, 3], {'lines': ['ATTN', 'ZORBLETONV'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONVA', 14, 2], {'lines': ['ATTN', 'ZORBLETONVA'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONVA DOCK ZORBLETONVAL', 14, 3], {'lines': ['ATTN', 'ZORBLETONVA', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZORBL', 14, 5], {'lines': ['SUITE', 'ZORBLETONVALEZ', 'ORBLETONVALEZO', 'RBL'], 'overflow': False}], ['repeated spaces collapse', ['4 FAKE RD', 14, 2], {'lines': ['4 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETONV', 15, 3], {'lines': ['ATTN ZORBLETONV'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETONVA', 15, 3], {'lines': ['ATTN', 'ZORBLETONVA'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONVAL', 15, 2], {'lines': ['ATTN', 'ZORBLETONVAL'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONVAL DOCK ZORBLETONVALE', 15, 3], {'lines': ['ATTN', 'ZORBLETONVAL', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZORBLET', 15, 5], {'lines': ['SUITE', 'ZORBLETONVALEZO', 'RBLETONVALEZORB', 'LET'], 'overflow': False}], ['repeated spaces collapse', ['5 FAKE RD', 15, 2], {'lines': ['5 FAKE RD'], 'overflow': False}]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| exact fit including the separator | {'lines': ['ATTN ZORBLE'], 'overflow': False} | {'lines': ['ATTN ZORBLE'], 'overflow': False} | Passed |
| one character over once the separator counts | {'lines': ['ATTN', 'ZORBLET'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLET'], 'overflow': False} | Passed |
| exactly the line budget | {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False} | Passed |
| more lines than the budget | {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': True} | Failed |
| overlong word after a short word | {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False} | {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False} | Passed |
| repeated spaces collapse | {'lines': ['1 FAKE RD'], 'overflow': False} | {'lines': ['1 FAKE RD'], 'overflow': False} | Passed |
SHA-256 / 9d433d61a8d1ff70f14a576539b7d6577bcfaba1936041a010ee1d5d51521bf9
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
text, width, max_lines = x
lines, cur = [], ''
for w in text.split():
while len(w) > width:
if cur:
lines.append(cur)
cur = ''
lines.append(w[:width])
w = w[width:]
if not cur:
cur = w
elif len(cur) + 1 + len(w) <= width:
cur = cur + ' ' + w
else:
lines.append(cur)
cur = w
if cur:
lines.append(cur)
return {'lines': lines[:max_lines], 'overflow': len(lines) > max_lines}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['exact fit including the separator', ['ATTN ZORBLE', 11, 3], {'lines': ['ATTN ZORBLE'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLET', 11, 3], {'lines': ['ATTN', 'ZORBLET'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETO', 11, 2], {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETO DOCK ZORBLETON', 11, 3], {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVAL', 11, 5], {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False}], ['repeated spaces collapse', ['1 FAKE RD', 11, 2], {'lines': ['1 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLET', 12, 3], {'lines': ['ATTN ZORBLET'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETO', 12, 3], {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETON', 12, 2], {'lines': ['ATTN', 'ZORBLETON'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETON DOCK ZORBLETONV', 12, 3], {'lines': ['ATTN', 'ZORBLETON', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZ', 12, 5], {'lines': ['SUITE', 'ZORBLETONVAL', 'EZORBLETONVA', 'LEZ'], 'overflow': False}], ['repeated spaces collapse', ['2 FAKE RD', 12, 2], {'lines': ['2 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETO', 13, 3], {'lines': ['ATTN ZORBLETO'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETON', 13, 3], {'lines': ['ATTN', 'ZORBLETON'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONV', 13, 2], {'lines': ['ATTN', 'ZORBLETONV'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONV DOCK ZORBLETONVA', 13, 3], {'lines': ['ATTN', 'ZORBLETONV', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZOR', 13, 5], {'lines': ['SUITE', 'ZORBLETONVALE', 'ZORBLETONVALE', 'ZOR'], 'overflow': False}], ['repeated spaces collapse', ['3 FAKE RD', 13, 2], {'lines': ['3 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETON', 14, 3], {'lines': ['ATTN ZORBLETON'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETONV', 14, 3], {'lines': ['ATTN', 'ZORBLETONV'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONVA', 14, 2], {'lines': ['ATTN', 'ZORBLETONVA'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONVA DOCK ZORBLETONVAL', 14, 3], {'lines': ['ATTN', 'ZORBLETONVA', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZORBL', 14, 5], {'lines': ['SUITE', 'ZORBLETONVALEZ', 'ORBLETONVALEZO', 'RBL'], 'overflow': False}], ['repeated spaces collapse', ['4 FAKE RD', 14, 2], {'lines': ['4 FAKE RD'], 'overflow': False}]], [['exact fit including the separator', ['ATTN ZORBLETONV', 15, 3], {'lines': ['ATTN ZORBLETONV'], 'overflow': False}], ['one character over once the separator counts', ['ATTN ZORBLETONVA', 15, 3], {'lines': ['ATTN', 'ZORBLETONVA'], 'overflow': False}], ['exactly the line budget', ['ATTN ZORBLETONVAL', 15, 2], {'lines': ['ATTN', 'ZORBLETONVAL'], 'overflow': False}], ['more lines than the budget', ['ATTN ZORBLETONVAL DOCK ZORBLETONVALE', 15, 3], {'lines': ['ATTN', 'ZORBLETONVAL', 'DOCK'], 'overflow': True}], ['overlong word after a short word', ['SUITE ZORBLETONVALEZORBLETONVALEZORBLET', 15, 5], {'lines': ['SUITE', 'ZORBLETONVALEZO', 'RBLETONVALEZORB', 'LET'], 'overflow': False}], ['repeated spaces collapse', ['5 FAKE RD', 15, 2], {'lines': ['5 FAKE RD'], 'overflow': False}]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| exact fit including the separator | {'lines': ['ATTN ZORBLE'], 'overflow': False} | {'lines': ['ATTN ZORBLE'], 'overflow': False} | Passed |
| one character over once the separator counts | {'lines': ['ATTN', 'ZORBLET'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLET'], 'overflow': False} | Passed |
| exactly the line budget | {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False} | Passed |
| more lines than the budget | {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': True} | {'lines': ['ATTN', 'ZORBLETO', 'DOCK'], 'overflow': True} | Passed |
| overlong word after a short word | {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False} | {'lines': ['SUITE', 'ZORBLETONVA', 'LEZORBLETON', 'VAL'], 'overflow': False} | Passed |
| repeated spaces collapse | {'lines': ['1 FAKE RD'], 'overflow': False} | {'lines': ['1 FAKE RD'], 'overflow': False} | Passed |
SHA-256 / 00140be3251941f06c3f328e5c46e4293f1547ba400ffaed34e27ba530d10916
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.841024+00:00.
Case digest / b8334723c0d89be52f51e257fe2e750291ca582420010171fc9a4c88e4634c2e