FA-80081 / Typography line breaking / Open access
Justified interword spacing: maximum space with remainder · case 01
Lines whose widest gap exceeds the maximum stay justified.
ROOT CAUSE
The loose check ignores the extra remainder unit on the widest gaps.
THE FAILURE
The loose check ignores the extra remainder unit on the widest gaps.
Unsuccessful approach: Adding the whole remainder overstates the widest gap.
Case contract
Input [word widths, target width, is_last, natural space, min space, max space]. Last lines and single-word lines are set ragged with natural spaces. Otherwise distribute target-sum(words) over the gaps: equal share with the remainder units added to the rightmost gaps; a share below min space is ["overfull"]; if any gap would exceed max space fall back to ragged. Return word x positions.
Why this case matters
Line breaking decides where paragraphs wrap on screen and in print; a wrong decision point shifts every following line.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
words, target, is_last, sp, lo, hi = x
n = len(words)
gaps = n - 1
def natural():
pos, xx = [], 0
for w in words:
pos.append(xx)
xx += w + sp
return pos
if is_last or gaps == 0:
return natural()
space = target - sum(words)
per, rem = divmod(space, gaps)
if per < lo:
return ['overfull']
if per > hi:
return natural()
pos, xx = [], 0
for k, w in enumerate(words):
pos.append(xx)
if k < gaps:
xx += w + per + (1 if k >= gaps - rem else 0)
return pos
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: maximum space with remainder', [[3, 5, 4, 9, 8, 2], 67, False, 3, 3, 7], [0, 6, 14, 21, 33, 44]), ('regression: maximum space with remainder', [[4, 3, 7, 3, 7], 42, False, 2, 2, 4], [0, 6, 11, 20, 25]), ('partial-repair probe', [[7, 2, 8, 7, 9], 55, False, 3, 3, 6], [0, 12, 19, 33, 46]), ('partial-repair probe', [[4, 5, 8, 9, 5, 6], 55, False, 3, 2, 4], [0, 7, 15, 27, 40, 49]), ('last line ragged', [[3, 4, 5], 20, True, 2, 1, 6], [0, 5, 11]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[2, 9, 6, 5, 6, 5], 53, True, 3, 3, 4], [0, 5, 17, 26, 34, 43]), ('control layout', [[9], 9, False, 3, 3, 6], [0])], [('regression: maximum space with remainder', [[7, 3, 4, 2, 9], 51, False, 3, 3, 6], [0, 10, 16, 23, 28]), ('regression: maximum space with remainder', [[4, 3, 7, 3, 7], 42, False, 2, 2, 4], [0, 6, 11, 20, 25]), ('partial-repair probe', [[8, 9, 2, 3, 5], 46, False, 2, 1, 5], [0, 12, 26, 33, 41]), ('partial-repair probe', [[7, 2, 8, 7, 9], 55, False, 3, 3, 6], [0, 12, 19, 33, 46]), ('single word line', [[7], 20, False, 2, 1, 4], [0]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[8, 7, 2, 8, 4, 4], 56, False, 3, 2, 7], [0, 12, 23, 30, 43, 52]), ('control layout', [[8, 9, 3, 7, 9, 8], 51, False, 2, 1, 5], [0, 9, 19, 23, 32, 43])], [('regression: maximum space with remainder', [[3, 5, 4, 9, 8, 2], 67, False, 3, 3, 7], [0, 6, 14, 21, 33, 44]), ('regression: maximum space with remainder', [[9, 8, 7, 8, 9], 59, False, 2, 1, 4], [0, 11, 21, 30, 40]), ('partial-repair probe', [[3, 7, 7, 8, 9], 41, False, 2, 1, 3], [0, 4, 13, 22, 32]), ('partial-repair probe', [[6, 8, 6, 8, 7], 49, False, 2, 2, 4], [0, 9, 20, 30, 42]), ('single word line', [[7], 20, False, 2, 1, 4], [0]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[5, 5, 5, 3, 7], 32, False, 3, 2, 6], ['overfull']), ('control layout', [[2, 2, 5, 5, 2], 24, False, 3, 2, 7], [0, 4, 8, 15, 22])], [('regression: maximum space with remainder', [[8, 7, 6, 6, 6], 52, False, 3, 2, 4], [0, 11, 21, 30, 39]), ('regression: maximum space with remainder', [[7, 3, 4, 2, 9], 51, False, 3, 3, 6], [0, 10, 16, 23, 28]), ('partial-repair probe', [[8, 9, 2, 3, 5], 46, False, 2, 1, 5], [0, 12, 26, 33, 41]), ('partial-repair probe', [[6, 8, 6, 8, 7], 49, False, 2, 2, 4], [0, 9, 20, 30, 42]), ('single word line', [[7], 20, False, 2, 1, 4], [0]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[7, 7, 7, 6, 2], 37, False, 3, 1, 5], [0, 9, 18, 27, 35]), ('control layout', [[5, 5, 5, 3, 7], 32, False, 3, 2, 6], ['overfull'])], [('regression: maximum space with remainder', [[6, 3, 4, 3], 30, False, 2, 1, 4], [0, 8, 13, 19]), ('regression: maximum space with remainder', [[8, 8, 6, 7], 43, False, 3, 1, 4], [0, 11, 22, 31]), ('partial-repair probe', [[2, 4, 9, 5], 31, False, 3, 2, 4], [0, 5, 13, 26]), ('partial-repair probe', [[2, 2, 3, 9], 30, False, 3, 2, 5], [0, 6, 13, 21]), ('remainder goes to right gaps', [[3, 4, 5, 2], 20, False, 2, 1, 4], [0, 5, 11, 18]), ('last line ragged', [[3, 4, 5], 20, True, 2, 1, 6], [0, 5, 11]), ('control layout', [[7, 7, 7, 6, 2], 37, False, 3, 1, 5], [0, 9, 18, 27, 35]), ('control layout', [[2, 7, 9, 4, 8], 39, False, 3, 3, 7], ['overfull'])]]
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 |
|---|---|---|---|
| regression: maximum space with remainder | [0, 10, 22, 33, 49, 65] | [0, 6, 14, 21, 33, 44] | Failed |
| regression: maximum space with remainder | [0, 8, 15, 27, 35] | [0, 6, 11, 20, 25] | Failed |
| partial-repair probe | [0, 12, 19, 33, 46] | [0, 12, 19, 33, 46] | Passed |
| partial-repair probe | [0, 7, 15, 27, 40, 49] | [0, 7, 15, 27, 40, 49] | Passed |
| last line ragged | [0, 5, 11] | [0, 5, 11] | Passed |
| exactly minimum share | [0, 4, 8] | [0, 4, 8] | Passed |
| control layout | [0, 5, 17, 26, 34, 43] | [0, 5, 17, 26, 34, 43] | Passed |
| control layout | [0] | [0] | Passed |
SHA-256 / 90632a4bfe500003236586ebb32559d79773f2e59c5a3857f60ae515c0d2a4a5
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
words, target, is_last, sp, lo, hi = x
n = len(words)
gaps = n - 1
def natural():
pos, xx = [], 0
for w in words:
pos.append(xx)
xx += w + sp
return pos
if is_last or gaps == 0:
return natural()
space = target - sum(words)
per, rem = divmod(space, gaps)
if per < lo:
return ['overfull']
if per + rem > hi:
return natural()
pos, xx = [], 0
for k, w in enumerate(words):
pos.append(xx)
if k < gaps:
xx += w + per + (1 if k >= gaps - rem else 0)
return pos
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: maximum space with remainder', [[3, 5, 4, 9, 8, 2], 67, False, 3, 3, 7], [0, 6, 14, 21, 33, 44]), ('regression: maximum space with remainder', [[4, 3, 7, 3, 7], 42, False, 2, 2, 4], [0, 6, 11, 20, 25]), ('partial-repair probe', [[7, 2, 8, 7, 9], 55, False, 3, 3, 6], [0, 12, 19, 33, 46]), ('partial-repair probe', [[4, 5, 8, 9, 5, 6], 55, False, 3, 2, 4], [0, 7, 15, 27, 40, 49]), ('last line ragged', [[3, 4, 5], 20, True, 2, 1, 6], [0, 5, 11]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[2, 9, 6, 5, 6, 5], 53, True, 3, 3, 4], [0, 5, 17, 26, 34, 43]), ('control layout', [[9], 9, False, 3, 3, 6], [0])], [('regression: maximum space with remainder', [[7, 3, 4, 2, 9], 51, False, 3, 3, 6], [0, 10, 16, 23, 28]), ('regression: maximum space with remainder', [[4, 3, 7, 3, 7], 42, False, 2, 2, 4], [0, 6, 11, 20, 25]), ('partial-repair probe', [[8, 9, 2, 3, 5], 46, False, 2, 1, 5], [0, 12, 26, 33, 41]), ('partial-repair probe', [[7, 2, 8, 7, 9], 55, False, 3, 3, 6], [0, 12, 19, 33, 46]), ('single word line', [[7], 20, False, 2, 1, 4], [0]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[8, 7, 2, 8, 4, 4], 56, False, 3, 2, 7], [0, 12, 23, 30, 43, 52]), ('control layout', [[8, 9, 3, 7, 9, 8], 51, False, 2, 1, 5], [0, 9, 19, 23, 32, 43])], [('regression: maximum space with remainder', [[3, 5, 4, 9, 8, 2], 67, False, 3, 3, 7], [0, 6, 14, 21, 33, 44]), ('regression: maximum space with remainder', [[9, 8, 7, 8, 9], 59, False, 2, 1, 4], [0, 11, 21, 30, 40]), ('partial-repair probe', [[3, 7, 7, 8, 9], 41, False, 2, 1, 3], [0, 4, 13, 22, 32]), ('partial-repair probe', [[6, 8, 6, 8, 7], 49, False, 2, 2, 4], [0, 9, 20, 30, 42]), ('single word line', [[7], 20, False, 2, 1, 4], [0]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[5, 5, 5, 3, 7], 32, False, 3, 2, 6], ['overfull']), ('control layout', [[2, 2, 5, 5, 2], 24, False, 3, 2, 7], [0, 4, 8, 15, 22])], [('regression: maximum space with remainder', [[8, 7, 6, 6, 6], 52, False, 3, 2, 4], [0, 11, 21, 30, 39]), ('regression: maximum space with remainder', [[7, 3, 4, 2, 9], 51, False, 3, 3, 6], [0, 10, 16, 23, 28]), ('partial-repair probe', [[8, 9, 2, 3, 5], 46, False, 2, 1, 5], [0, 12, 26, 33, 41]), ('partial-repair probe', [[6, 8, 6, 8, 7], 49, False, 2, 2, 4], [0, 9, 20, 30, 42]), ('single word line', [[7], 20, False, 2, 1, 4], [0]), ('exactly minimum share', [[3, 3, 3], 11, False, 2, 1, 4], [0, 4, 8]), ('control layout', [[7, 7, 7, 6, 2], 37, False, 3, 1, 5], [0, 9, 18, 27, 35]), ('control layout', [[5, 5, 5, 3, 7], 32, False, 3, 2, 6], ['overfull'])], [('regression: maximum space with remainder', [[6, 3, 4, 3], 30, False, 2, 1, 4], [0, 8, 13, 19]), ('regression: maximum space with remainder', [[8, 8, 6, 7], 43, False, 3, 1, 4], [0, 11, 22, 31]), ('partial-repair probe', [[2, 4, 9, 5], 31, False, 3, 2, 4], [0, 5, 13, 26]), ('partial-repair probe', [[2, 2, 3, 9], 30, False, 3, 2, 5], [0, 6, 13, 21]), ('remainder goes to right gaps', [[3, 4, 5, 2], 20, False, 2, 1, 4], [0, 5, 11, 18]), ('last line ragged', [[3, 4, 5], 20, True, 2, 1, 6], [0, 5, 11]), ('control layout', [[7, 7, 7, 6, 2], 37, False, 3, 1, 5], [0, 9, 18, 27, 35]), ('control layout', [[2, 7, 9, 4, 8], 39, False, 3, 3, 7], ['overfull'])]]
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 |
|---|---|---|---|
| regression: maximum space with remainder | [0, 6, 14, 21, 33, 44] | [0, 6, 14, 21, 33, 44] | Passed |
| regression: maximum space with remainder | [0, 6, 11, 20, 25] | [0, 6, 11, 20, 25] | Passed |
| partial-repair probe | [0, 10, 15, 26, 36] | [0, 12, 19, 33, 46] | Failed |
| partial-repair probe | [0, 7, 15, 26, 38, 46] | [0, 7, 15, 27, 40, 49] | Failed |
| last line ragged | [0, 5, 11] | [0, 5, 11] | Passed |
| exactly minimum share | [0, 4, 8] | [0, 4, 8] | Passed |
| control layout | [0, 5, 17, 26, 34, 43] | [0, 5, 17, 26, 34, 43] | Passed |
| control layout | [0] | [0] | Passed |
SHA-256 / 7333b46f5ca98af88e56f64138506dbf6ea6c47f6853adb7dcd843321ba8a949
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic toy typesetting model with integer widths and a stipulated rule set; it does not claim conformance to any engine. 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:49:50.512273+00:00.
Case digest / 24a3de9fbfe0455ce877c85079fe56c9d3d167fc2a45cab00691d9e04b35c411