FA-79971 / Typography line breaking / Open access
Consecutive hyphen limit: whole-word fit test · case 01
Words that exactly fill the measure are pushed to the next line.
ROOT CAUSE
The whole-word fit uses a strict < width comparison.
VERIFIED REPAIR
Accept a word when the resulting line width equals the measure.
Unsuccessful approach: Allowing width + 1 overfills the measure.
Case contract
Input [words as syllable lists, width, limit]. Greedy fill with 1-unit spaces and characters. A word that does not fit may be split at the latest syllable boundary whose head plus "-" fits, only if fewer than limit immediately preceding lines ended in a hyphen and the word is not the paragraph's last word. A line ended without hyphen resets the streak; a word too long for an empty line is set alone. Return the lines.
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, width, limit = x
queue = [list(w) for w in words]
lines = []
cur = ''
streak = 0
k = 0
while k < len(queue):
syl = queue[k]
token = ''.join(syl)
need = len(token) if cur == '' else len(cur) + 1 + len(token)
if need < width:
cur = token if cur == '' else cur + ' ' + token
k += 1
continue
split = None
if streak < limit and k < len(queue) - 1:
for cut in range(len(syl) - 1, 0, -1):
head = ''.join(syl[:cut]) + '-'
room = len(head) if cur == '' else len(cur) + len(head) + 1
if room <= width:
split = cut
break
if split is not None:
head = ''.join(syl[:split]) + '-'
lines.append(head if cur == '' else cur + ' ' + head)
queue[k] = syl[split:]
cur = ''
streak += 1
elif cur == '':
lines.append(token)
k += 1
streak = 0
else:
lines.append(cur)
cur, streak = '', 0
if cur:
lines.append(cur)
return lines
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: whole-word fit test', [[['lead', 'ing'], ['a'], ['jus', 'ti', 'fied'], ['a'], ['a'], ['pa', 'ra', 'graph'], ['set', 'ting'], ['jus', 'ti', 'fied']], 6, 1], ['lead-', 'ing a', 'justi-', 'fied a', 'a pa-', 'ragraph', 'set-', 'ting', 'justified']), ('regression: whole-word fit test', [[['lead', 'ing'], ['kern', 'ing'], ['com', 'po', 'si', 'tion'], ['text'], ['lead', 'ing'], ['kern', 'ing'], ['hy', 'phen', 'a', 'tion'], ['hy', 'phen', 'a', 'tion'], ['a'], ['text'], ['pa', 'ra', 'graph']], 14, 1], ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph']), ('partial-repair probe', [[['break', 'ing'], ['kern', 'ing'], ['set', 'ting'], ['break', 'ing'], ['hy', 'phen', 'a', 'tion'], ['lead', 'ing'], ['to'], ['line'], ['jus', 'ti', 'fied']], 12, 1], ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified']), ('regression: whole-word fit test', [[['to'], ['line'], ['com', 'po', 'si', 'tion'], ['mar', 'gin'], ['mar', 'gin'], ['type'], ['kern', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['col', 'umn'], ['line'], ['com', 'po', 'si', 'tion'], ['to']], 14, 1], ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition to']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'a', 'tion'], ['a'], ['hy', 'phen', 'a', 'tion'], ['break', 'ing']], 9, 3], ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking']), ('control layout', [[['text'], ['line'], ['hy', 'phen', 'a', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['set', 'ting']], 14, 2], ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'])], [('regression: whole-word fit test', [[['pa', 'ra', 'graph'], ['of'], ['type'], ['lead', 'ing'], ['col', 'umn'], ['pa', 'ra', 'graph'], ['lead', 'ing'], ['kern', 'ing'], ['set', 'ting']], 7, 3], ['para-', 'graph', 'of type', 'leading', 'column', 'para-', 'graph', 'leading', 'kerning', 'setting']), ('regression: whole-word fit test', [[['hy', 'phen', 'a', 'tion'], ['lead', 'ing'], ['to'], ['in', 'ter', 'na', 'tion', 'al'], ['a'], ['set', 'ting'], ['col', 'umn']], 13, 3], ['hyphenation', 'leading to', 'international', 'a setting', 'column']), ('partial-repair probe', [[['jus', 'ti', 'fied'], ['text'], ['of'], ['in', 'ter', 'na', 'tion', 'al'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['mar', 'gin'], ['of'], ['break', 'ing'], ['line']], 12, 1], ['justified', 'text of in-', 'ternational', 'internation-', 'al margin', 'margin of', 'breaking', 'line']), ('partial-repair probe', [[['lead', 'ing'], ['pa', 'ra', 'graph'], ['to'], ['mar', 'gin'], ['line'], ['jus', 'ti', 'fied']], 14, 3], ['leading para-', 'graph to mar-', 'gin line', 'justified']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('control layout', [[['jus', 'ti', 'fied'], ['col', 'umn'], ['com', 'po', 'si', 'tion'], ['pa', 'ra', 'graph'], ['to'], ['jus', 'ti', 'fied'], ['mar', 'gin']], 12, 2], ['justified', 'column com-', 'position pa-', 'ragraph to', 'justified', 'margin']), ('control layout', [[['a'], ['kern', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['set', 'ting'], ['pa', 'ra', 'graph']], 11, 1], ['a kerning', 'interna-', 'tional', 'setting', 'paragraph'])], [('regression: whole-word fit test', [[['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['break', 'ing'], ['mar', 'gin'], ['line'], ['set', 'ting'], ['in', 'ter', 'na', 'tion', 'al']], 6, 1], ['compo-', 'sition', 'inter-', 'national', 'margin', 'break-', 'ing', 'margin', 'line', 'set-', 'ting', 'international']), ('regression: whole-word fit test', [[['col', 'umn'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing'], ['type'], ['lead', 'ing'], ['lead', 'ing'], ['text'], ['text'], ['pa', 'ra', 'graph']], 6, 1], ['column', 'inter-', 'national', 'kern-', 'ing', 'type', 'lead-', 'ing', 'lead-', 'ing', 'text', 'text', 'paragraph']), ('regression: whole-word fit test', [[['line'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['pa', 'ra', 'graph'], ['a'], ['a']], 7, 2], ['line', 'inter-', 'nation-', 'al', 'margin', 'para-', 'graph a', 'a']), ('regression: whole-word fit test', [[['break', 'ing'], ['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['break', 'ing'], ['text'], ['set', 'ting'], ['lead', 'ing']], 11, 3], ['breaking', 'composition', 'interna-', 'tional', 'breaking', 'text set-', 'ting', 'leading']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['line'], ['pa', 'ra', 'graph'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['pa', 'ra', 'graph'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing']], 6, 1], ['line', 'para-', 'graph', 'compo-', 'sition', 'hy-', 'phenation', 'para-', 'graph', 'inter-', 'national', 'kerning']), ('control layout', [[['a'], ['mar', 'gin'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing'], ['col', 'umn'], ['col', 'umn'], ['lead', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['to'], ['break', 'ing'], ['jus', 'ti', 'fied']], 12, 1], ['a margin in-', 'ternational', 'kerning col-', 'umn column', 'leading in-', 'ternational', 'to breaking', 'justified'])], [('regression: whole-word fit test', [[['set', 'ting'], ['of'], ['mar', 'gin'], ['kern', 'ing'], ['set', 'ting'], ['col', 'umn'], ['line'], ['set', 'ting'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin']], 11, 2], ['setting of', 'margin', 'kerning', 'setting', 'column line', 'setting a', 'interna-', 'tional', 'margin']), ('regression: whole-word fit test', [[['type'], ['col', 'umn'], ['lead', 'ing'], ['lead', 'ing'], ['of'], ['mar', 'gin'], ['in', 'ter', 'na', 'tion', 'al']], 10, 1], ['type col-', 'umn', 'leading', 'leading of', 'margin', 'international']), ('regression: whole-word fit test', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['type'], ['hy', 'phen', 'a', 'tion'], ['col', 'umn'], ['of'], ['pa', 'ra', 'graph'], ['hy', 'phen', 'a', 'tion']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'type', 'hyphen-', 'ation', 'column', 'of pa-', 'ragraph', 'hyphenation']), ('regression: whole-word fit test', [[['mar', 'gin'], ['pa', 'ra', 'graph'], ['lead', 'ing'], ['of'], ['type'], ['col', 'umn'], ['lead', 'ing']], 9, 3], ['margin', 'paragraph', 'leading', 'of type', 'column', 'leading']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['pa', 'ra', 'graph'], ['to'], ['jus', 'ti', 'fied'], ['lead', 'ing'], ['to'], ['col', 'umn']], 13, 2], ['paragraph to', 'justified', 'leading to', 'column']), ('control layout', [[['set', 'ting'], ['to'], ['break', 'ing'], ['com', 'po', 'si', 'tion'], ['lead', 'ing'], ['line'], ['jus', 'ti', 'fied'], ['a'], ['break', 'ing'], ['a'], ['line']], 13, 2], ['setting to', 'breaking com-', 'position', 'leading line', 'justified a', 'breaking a', 'line'])], [('regression: whole-word fit test', [[['line'], ['com', 'po', 'si', 'tion'], ['of'], ['to'], ['in', 'ter', 'na', 'tion', 'al'], ['lead', 'ing'], ['pa', 'ra', 'graph'], ['hy', 'phen', 'a', 'tion'], ['set', 'ting']], 10, 3], ['line com-', 'position', 'of to in-', 'ternation-', 'al leading', 'paragraph', 'hyphena-', 'tion', 'setting']), ('regression: whole-word fit test', [[['lead', 'ing'], ['kern', 'ing'], ['hy', 'phen', 'a', 'tion'], ['kern', 'ing'], ['col', 'umn'], ['com', 'po', 'si', 'tion'], ['lead', 'ing'], ['text'], ['of'], ['jus', 'ti', 'fied'], ['type'], ['kern', 'ing']], 12, 1], ['leading', 'kerning hy-', 'phenation', 'kerning col-', 'umn', 'composition', 'leading text', 'of justified', 'type kerning']), ('partial-repair probe', [[['hy', 'phen', 'a', 'tion'], ['type'], ['mar', 'gin'], ['a'], ['jus', 'ti', 'fied'], ['col', 'umn'], ['break', 'ing'], ['com', 'po', 'si', 'tion'], ['line']], 12, 2], ['hyphenation', 'type margin', 'a justified', 'column', 'breaking', 'composition', 'line']), ('partial-repair probe', [[['type'], ['mar', 'gin'], ['of'], ['a'], ['col', 'umn']], 8, 3], ['type', 'margin', 'of a', 'column']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['col', 'umn'], ['kern', 'ing'], ['text'], ['col', 'umn'], ['line'], ['line'], ['a']], 12, 2], ['column kern-', 'ing text', 'column line', 'line a']), ('control layout', [[['of'], ['break', 'ing'], ['type'], ['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'a', 'tion'], ['break', 'ing']], 12, 3], ['of breaking', 'type compo-', 'sition in-', 'ternational', 'hyphenation', 'breaking'])]]
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: whole-word fit test | ['lead-', 'ing a', 'justi-', 'fied', 'a a', 'para-', 'graph', 'set-', 'ting', 'justified'] | ['lead-', 'ing a', 'justi-', 'fied a', 'a pa-', 'ragraph', 'set-', 'ting', 'justified'] | Failed |
| regression: whole-word fit test | ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text', 'paragraph'] | ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph'] | Failed |
| partial-repair probe | ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified'] | ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified'] | Passed |
| regression: whole-word fit test | ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition', 'to'] | ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition to'] | Failed |
| ladder of three hyphenated lines | ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text'] | ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text'] | Passed |
| last word never hyphenated | ['a', 'composition'] | ['a', 'composition'] | Passed |
| control layout | ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking'] | ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking'] | Passed |
| control layout | ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'] | ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'] | Passed |
SHA-256 / e244e15e7454c2fb755300eb9468d316174afb7c0c3105dd24e5fa26bc9eb5dd
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
words, width, limit = x
queue = [list(w) for w in words]
lines = []
cur = ''
streak = 0
k = 0
while k < len(queue):
syl = queue[k]
token = ''.join(syl)
need = len(token) if cur == '' else len(cur) + 1 + len(token)
if need <= width + 1:
cur = token if cur == '' else cur + ' ' + token
k += 1
continue
split = None
if streak < limit and k < len(queue) - 1:
for cut in range(len(syl) - 1, 0, -1):
head = ''.join(syl[:cut]) + '-'
room = len(head) if cur == '' else len(cur) + len(head) + 1
if room <= width:
split = cut
break
if split is not None:
head = ''.join(syl[:split]) + '-'
lines.append(head if cur == '' else cur + ' ' + head)
queue[k] = syl[split:]
cur = ''
streak += 1
elif cur == '':
lines.append(token)
k += 1
streak = 0
else:
lines.append(cur)
cur, streak = '', 0
if cur:
lines.append(cur)
return lines
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: whole-word fit test', [[['lead', 'ing'], ['a'], ['jus', 'ti', 'fied'], ['a'], ['a'], ['pa', 'ra', 'graph'], ['set', 'ting'], ['jus', 'ti', 'fied']], 6, 1], ['lead-', 'ing a', 'justi-', 'fied a', 'a pa-', 'ragraph', 'set-', 'ting', 'justified']), ('regression: whole-word fit test', [[['lead', 'ing'], ['kern', 'ing'], ['com', 'po', 'si', 'tion'], ['text'], ['lead', 'ing'], ['kern', 'ing'], ['hy', 'phen', 'a', 'tion'], ['hy', 'phen', 'a', 'tion'], ['a'], ['text'], ['pa', 'ra', 'graph']], 14, 1], ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph']), ('partial-repair probe', [[['break', 'ing'], ['kern', 'ing'], ['set', 'ting'], ['break', 'ing'], ['hy', 'phen', 'a', 'tion'], ['lead', 'ing'], ['to'], ['line'], ['jus', 'ti', 'fied']], 12, 1], ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified']), ('regression: whole-word fit test', [[['to'], ['line'], ['com', 'po', 'si', 'tion'], ['mar', 'gin'], ['mar', 'gin'], ['type'], ['kern', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['col', 'umn'], ['line'], ['com', 'po', 'si', 'tion'], ['to']], 14, 1], ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition to']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'a', 'tion'], ['a'], ['hy', 'phen', 'a', 'tion'], ['break', 'ing']], 9, 3], ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking']), ('control layout', [[['text'], ['line'], ['hy', 'phen', 'a', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['set', 'ting']], 14, 2], ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'])], [('regression: whole-word fit test', [[['pa', 'ra', 'graph'], ['of'], ['type'], ['lead', 'ing'], ['col', 'umn'], ['pa', 'ra', 'graph'], ['lead', 'ing'], ['kern', 'ing'], ['set', 'ting']], 7, 3], ['para-', 'graph', 'of type', 'leading', 'column', 'para-', 'graph', 'leading', 'kerning', 'setting']), ('regression: whole-word fit test', [[['hy', 'phen', 'a', 'tion'], ['lead', 'ing'], ['to'], ['in', 'ter', 'na', 'tion', 'al'], ['a'], ['set', 'ting'], ['col', 'umn']], 13, 3], ['hyphenation', 'leading to', 'international', 'a setting', 'column']), ('partial-repair probe', [[['jus', 'ti', 'fied'], ['text'], ['of'], ['in', 'ter', 'na', 'tion', 'al'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['mar', 'gin'], ['of'], ['break', 'ing'], ['line']], 12, 1], ['justified', 'text of in-', 'ternational', 'internation-', 'al margin', 'margin of', 'breaking', 'line']), ('partial-repair probe', [[['lead', 'ing'], ['pa', 'ra', 'graph'], ['to'], ['mar', 'gin'], ['line'], ['jus', 'ti', 'fied']], 14, 3], ['leading para-', 'graph to mar-', 'gin line', 'justified']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('control layout', [[['jus', 'ti', 'fied'], ['col', 'umn'], ['com', 'po', 'si', 'tion'], ['pa', 'ra', 'graph'], ['to'], ['jus', 'ti', 'fied'], ['mar', 'gin']], 12, 2], ['justified', 'column com-', 'position pa-', 'ragraph to', 'justified', 'margin']), ('control layout', [[['a'], ['kern', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['set', 'ting'], ['pa', 'ra', 'graph']], 11, 1], ['a kerning', 'interna-', 'tional', 'setting', 'paragraph'])], [('regression: whole-word fit test', [[['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['break', 'ing'], ['mar', 'gin'], ['line'], ['set', 'ting'], ['in', 'ter', 'na', 'tion', 'al']], 6, 1], ['compo-', 'sition', 'inter-', 'national', 'margin', 'break-', 'ing', 'margin', 'line', 'set-', 'ting', 'international']), ('regression: whole-word fit test', [[['col', 'umn'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing'], ['type'], ['lead', 'ing'], ['lead', 'ing'], ['text'], ['text'], ['pa', 'ra', 'graph']], 6, 1], ['column', 'inter-', 'national', 'kern-', 'ing', 'type', 'lead-', 'ing', 'lead-', 'ing', 'text', 'text', 'paragraph']), ('regression: whole-word fit test', [[['line'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['pa', 'ra', 'graph'], ['a'], ['a']], 7, 2], ['line', 'inter-', 'nation-', 'al', 'margin', 'para-', 'graph a', 'a']), ('regression: whole-word fit test', [[['break', 'ing'], ['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['break', 'ing'], ['text'], ['set', 'ting'], ['lead', 'ing']], 11, 3], ['breaking', 'composition', 'interna-', 'tional', 'breaking', 'text set-', 'ting', 'leading']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['line'], ['pa', 'ra', 'graph'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['pa', 'ra', 'graph'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing']], 6, 1], ['line', 'para-', 'graph', 'compo-', 'sition', 'hy-', 'phenation', 'para-', 'graph', 'inter-', 'national', 'kerning']), ('control layout', [[['a'], ['mar', 'gin'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing'], ['col', 'umn'], ['col', 'umn'], ['lead', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['to'], ['break', 'ing'], ['jus', 'ti', 'fied']], 12, 1], ['a margin in-', 'ternational', 'kerning col-', 'umn column', 'leading in-', 'ternational', 'to breaking', 'justified'])], [('regression: whole-word fit test', [[['set', 'ting'], ['of'], ['mar', 'gin'], ['kern', 'ing'], ['set', 'ting'], ['col', 'umn'], ['line'], ['set', 'ting'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin']], 11, 2], ['setting of', 'margin', 'kerning', 'setting', 'column line', 'setting a', 'interna-', 'tional', 'margin']), ('regression: whole-word fit test', [[['type'], ['col', 'umn'], ['lead', 'ing'], ['lead', 'ing'], ['of'], ['mar', 'gin'], ['in', 'ter', 'na', 'tion', 'al']], 10, 1], ['type col-', 'umn', 'leading', 'leading of', 'margin', 'international']), ('regression: whole-word fit test', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['type'], ['hy', 'phen', 'a', 'tion'], ['col', 'umn'], ['of'], ['pa', 'ra', 'graph'], ['hy', 'phen', 'a', 'tion']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'type', 'hyphen-', 'ation', 'column', 'of pa-', 'ragraph', 'hyphenation']), ('regression: whole-word fit test', [[['mar', 'gin'], ['pa', 'ra', 'graph'], ['lead', 'ing'], ['of'], ['type'], ['col', 'umn'], ['lead', 'ing']], 9, 3], ['margin', 'paragraph', 'leading', 'of type', 'column', 'leading']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['pa', 'ra', 'graph'], ['to'], ['jus', 'ti', 'fied'], ['lead', 'ing'], ['to'], ['col', 'umn']], 13, 2], ['paragraph to', 'justified', 'leading to', 'column']), ('control layout', [[['set', 'ting'], ['to'], ['break', 'ing'], ['com', 'po', 'si', 'tion'], ['lead', 'ing'], ['line'], ['jus', 'ti', 'fied'], ['a'], ['break', 'ing'], ['a'], ['line']], 13, 2], ['setting to', 'breaking com-', 'position', 'leading line', 'justified a', 'breaking a', 'line'])], [('regression: whole-word fit test', [[['line'], ['com', 'po', 'si', 'tion'], ['of'], ['to'], ['in', 'ter', 'na', 'tion', 'al'], ['lead', 'ing'], ['pa', 'ra', 'graph'], ['hy', 'phen', 'a', 'tion'], ['set', 'ting']], 10, 3], ['line com-', 'position', 'of to in-', 'ternation-', 'al leading', 'paragraph', 'hyphena-', 'tion', 'setting']), ('regression: whole-word fit test', [[['lead', 'ing'], ['kern', 'ing'], ['hy', 'phen', 'a', 'tion'], ['kern', 'ing'], ['col', 'umn'], ['com', 'po', 'si', 'tion'], ['lead', 'ing'], ['text'], ['of'], ['jus', 'ti', 'fied'], ['type'], ['kern', 'ing']], 12, 1], ['leading', 'kerning hy-', 'phenation', 'kerning col-', 'umn', 'composition', 'leading text', 'of justified', 'type kerning']), ('partial-repair probe', [[['hy', 'phen', 'a', 'tion'], ['type'], ['mar', 'gin'], ['a'], ['jus', 'ti', 'fied'], ['col', 'umn'], ['break', 'ing'], ['com', 'po', 'si', 'tion'], ['line']], 12, 2], ['hyphenation', 'type margin', 'a justified', 'column', 'breaking', 'composition', 'line']), ('partial-repair probe', [[['type'], ['mar', 'gin'], ['of'], ['a'], ['col', 'umn']], 8, 3], ['type', 'margin', 'of a', 'column']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['col', 'umn'], ['kern', 'ing'], ['text'], ['col', 'umn'], ['line'], ['line'], ['a']], 12, 2], ['column kern-', 'ing text', 'column line', 'line a']), ('control layout', [[['of'], ['break', 'ing'], ['type'], ['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'a', 'tion'], ['break', 'ing']], 12, 3], ['of breaking', 'type compo-', 'sition in-', 'ternational', 'hyphenation', 'breaking'])]]
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: whole-word fit test | ['leading', 'a jus-', 'tified', 'a a', 'para-', 'graph', 'setting', 'justified'] | ['lead-', 'ing a', 'justi-', 'fied a', 'a pa-', 'ragraph', 'set-', 'ting', 'justified'] | Failed |
| regression: whole-word fit test | ['leading kerning', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph'] | ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph'] | Failed |
| partial-repair probe | ['breaking', 'kerning set-', 'ting breaking', 'hyphenation', 'leading to', 'line', 'justified'] | ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified'] | Failed |
| regression: whole-word fit test | ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national column', 'line composi-', 'tion to'] | ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition to'] | Failed |
| ladder of three hyphenated lines | ['inter-', 'national', 'compo-', 'sition', 'hyphen-', 'ation', 'text'] | ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text'] | Failed |
| last word never hyphenated | ['a', 'composition'] | ['a', 'composition'] | Passed |
| control layout | ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking'] | ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking'] | Passed |
| control layout | ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'] | ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'] | Passed |
SHA-256 / 4bec4c389cef829ed27fe591d2e00ddb05a7a7b4bb8ef8b083527effd9fdcf10
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
words, width, limit = x
queue = [list(w) for w in words]
lines = []
cur = ''
streak = 0
k = 0
while k < len(queue):
syl = queue[k]
token = ''.join(syl)
need = len(token) if cur == '' else len(cur) + 1 + len(token)
if need <= width:
cur = token if cur == '' else cur + ' ' + token
k += 1
continue
split = None
if streak < limit and k < len(queue) - 1:
for cut in range(len(syl) - 1, 0, -1):
head = ''.join(syl[:cut]) + '-'
room = len(head) if cur == '' else len(cur) + len(head) + 1
if room <= width:
split = cut
break
if split is not None:
head = ''.join(syl[:split]) + '-'
lines.append(head if cur == '' else cur + ' ' + head)
queue[k] = syl[split:]
cur = ''
streak += 1
elif cur == '':
lines.append(token)
k += 1
streak = 0
else:
lines.append(cur)
cur, streak = '', 0
if cur:
lines.append(cur)
return lines
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: whole-word fit test', [[['lead', 'ing'], ['a'], ['jus', 'ti', 'fied'], ['a'], ['a'], ['pa', 'ra', 'graph'], ['set', 'ting'], ['jus', 'ti', 'fied']], 6, 1], ['lead-', 'ing a', 'justi-', 'fied a', 'a pa-', 'ragraph', 'set-', 'ting', 'justified']), ('regression: whole-word fit test', [[['lead', 'ing'], ['kern', 'ing'], ['com', 'po', 'si', 'tion'], ['text'], ['lead', 'ing'], ['kern', 'ing'], ['hy', 'phen', 'a', 'tion'], ['hy', 'phen', 'a', 'tion'], ['a'], ['text'], ['pa', 'ra', 'graph']], 14, 1], ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph']), ('partial-repair probe', [[['break', 'ing'], ['kern', 'ing'], ['set', 'ting'], ['break', 'ing'], ['hy', 'phen', 'a', 'tion'], ['lead', 'ing'], ['to'], ['line'], ['jus', 'ti', 'fied']], 12, 1], ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified']), ('regression: whole-word fit test', [[['to'], ['line'], ['com', 'po', 'si', 'tion'], ['mar', 'gin'], ['mar', 'gin'], ['type'], ['kern', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['col', 'umn'], ['line'], ['com', 'po', 'si', 'tion'], ['to']], 14, 1], ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition to']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'a', 'tion'], ['a'], ['hy', 'phen', 'a', 'tion'], ['break', 'ing']], 9, 3], ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking']), ('control layout', [[['text'], ['line'], ['hy', 'phen', 'a', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['set', 'ting']], 14, 2], ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'])], [('regression: whole-word fit test', [[['pa', 'ra', 'graph'], ['of'], ['type'], ['lead', 'ing'], ['col', 'umn'], ['pa', 'ra', 'graph'], ['lead', 'ing'], ['kern', 'ing'], ['set', 'ting']], 7, 3], ['para-', 'graph', 'of type', 'leading', 'column', 'para-', 'graph', 'leading', 'kerning', 'setting']), ('regression: whole-word fit test', [[['hy', 'phen', 'a', 'tion'], ['lead', 'ing'], ['to'], ['in', 'ter', 'na', 'tion', 'al'], ['a'], ['set', 'ting'], ['col', 'umn']], 13, 3], ['hyphenation', 'leading to', 'international', 'a setting', 'column']), ('partial-repair probe', [[['jus', 'ti', 'fied'], ['text'], ['of'], ['in', 'ter', 'na', 'tion', 'al'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['mar', 'gin'], ['of'], ['break', 'ing'], ['line']], 12, 1], ['justified', 'text of in-', 'ternational', 'internation-', 'al margin', 'margin of', 'breaking', 'line']), ('partial-repair probe', [[['lead', 'ing'], ['pa', 'ra', 'graph'], ['to'], ['mar', 'gin'], ['line'], ['jus', 'ti', 'fied']], 14, 3], ['leading para-', 'graph to mar-', 'gin line', 'justified']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('control layout', [[['jus', 'ti', 'fied'], ['col', 'umn'], ['com', 'po', 'si', 'tion'], ['pa', 'ra', 'graph'], ['to'], ['jus', 'ti', 'fied'], ['mar', 'gin']], 12, 2], ['justified', 'column com-', 'position pa-', 'ragraph to', 'justified', 'margin']), ('control layout', [[['a'], ['kern', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['set', 'ting'], ['pa', 'ra', 'graph']], 11, 1], ['a kerning', 'interna-', 'tional', 'setting', 'paragraph'])], [('regression: whole-word fit test', [[['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['break', 'ing'], ['mar', 'gin'], ['line'], ['set', 'ting'], ['in', 'ter', 'na', 'tion', 'al']], 6, 1], ['compo-', 'sition', 'inter-', 'national', 'margin', 'break-', 'ing', 'margin', 'line', 'set-', 'ting', 'international']), ('regression: whole-word fit test', [[['col', 'umn'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing'], ['type'], ['lead', 'ing'], ['lead', 'ing'], ['text'], ['text'], ['pa', 'ra', 'graph']], 6, 1], ['column', 'inter-', 'national', 'kern-', 'ing', 'type', 'lead-', 'ing', 'lead-', 'ing', 'text', 'text', 'paragraph']), ('regression: whole-word fit test', [[['line'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin'], ['pa', 'ra', 'graph'], ['a'], ['a']], 7, 2], ['line', 'inter-', 'nation-', 'al', 'margin', 'para-', 'graph a', 'a']), ('regression: whole-word fit test', [[['break', 'ing'], ['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['break', 'ing'], ['text'], ['set', 'ting'], ['lead', 'ing']], 11, 3], ['breaking', 'composition', 'interna-', 'tional', 'breaking', 'text set-', 'ting', 'leading']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['line'], ['pa', 'ra', 'graph'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['pa', 'ra', 'graph'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing']], 6, 1], ['line', 'para-', 'graph', 'compo-', 'sition', 'hy-', 'phenation', 'para-', 'graph', 'inter-', 'national', 'kerning']), ('control layout', [[['a'], ['mar', 'gin'], ['in', 'ter', 'na', 'tion', 'al'], ['kern', 'ing'], ['col', 'umn'], ['col', 'umn'], ['lead', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['to'], ['break', 'ing'], ['jus', 'ti', 'fied']], 12, 1], ['a margin in-', 'ternational', 'kerning col-', 'umn column', 'leading in-', 'ternational', 'to breaking', 'justified'])], [('regression: whole-word fit test', [[['set', 'ting'], ['of'], ['mar', 'gin'], ['kern', 'ing'], ['set', 'ting'], ['col', 'umn'], ['line'], ['set', 'ting'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['mar', 'gin']], 11, 2], ['setting of', 'margin', 'kerning', 'setting', 'column line', 'setting a', 'interna-', 'tional', 'margin']), ('regression: whole-word fit test', [[['type'], ['col', 'umn'], ['lead', 'ing'], ['lead', 'ing'], ['of'], ['mar', 'gin'], ['in', 'ter', 'na', 'tion', 'al']], 10, 1], ['type col-', 'umn', 'leading', 'leading of', 'margin', 'international']), ('regression: whole-word fit test', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['type'], ['hy', 'phen', 'a', 'tion'], ['col', 'umn'], ['of'], ['pa', 'ra', 'graph'], ['hy', 'phen', 'a', 'tion']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'type', 'hyphen-', 'ation', 'column', 'of pa-', 'ragraph', 'hyphenation']), ('regression: whole-word fit test', [[['mar', 'gin'], ['pa', 'ra', 'graph'], ['lead', 'ing'], ['of'], ['type'], ['col', 'umn'], ['lead', 'ing']], 9, 3], ['margin', 'paragraph', 'leading', 'of type', 'column', 'leading']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['pa', 'ra', 'graph'], ['to'], ['jus', 'ti', 'fied'], ['lead', 'ing'], ['to'], ['col', 'umn']], 13, 2], ['paragraph to', 'justified', 'leading to', 'column']), ('control layout', [[['set', 'ting'], ['to'], ['break', 'ing'], ['com', 'po', 'si', 'tion'], ['lead', 'ing'], ['line'], ['jus', 'ti', 'fied'], ['a'], ['break', 'ing'], ['a'], ['line']], 13, 2], ['setting to', 'breaking com-', 'position', 'leading line', 'justified a', 'breaking a', 'line'])], [('regression: whole-word fit test', [[['line'], ['com', 'po', 'si', 'tion'], ['of'], ['to'], ['in', 'ter', 'na', 'tion', 'al'], ['lead', 'ing'], ['pa', 'ra', 'graph'], ['hy', 'phen', 'a', 'tion'], ['set', 'ting']], 10, 3], ['line com-', 'position', 'of to in-', 'ternation-', 'al leading', 'paragraph', 'hyphena-', 'tion', 'setting']), ('regression: whole-word fit test', [[['lead', 'ing'], ['kern', 'ing'], ['hy', 'phen', 'a', 'tion'], ['kern', 'ing'], ['col', 'umn'], ['com', 'po', 'si', 'tion'], ['lead', 'ing'], ['text'], ['of'], ['jus', 'ti', 'fied'], ['type'], ['kern', 'ing']], 12, 1], ['leading', 'kerning hy-', 'phenation', 'kerning col-', 'umn', 'composition', 'leading text', 'of justified', 'type kerning']), ('partial-repair probe', [[['hy', 'phen', 'a', 'tion'], ['type'], ['mar', 'gin'], ['a'], ['jus', 'ti', 'fied'], ['col', 'umn'], ['break', 'ing'], ['com', 'po', 'si', 'tion'], ['line']], 12, 2], ['hyphenation', 'type margin', 'a justified', 'column', 'breaking', 'composition', 'line']), ('partial-repair probe', [[['type'], ['mar', 'gin'], ['of'], ['a'], ['col', 'umn']], 8, 3], ['type', 'margin', 'of a', 'column']), ('ladder of three hyphenated lines', [[['in', 'ter', 'na', 'tion', 'al'], ['com', 'po', 'si', 'tion'], ['hy', 'phen', 'a', 'tion'], ['text']], 7, 2], ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text']), ('last word never hyphenated', [[['a'], ['com', 'po', 'si', 'tion']], 8, 2], ['a', 'composition']), ('control layout', [[['col', 'umn'], ['kern', 'ing'], ['text'], ['col', 'umn'], ['line'], ['line'], ['a']], 12, 2], ['column kern-', 'ing text', 'column line', 'line a']), ('control layout', [[['of'], ['break', 'ing'], ['type'], ['com', 'po', 'si', 'tion'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'a', 'tion'], ['break', 'ing']], 12, 3], ['of breaking', 'type compo-', 'sition in-', 'ternational', 'hyphenation', 'breaking'])]]
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: whole-word fit test | ['lead-', 'ing a', 'justi-', 'fied a', 'a pa-', 'ragraph', 'set-', 'ting', 'justified'] | ['lead-', 'ing a', 'justi-', 'fied a', 'a pa-', 'ragraph', 'set-', 'ting', 'justified'] | Passed |
| regression: whole-word fit test | ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph'] | ['leading kern-', 'ing', 'composition', 'text leading', 'kerning hy-', 'phenation', 'hyphenation a', 'text paragraph'] | Passed |
| partial-repair probe | ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified'] | ['breaking', 'kerning set-', 'ting', 'breaking hy-', 'phenation', 'leading to', 'line', 'justified'] | Passed |
| regression: whole-word fit test | ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition to'] | ['to line compo-', 'sition margin', 'margin type', 'kerning inter-', 'national', 'column line', 'composition to'] | Passed |
| ladder of three hyphenated lines | ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text'] | ['inter-', 'nation-', 'al', 'compo-', 'sition', 'hyphen-', 'ation', 'text'] | Passed |
| last word never hyphenated | ['a', 'composition'] | ['a', 'composition'] | Passed |
| control layout | ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking'] | ['interna-', 'tional', 'hyphena-', 'tion a', 'hyphena-', 'tion', 'breaking'] | Passed |
| control layout | ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'] | ['text line hy-', 'phenation in-', 'ternational', 'composition', 'setting'] | Passed |
SHA-256 / 3dfc3d27a68846162fadf9365e2d29b030c0c90dc2e541142a9d872d8cdcdd74
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:49.573114+00:00.
Case digest / e2caa195166624010edf64b39a611672e583df163abafaf5c9add7b38055d08f