FA-96006 / Postal address normalization / Open access
Address label line wrapper: lines beyond the budget are returned · case 01
A two-line label receives three lines.
ROOT CAUSE
The full line list is returned instead of the first max_lines.
VERIFIED REPAIR
Return only the first max_lines lines and signal the rest through overflow.
Unsuccessful approach: Truncating to max_lines - 1 lines throws away a line that fits.
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
if cur:
lines.append(cur)
return {'lines': 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', 'ZORBLETON'], 'overflow': True} | {'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 / 610efc6124176627501ea9945846d28bff01c04af7cd6f551a8461347a97f02b
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:
lines.append(cur)
return {'lines': lines[:max_lines - 1], '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'], 'overflow': False} | {'lines': ['ATTN', 'ZORBLETO'], 'overflow': False} | Failed |
| more lines than the budget | {'lines': ['ATTN', 'ZORBLETO'], 'overflow': True} | {'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 / 16aa1ea14739556fbac84ab4b4e1fb72321836f03254793444bbae10afef1aef
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.816587+00:00.
Case digest / df8333a59dd53e9ccdc69324fbc6f44289d7b80592f5296e861b8457c5d1452d