FAILURE MAP
← Case archive

FA-80226 / Typography line breaking / Open access

Ragged-right hyphenation zone: minimum word length unit · case 01

Long words with few syllables are never hyphenated.

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

ROOT CAUSE

The minimum word length is compared with the syllable count.

VERIFIED REPAIR

Compare the character length with the minimum word length.

Unsuccessful approach: A strict comparison excludes words of exactly the minimum length.

Case contract

Input [words as syllables, width, zone, min word length, min chars before, min chars after, hyphenate capitals]. Greedy fill. A word that does not fit may be hyphenated only if the slack left on the line (width minus current text minus the separating space) is at least the zone, the word has at least min-word characters, and (capitals allowed or its first letter is not uppercase). Pick the latest syllable boundary with head >= min before and tail >= min after chars whose head plus "-" fits. Return 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, zone, min_word, min_before, min_after, caps = x
    lines = []
    cur = ''
    k = 0
    queue = [list(w) for w in words]
    while k < len(queue):
        syl = queue[k]
        token = ''.join(syl)
        cand = token if not cur else cur + ' ' + token
        if len(cand) <= width:
            cur = cand
            k += 1
            continue
        slack = width - len(cur) - (1 if cur else 0)
        eligible = slack >= zone and len(syl) >= min_word and (caps or not token[0].isupper())
        cut = None
        if eligible:
            for c in range(len(syl) - 1, 0, -1):
                head = ''.join(syl[:c])
                tail = ''.join(syl[c:])
                if len(head) < min_before or len(tail) < min_after:
                    continue
                fit = len(head) + 1 if not cur else len(cur) + len(head) + 2
                if fit <= width:
                    cut = c
                    break
        if cut is not None:
            head = ''.join(syl[:cut]) + '-'
            lines.append(head if not cur else cur + ' ' + head)
            queue[k] = syl[cut:]
            cur = ''
        elif cur:
            lines.append(cur)
            cur = ''
        else:
            cur = token
            k += 1
    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: minimum word length unit', [[['of'], ['of'], ['hy', 'phen', 'at', 'ed'], ['set'], ['rag', 'ged'], ['the'], ['Mc', 'Don', 'ald']], 9, 3, 4, 2, 3, True], ['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']), ('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['rag', 'ged'], ['of'], ['im', 'por', 'tant'], ['set'], ['in', 'ter', 'na', 'tion', 'al']], 14, 5, 7, 1, 3, False], ['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']), ('regression: minimum word length unit', [[['the'], ['the'], ['on', 'ly'], ['rag', 'ged']], 10, 5, 6, 3, 2, False], ['the the', 'only rag-', 'ged']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['the'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 2, 6, 1, 2, False], ['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['set'], ['ty', 'po', 'gra', 'phy']], 14, 3, 4, 2, 2, False], ['only typogra-', 'phy important', 'important set', 'typography']), ('control layout', [[['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['on', 'ly'], ['set'], ['im', 'por', 'tant'], ['Mc', 'Don', 'ald'], ['on', 'ly'], ['on', 'ly'], ['on', 'ly']], 9, 4, 4, 2, 2, False], ['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only'])], [('regression: minimum word length unit', [[['a'], ['Ber', 'lin'], ['in', 'ter', 'na', 'tion', 'al'], ['Ber', 'lin'], ['rag', 'ged'], ['im', 'por', 'tant'], ['e', 'Book', 'ing']], 16, 5, 6, 1, 3, True], ['a Berlin inter-', 'national Berlin', 'ragged important', 'eBooking']), ('regression: minimum word length unit', [[['hy', 'phen', 'at', 'ed'], ['set'], ['set'], ['ty', 'po', 'gra', 'phy'], ['a'], ['rag', 'ged']], 13, 3, 5, 2, 2, False], ['hyphenated', 'set set typo-', 'graphy a rag-', 'ged']), ('regression: minimum word length unit', [[['set'], ['in', 'ter', 'na', 'tion', 'al'], ['rag', 'ged'], ['on', 'ly']], 12, 3, 6, 2, 3, True], ['set interna-', 'tional rag-', 'ged only']), ('regression: minimum word length unit', [[['of'], ['on', 'ly'], ['rag', 'ged'], ['of'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 2, 6, 2, 2, True], ['of only', 'ragged', 'of Ber-', 'lin hy-', 'phenated', 'ragged']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['a'], ['Ber', 'lin'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['of'], ['im', 'por', 'tant'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['e', 'Book', 'ing'], ['on', 'ly']], 15, 4, 5, 1, 3, True], ['a Berlin a in-', 'ternational of', 'important a', 'international', 'eBooking only']), ('control layout', [[['the'], ['rag', 'ged'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['on', 'ly']], 12, 2, 6, 1, 2, True], ['the ragged', 'ragged the', 'Berlin only'])], [('regression: minimum word length unit', [[['of'], ['hy', 'phen', 'at', 'ed'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['rag', 'ged'], ['a'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald'], ['set'], ['e', 'Book', 'ing']], 15, 3, 5, 2, 3, True], ['of hyphenated', 'typography Ber-', 'lin ragged a', 'McDonald McDon-', 'ald set eBook-', 'ing']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['im', 'por', 'tant'], ['Ber', 'lin'], ['ty', 'po', 'gra', 'phy'], ['on', 'ly'], ['Ber', 'lin']], 13, 4, 5, 3, 2, True], ['important the', 'important', 'Berlin typo-', 'graphy only', 'Berlin']), ('regression: minimum word length unit', [[['of'], ['of'], ['set'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged']], 9, 1, 6, 3, 2, True], ['of of set', 'typogra-', 'phy rag-', 'ged']), ('regression: minimum word length unit', [[['on', 'ly'], ['rag', 'ged'], ['the'], ['on', 'ly']], 9, 2, 6, 3, 3, False], ['only rag-', 'ged the', 'only']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['Ber', 'lin'], ['the'], ['a'], ['of'], ['rag', 'ged'], ['Ber', 'lin'], ['set'], ['set']], 14, 3, 4, 2, 2, False], ['Berlin the a', 'of ragged', 'Berlin set set']), ('control layout', [[['on', 'ly'], ['Ber', 'lin'], ['of'], ['hy', 'phen', 'at', 'ed'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy']], 13, 2, 5, 3, 3, True], ['only Berlin', 'of hyphenated', 'important', 'important', 'important', 'McDonald', 'typography'])], [('regression: minimum word length unit', [[['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['Mc', 'Don', 'ald'], ['e', 'Book', 'ing'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy']], 9, 4, 6, 2, 3, False], ['McDonald', 'Berlin', 'McDonald', 'eBooking', 'only ty-', 'pography', 'typogra-', 'phy rag-', 'ged typo-', 'graphy']), ('regression: minimum word length unit', [[['ty', 'po', 'gra', 'phy'], ['a'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al']], 14, 3, 6, 3, 2, True], ['typography a', 'typography', 'ragged inter-', 'national typo-', 'graphy inter-', 'national']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['the'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 2, 6, 1, 2, False], ['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']), ('regression: minimum word length unit', [[['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['e', 'Book', 'ing'], ['rag', 'ged'], ['rag', 'ged'], ['e', 'Book', 'ing']], 14, 5, 6, 2, 3, True], ['ragged typo-', 'graphy Berlin', 'eBooking rag-', 'ged ragged', 'eBooking']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('control layout', [[['Ber', 'lin'], ['Ber', 'lin'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 1, 5, 3, 3, False], ['Berlin', 'Berlin', 'Berlin', 'McDonald']), ('control layout', [[['hy', 'phen', 'at', 'ed'], ['of'], ['e', 'Book', 'ing'], ['on', 'ly'], ['rag', 'ged'], ['Ber', 'lin']], 14, 3, 6, 3, 2, True], ['hyphenated of', 'eBooking only', 'ragged Berlin'])], [('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald']], 15, 5, 7, 3, 2, True], ['eBooking McDon-', 'ald interna-', 'tional McDonald', 'McDonald']), ('regression: minimum word length unit', [[['hy', 'phen', 'at', 'ed'], ['the'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['of'], ['rag', 'ged'], ['of'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 5, 6, 2, 2, False], ['hyphen-', 'ated the', 'ragged', 'typogra-', 'phy', 'Berlin', 'of rag-', 'ged of', 'hyphen-', 'ated', 'ragged']), ('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['on', 'ly'], ['Ber', 'lin'], ['in', 'ter', 'na', 'tion', 'al'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing']], 14, 3, 6, 1, 2, True], ['eBooking only', 'Berlin inter-', 'national Ber-', 'lin hyphenated', 'eBooking']), ('regression: minimum word length unit', [[['of'], ['on', 'ly'], ['rag', 'ged'], ['of'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 2, 6, 2, 2, True], ['of only', 'ragged', 'of Ber-', 'lin hy-', 'phenated', 'ragged']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['the'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 16, 5, 7, 2, 3, True], ['the McDonald', 'international', 'hyphenated']), ('control layout', [[['set'], ['Ber', 'lin'], ['set'], ['a']], 14, 5, 5, 2, 2, True], ['set Berlin set', 'a'])]]
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 fixtureActualExpectedOutcome
regression: minimum word length unit['of of hy-', 'phenated', 'set', 'ragged', 'the', 'McDonald']['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']Failed
regression: minimum word length unit['eBooking', 'international', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']Failed
regression: minimum word length unit['the the', 'only', 'ragged']['the the', 'only rag-', 'ged']Failed
regression: minimum word length unit['important', 'the the', 'typography', 'Berlin', 'the', 'ragged', 'the', 'Berlin', 'McDonald']['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']Failed
capitalised word protected['the', 'McDonald']['the', 'McDonald']Passed
zone exactly met['the typo-', 'graphy']['the typo-', 'graphy']Passed
control layout['only typogra-', 'phy important', 'important set', 'typography']['only typogra-', 'phy important', 'important set', 'typography']Passed
control layout['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only']['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only']Passed

SHA-256 / 7219f7f07ca4b18a95fef4aa96e02698cf9318e2fd4177cbc70a292911ef13ed

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    words, width, zone, min_word, min_before, min_after, caps = x
    lines = []
    cur = ''
    k = 0
    queue = [list(w) for w in words]
    while k < len(queue):
        syl = queue[k]
        token = ''.join(syl)
        cand = token if not cur else cur + ' ' + token
        if len(cand) <= width:
            cur = cand
            k += 1
            continue
        slack = width - len(cur) - (1 if cur else 0)
        eligible = slack >= zone and len(token) > min_word and (caps or not token[0].isupper())
        cut = None
        if eligible:
            for c in range(len(syl) - 1, 0, -1):
                head = ''.join(syl[:c])
                tail = ''.join(syl[c:])
                if len(head) < min_before or len(tail) < min_after:
                    continue
                fit = len(head) + 1 if not cur else len(cur) + len(head) + 2
                if fit <= width:
                    cut = c
                    break
        if cut is not None:
            head = ''.join(syl[:cut]) + '-'
            lines.append(head if not cur else cur + ' ' + head)
            queue[k] = syl[cut:]
            cur = ''
        elif cur:
            lines.append(cur)
            cur = ''
        else:
            cur = token
            k += 1
    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: minimum word length unit', [[['of'], ['of'], ['hy', 'phen', 'at', 'ed'], ['set'], ['rag', 'ged'], ['the'], ['Mc', 'Don', 'ald']], 9, 3, 4, 2, 3, True], ['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']), ('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['rag', 'ged'], ['of'], ['im', 'por', 'tant'], ['set'], ['in', 'ter', 'na', 'tion', 'al']], 14, 5, 7, 1, 3, False], ['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']), ('regression: minimum word length unit', [[['the'], ['the'], ['on', 'ly'], ['rag', 'ged']], 10, 5, 6, 3, 2, False], ['the the', 'only rag-', 'ged']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['the'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 2, 6, 1, 2, False], ['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['set'], ['ty', 'po', 'gra', 'phy']], 14, 3, 4, 2, 2, False], ['only typogra-', 'phy important', 'important set', 'typography']), ('control layout', [[['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['on', 'ly'], ['set'], ['im', 'por', 'tant'], ['Mc', 'Don', 'ald'], ['on', 'ly'], ['on', 'ly'], ['on', 'ly']], 9, 4, 4, 2, 2, False], ['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only'])], [('regression: minimum word length unit', [[['a'], ['Ber', 'lin'], ['in', 'ter', 'na', 'tion', 'al'], ['Ber', 'lin'], ['rag', 'ged'], ['im', 'por', 'tant'], ['e', 'Book', 'ing']], 16, 5, 6, 1, 3, True], ['a Berlin inter-', 'national Berlin', 'ragged important', 'eBooking']), ('regression: minimum word length unit', [[['hy', 'phen', 'at', 'ed'], ['set'], ['set'], ['ty', 'po', 'gra', 'phy'], ['a'], ['rag', 'ged']], 13, 3, 5, 2, 2, False], ['hyphenated', 'set set typo-', 'graphy a rag-', 'ged']), ('regression: minimum word length unit', [[['set'], ['in', 'ter', 'na', 'tion', 'al'], ['rag', 'ged'], ['on', 'ly']], 12, 3, 6, 2, 3, True], ['set interna-', 'tional rag-', 'ged only']), ('regression: minimum word length unit', [[['of'], ['on', 'ly'], ['rag', 'ged'], ['of'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 2, 6, 2, 2, True], ['of only', 'ragged', 'of Ber-', 'lin hy-', 'phenated', 'ragged']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['a'], ['Ber', 'lin'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['of'], ['im', 'por', 'tant'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['e', 'Book', 'ing'], ['on', 'ly']], 15, 4, 5, 1, 3, True], ['a Berlin a in-', 'ternational of', 'important a', 'international', 'eBooking only']), ('control layout', [[['the'], ['rag', 'ged'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['on', 'ly']], 12, 2, 6, 1, 2, True], ['the ragged', 'ragged the', 'Berlin only'])], [('regression: minimum word length unit', [[['of'], ['hy', 'phen', 'at', 'ed'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['rag', 'ged'], ['a'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald'], ['set'], ['e', 'Book', 'ing']], 15, 3, 5, 2, 3, True], ['of hyphenated', 'typography Ber-', 'lin ragged a', 'McDonald McDon-', 'ald set eBook-', 'ing']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['im', 'por', 'tant'], ['Ber', 'lin'], ['ty', 'po', 'gra', 'phy'], ['on', 'ly'], ['Ber', 'lin']], 13, 4, 5, 3, 2, True], ['important the', 'important', 'Berlin typo-', 'graphy only', 'Berlin']), ('regression: minimum word length unit', [[['of'], ['of'], ['set'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged']], 9, 1, 6, 3, 2, True], ['of of set', 'typogra-', 'phy rag-', 'ged']), ('regression: minimum word length unit', [[['on', 'ly'], ['rag', 'ged'], ['the'], ['on', 'ly']], 9, 2, 6, 3, 3, False], ['only rag-', 'ged the', 'only']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['Ber', 'lin'], ['the'], ['a'], ['of'], ['rag', 'ged'], ['Ber', 'lin'], ['set'], ['set']], 14, 3, 4, 2, 2, False], ['Berlin the a', 'of ragged', 'Berlin set set']), ('control layout', [[['on', 'ly'], ['Ber', 'lin'], ['of'], ['hy', 'phen', 'at', 'ed'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy']], 13, 2, 5, 3, 3, True], ['only Berlin', 'of hyphenated', 'important', 'important', 'important', 'McDonald', 'typography'])], [('regression: minimum word length unit', [[['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['Mc', 'Don', 'ald'], ['e', 'Book', 'ing'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy']], 9, 4, 6, 2, 3, False], ['McDonald', 'Berlin', 'McDonald', 'eBooking', 'only ty-', 'pography', 'typogra-', 'phy rag-', 'ged typo-', 'graphy']), ('regression: minimum word length unit', [[['ty', 'po', 'gra', 'phy'], ['a'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al']], 14, 3, 6, 3, 2, True], ['typography a', 'typography', 'ragged inter-', 'national typo-', 'graphy inter-', 'national']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['the'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 2, 6, 1, 2, False], ['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']), ('regression: minimum word length unit', [[['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['e', 'Book', 'ing'], ['rag', 'ged'], ['rag', 'ged'], ['e', 'Book', 'ing']], 14, 5, 6, 2, 3, True], ['ragged typo-', 'graphy Berlin', 'eBooking rag-', 'ged ragged', 'eBooking']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('control layout', [[['Ber', 'lin'], ['Ber', 'lin'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 1, 5, 3, 3, False], ['Berlin', 'Berlin', 'Berlin', 'McDonald']), ('control layout', [[['hy', 'phen', 'at', 'ed'], ['of'], ['e', 'Book', 'ing'], ['on', 'ly'], ['rag', 'ged'], ['Ber', 'lin']], 14, 3, 6, 3, 2, True], ['hyphenated of', 'eBooking only', 'ragged Berlin'])], [('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald']], 15, 5, 7, 3, 2, True], ['eBooking McDon-', 'ald interna-', 'tional McDonald', 'McDonald']), ('regression: minimum word length unit', [[['hy', 'phen', 'at', 'ed'], ['the'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['of'], ['rag', 'ged'], ['of'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 5, 6, 2, 2, False], ['hyphen-', 'ated the', 'ragged', 'typogra-', 'phy', 'Berlin', 'of rag-', 'ged of', 'hyphen-', 'ated', 'ragged']), ('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['on', 'ly'], ['Ber', 'lin'], ['in', 'ter', 'na', 'tion', 'al'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing']], 14, 3, 6, 1, 2, True], ['eBooking only', 'Berlin inter-', 'national Ber-', 'lin hyphenated', 'eBooking']), ('regression: minimum word length unit', [[['of'], ['on', 'ly'], ['rag', 'ged'], ['of'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 2, 6, 2, 2, True], ['of only', 'ragged', 'of Ber-', 'lin hy-', 'phenated', 'ragged']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['the'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 16, 5, 7, 2, 3, True], ['the McDonald', 'international', 'hyphenated']), ('control layout', [[['set'], ['Ber', 'lin'], ['set'], ['a']], 14, 5, 5, 2, 2, True], ['set Berlin set', 'a'])]]
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 fixtureActualExpectedOutcome
regression: minimum word length unit['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']Passed
regression: minimum word length unit['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']Passed
regression: minimum word length unit['the the', 'only', 'ragged']['the the', 'only rag-', 'ged']Failed
regression: minimum word length unit['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the', 'ragged', 'the', 'Berlin', 'McDonald']['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']Failed
capitalised word protected['the', 'McDonald']['the', 'McDonald']Passed
zone exactly met['the typo-', 'graphy']['the typo-', 'graphy']Passed
control layout['only typogra-', 'phy important', 'important set', 'typography']['only typogra-', 'phy important', 'important set', 'typography']Passed
control layout['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only']['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only']Passed

SHA-256 / a501ac6834843d65e11c2f3dc2e77bfcd26cf1a7742ccf6d3706304e125a6f1d

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    words, width, zone, min_word, min_before, min_after, caps = x
    lines = []
    cur = ''
    k = 0
    queue = [list(w) for w in words]
    while k < len(queue):
        syl = queue[k]
        token = ''.join(syl)
        cand = token if not cur else cur + ' ' + token
        if len(cand) <= width:
            cur = cand
            k += 1
            continue
        slack = width - len(cur) - (1 if cur else 0)
        eligible = slack >= zone and len(token) >= min_word and (caps or not token[0].isupper())
        cut = None
        if eligible:
            for c in range(len(syl) - 1, 0, -1):
                head = ''.join(syl[:c])
                tail = ''.join(syl[c:])
                if len(head) < min_before or len(tail) < min_after:
                    continue
                fit = len(head) + 1 if not cur else len(cur) + len(head) + 2
                if fit <= width:
                    cut = c
                    break
        if cut is not None:
            head = ''.join(syl[:cut]) + '-'
            lines.append(head if not cur else cur + ' ' + head)
            queue[k] = syl[cut:]
            cur = ''
        elif cur:
            lines.append(cur)
            cur = ''
        else:
            cur = token
            k += 1
    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: minimum word length unit', [[['of'], ['of'], ['hy', 'phen', 'at', 'ed'], ['set'], ['rag', 'ged'], ['the'], ['Mc', 'Don', 'ald']], 9, 3, 4, 2, 3, True], ['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']), ('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['in', 'ter', 'na', 'tion', 'al'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['rag', 'ged'], ['of'], ['im', 'por', 'tant'], ['set'], ['in', 'ter', 'na', 'tion', 'al']], 14, 5, 7, 1, 3, False], ['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']), ('regression: minimum word length unit', [[['the'], ['the'], ['on', 'ly'], ['rag', 'ged']], 10, 5, 6, 3, 2, False], ['the the', 'only rag-', 'ged']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['the'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 2, 6, 1, 2, False], ['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['set'], ['ty', 'po', 'gra', 'phy']], 14, 3, 4, 2, 2, False], ['only typogra-', 'phy important', 'important set', 'typography']), ('control layout', [[['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['on', 'ly'], ['set'], ['im', 'por', 'tant'], ['Mc', 'Don', 'ald'], ['on', 'ly'], ['on', 'ly'], ['on', 'ly']], 9, 4, 4, 2, 2, False], ['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only'])], [('regression: minimum word length unit', [[['a'], ['Ber', 'lin'], ['in', 'ter', 'na', 'tion', 'al'], ['Ber', 'lin'], ['rag', 'ged'], ['im', 'por', 'tant'], ['e', 'Book', 'ing']], 16, 5, 6, 1, 3, True], ['a Berlin inter-', 'national Berlin', 'ragged important', 'eBooking']), ('regression: minimum word length unit', [[['hy', 'phen', 'at', 'ed'], ['set'], ['set'], ['ty', 'po', 'gra', 'phy'], ['a'], ['rag', 'ged']], 13, 3, 5, 2, 2, False], ['hyphenated', 'set set typo-', 'graphy a rag-', 'ged']), ('regression: minimum word length unit', [[['set'], ['in', 'ter', 'na', 'tion', 'al'], ['rag', 'ged'], ['on', 'ly']], 12, 3, 6, 2, 3, True], ['set interna-', 'tional rag-', 'ged only']), ('regression: minimum word length unit', [[['of'], ['on', 'ly'], ['rag', 'ged'], ['of'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 2, 6, 2, 2, True], ['of only', 'ragged', 'of Ber-', 'lin hy-', 'phenated', 'ragged']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['a'], ['Ber', 'lin'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['of'], ['im', 'por', 'tant'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['e', 'Book', 'ing'], ['on', 'ly']], 15, 4, 5, 1, 3, True], ['a Berlin a in-', 'ternational of', 'important a', 'international', 'eBooking only']), ('control layout', [[['the'], ['rag', 'ged'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['on', 'ly']], 12, 2, 6, 1, 2, True], ['the ragged', 'ragged the', 'Berlin only'])], [('regression: minimum word length unit', [[['of'], ['hy', 'phen', 'at', 'ed'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['rag', 'ged'], ['a'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald'], ['set'], ['e', 'Book', 'ing']], 15, 3, 5, 2, 3, True], ['of hyphenated', 'typography Ber-', 'lin ragged a', 'McDonald McDon-', 'ald set eBook-', 'ing']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['im', 'por', 'tant'], ['Ber', 'lin'], ['ty', 'po', 'gra', 'phy'], ['on', 'ly'], ['Ber', 'lin']], 13, 4, 5, 3, 2, True], ['important the', 'important', 'Berlin typo-', 'graphy only', 'Berlin']), ('regression: minimum word length unit', [[['of'], ['of'], ['set'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged']], 9, 1, 6, 3, 2, True], ['of of set', 'typogra-', 'phy rag-', 'ged']), ('regression: minimum word length unit', [[['on', 'ly'], ['rag', 'ged'], ['the'], ['on', 'ly']], 9, 2, 6, 3, 3, False], ['only rag-', 'ged the', 'only']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['Ber', 'lin'], ['the'], ['a'], ['of'], ['rag', 'ged'], ['Ber', 'lin'], ['set'], ['set']], 14, 3, 4, 2, 2, False], ['Berlin the a', 'of ragged', 'Berlin set set']), ('control layout', [[['on', 'ly'], ['Ber', 'lin'], ['of'], ['hy', 'phen', 'at', 'ed'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy']], 13, 2, 5, 3, 3, True], ['only Berlin', 'of hyphenated', 'important', 'important', 'important', 'McDonald', 'typography'])], [('regression: minimum word length unit', [[['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['Mc', 'Don', 'ald'], ['e', 'Book', 'ing'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy']], 9, 4, 6, 2, 3, False], ['McDonald', 'Berlin', 'McDonald', 'eBooking', 'only ty-', 'pography', 'typogra-', 'phy rag-', 'ged typo-', 'graphy']), ('regression: minimum word length unit', [[['ty', 'po', 'gra', 'phy'], ['a'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al']], 14, 3, 6, 3, 2, True], ['typography a', 'typography', 'ragged inter-', 'national typo-', 'graphy inter-', 'national']), ('regression: minimum word length unit', [[['im', 'por', 'tant'], ['the'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['the'], ['rag', 'ged'], ['the'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 2, 6, 1, 2, False], ['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']), ('regression: minimum word length unit', [[['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['e', 'Book', 'ing'], ['rag', 'ged'], ['rag', 'ged'], ['e', 'Book', 'ing']], 14, 5, 6, 2, 3, True], ['ragged typo-', 'graphy Berlin', 'eBooking rag-', 'ged ragged', 'eBooking']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('control layout', [[['Ber', 'lin'], ['Ber', 'lin'], ['Ber', 'lin'], ['Mc', 'Don', 'ald']], 9, 1, 5, 3, 3, False], ['Berlin', 'Berlin', 'Berlin', 'McDonald']), ('control layout', [[['hy', 'phen', 'at', 'ed'], ['of'], ['e', 'Book', 'ing'], ['on', 'ly'], ['rag', 'ged'], ['Ber', 'lin']], 14, 3, 6, 3, 2, True], ['hyphenated of', 'eBooking only', 'ragged Berlin'])], [('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald']], 15, 5, 7, 3, 2, True], ['eBooking McDon-', 'ald interna-', 'tional McDonald', 'McDonald']), ('regression: minimum word length unit', [[['hy', 'phen', 'at', 'ed'], ['the'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['of'], ['rag', 'ged'], ['of'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 5, 6, 2, 2, False], ['hyphen-', 'ated the', 'ragged', 'typogra-', 'phy', 'Berlin', 'of rag-', 'ged of', 'hyphen-', 'ated', 'ragged']), ('regression: minimum word length unit', [[['e', 'Book', 'ing'], ['on', 'ly'], ['Ber', 'lin'], ['in', 'ter', 'na', 'tion', 'al'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing']], 14, 3, 6, 1, 2, True], ['eBooking only', 'Berlin inter-', 'national Ber-', 'lin hyphenated', 'eBooking']), ('regression: minimum word length unit', [[['of'], ['on', 'ly'], ['rag', 'ged'], ['of'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['rag', 'ged']], 8, 2, 6, 2, 2, True], ['of only', 'ragged', 'of Ber-', 'lin hy-', 'phenated', 'ragged']), ('capitalised word protected', [[['the'], ['Mc', 'Don', 'ald']], 10, 2, 4, 2, 2, False], ['the', 'McDonald']), ('zone exactly met', [[['the'], ['ty', 'po', 'gra', 'phy']], 10, 6, 4, 2, 2, False], ['the typo-', 'graphy']), ('control layout', [[['the'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 16, 5, 7, 2, 3, True], ['the McDonald', 'international', 'hyphenated']), ('control layout', [[['set'], ['Ber', 'lin'], ['set'], ['a']], 14, 5, 5, 2, 2, True], ['set Berlin set', 'a'])]]
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 fixtureActualExpectedOutcome
regression: minimum word length unit['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']['of of hy-', 'phenated', 'set rag-', 'ged the', 'McDonald']Passed
regression: minimum word length unit['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']['eBooking in-', 'ternational', 'eBooking', 'McDonald', 'ragged of', 'important set', 'international']Passed
regression: minimum word length unit['the the', 'only rag-', 'ged']['the the', 'only rag-', 'ged']Passed
regression: minimum word length unit['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']['important', 'the the', 'typogra-', 'phy', 'Berlin', 'the rag-', 'ged the', 'Berlin', 'McDonald']Passed
capitalised word protected['the', 'McDonald']['the', 'McDonald']Passed
zone exactly met['the typo-', 'graphy']['the typo-', 'graphy']Passed
control layout['only typogra-', 'phy important', 'important set', 'typography']['only typogra-', 'phy important', 'important set', 'typography']Passed
control layout['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only']['only ty-', 'pography', 'only set', 'important', 'McDonald', 'only only', 'only']Passed

SHA-256 / 0a8f7a688ba6cbe933b3999eb73791dfa0c18885d1339edf963631c91a16e8d5

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:51.852510+00:00.

Case digest / 950f824f33446a1261f7da153b09cf6b53090c1d8a8eff2688a5842de6480fa9