FAILURE MAP
← Case archive

FA-80216 / Typography line breaking / Open access

Ragged-right hyphenation zone: slack separator · case 01

Slack is overstated by one on lines that already hold text.

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

ROOT CAUSE

Slack ignores the space that would precede the next word.

VERIFIED REPAIR

Subtract the separating space from the slack when the line is not empty.

Unsuccessful approach: Adding the space instead of subtracting it overstates slack even more.

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)
        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: slack separator', [[['Mc', 'Don', 'ald'], ['rag', 'ged'], ['Ber', 'lin'], ['the'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al']], 12, 4, 6, 2, 3, False], ['McDonald', 'ragged', 'Berlin the', 'McDonald', 'interna-', 'tional rag-', 'ged typogra-', 'phy interna-', 'tional']), ('regression: slack separator', [[['a'], ['the'], ['hy', 'phen', 'at', 'ed'], ['a'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['in', 'ter', 'na', 'tion', 'al']], 9, 4, 7, 2, 3, False], ['a the', 'hyphen-', 'ated a', 'typogra-', 'phy typo-', 'graphy', 'eBooking', 'important', 'important', 'interna-', 'tional']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('partial-repair probe', [[['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['Ber', 'lin'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['hy', 'phen', 'at', 'ed']], 10, 5, 5, 2, 2, False], ['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']), ('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', [[['on', 'ly'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald'], ['hy', 'phen', 'at', 'ed']], 13, 3, 6, 2, 2, False], ['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']), ('control layout', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['a'], ['im', 'por', 'tant'], ['the'], ['Ber', 'lin'], ['set'], ['a']], 13, 2, 6, 3, 2, False], ['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a'])], [('regression: slack separator', [[['Mc', 'Don', 'ald'], ['of'], ['the'], ['Mc', 'Don', 'ald'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['hy', 'phen', 'at', 'ed'], ['on', 'ly']], 8, 4, 4, 1, 2, False], ['McDonald', 'of the', 'McDonald', 'impor-', 'tant', 'eBooking', 'hyphen-', 'ated', 'only']), ('regression: slack separator', [[['on', 'ly'], ['of'], ['set'], ['in', 'ter', 'na', 'tion', 'al'], ['set'], ['the'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['e', 'Book', 'ing']], 12, 3, 4, 1, 2, True], ['only of set', 'internation-', 'al set the', 'important', 'eBooking e-', 'Booking']), ('regression: slack separator', [[['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']), ('regression: slack separator', [[['on', 'ly'], ['the'], ['of'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy']], 15, 4, 6, 1, 3, True], ['only the of', 'McDonald typo-', 'graphy']), ('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', [[['hy', 'phen', 'at', 'ed'], ['Ber', 'lin'], ['set'], ['e', 'Book', 'ing'], ['e', 'Book', 'ing'], ['the']], 8, 3, 6, 2, 3, True], ['hyphen-', 'ated', 'Berlin', 'set', 'eBooking', 'eBooking', 'the']), ('control layout', [[['of'], ['of'], ['set'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged']], 9, 1, 6, 3, 2, True], ['of of set', 'typogra-', 'phy rag-', 'ged'])], [('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['the'], ['a'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Mc', 'Don', 'ald'], ['set'], ['Ber', 'lin']], 15, 5, 7, 2, 3, False], ['hyphenated', 'international', 'the a the typo-', 'graphy McDonald', 'set Berlin']), ('regression: slack separator', [[['e', 'Book', 'ing'], ['im', 'por', 'tant'], ['of'], ['hy', 'phen', 'at', 'ed'], ['im', 'por', 'tant'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing']], 14, 5, 5, 1, 2, True], ['eBooking im-', 'portant of', 'hyphenated', 'important', 'hyphenated', 'eBooking']), ('regression: slack separator', [[['Mc', 'Don', 'ald'], ['of'], ['the'], ['Mc', 'Don', 'ald'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['hy', 'phen', 'at', 'ed'], ['on', 'ly']], 8, 4, 4, 1, 2, False], ['McDonald', 'of the', 'McDonald', 'impor-', 'tant', 'eBooking', 'hyphen-', 'ated', 'only']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('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', [[['on', 'ly'], ['the'], ['im', 'por', 'tant'], ['of']], 14, 1, 4, 3, 2, True], ['only the', 'important of']), ('control layout', [[['a'], ['Ber', 'lin'], ['on', 'ly'], ['e', 'Book', 'ing']], 8, 5, 5, 2, 3, True], ['a Berlin', 'only', 'eBooking'])], [('regression: slack separator', [[['the'], ['in', 'ter', 'na', 'tion', 'al'], ['on', 'ly'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy']], 14, 4, 4, 2, 2, False], ['the interna-', 'tional only', 'hyphenated', 'international', 'international', 'typography', 'typography']), ('regression: slack separator', [[['the'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['set'], ['rag', 'ged'], ['set'], ['Mc', 'Don', 'ald'], ['rag', 'ged']], 8, 5, 4, 1, 2, True], ['the', 'typogra-', 'phy', 'typogra-', 'phy set', 'ragged', 'set', 'McDonald', 'ragged']), ('regression: slack separator', [[['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al'], ['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['rag', 'ged'], ['rag', 'ged'], ['on', 'ly'], ['of'], ['hy', 'phen', 'at', 'ed']], 11, 5, 5, 2, 3, False], ['typography', 'interna-', 'tional', 'McDonald', 'Berlin', 'ragged', 'ragged only', 'of hyphen-', 'ated']), ('regression: slack separator', [[['in', 'ter', 'na', 'tion', 'al'], ['a'], ['on', 'ly'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy']], 9, 5, 5, 1, 2, False], ['interna-', 'tional a', 'only', 'interna-', 'tional', 'typogra-', 'phy']), ('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', [[['a'], ['e', 'Book', 'ing'], ['rag', 'ged'], ['e', 'Book', 'ing'], ['the'], ['of'], ['a'], ['ty', 'po', 'gra', 'phy']], 11, 4, 7, 2, 2, False], ['a eBooking', 'ragged', 'eBooking', 'the of a', 'typography']), ('control layout', [[['of'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['rag', 'ged'], ['hy', 'phen', 'at', 'ed'], ['a'], ['im', 'por', 'tant'], ['a'], ['Mc', 'Don', 'ald']], 9, 1, 7, 2, 2, False], ['of only', 'typogra-', 'phy', 'Berlin', 'ragged', 'hyphenat-', 'ed a im-', 'portant a', 'McDonald'])], [('regression: slack separator', [[['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['the'], ['hy', 'phen', 'at', 'ed'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['of']], 13, 3, 7, 1, 3, True], ['typography', 'typography', 'eBooking Mc-', 'Donald the', 'hyphenated', 'McDonald in-', 'ternational', 'typography of']), ('regression: slack separator', [[['the'], ['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['a'], ['Ber', 'lin'], ['a'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed'], ['ty', 'po', 'gra', 'phy']], 11, 5, 5, 2, 2, False], ['the', 'McDonald', 'Berlin a', 'Berlin a a', 'interna-', 'tional', 'hyphenated', 'typography']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('regression: slack separator', [[['Mc', 'Don', 'ald'], ['on', 'ly'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing'], ['Ber', 'lin'], ['on', 'ly'], ['rag', 'ged'], ['rag', 'ged'], ['im', 'por', 'tant']], 8, 4, 7, 1, 2, False], ['McDonald', 'only', 'Berlin', 'hyphen-', 'ated', 'eBooking', 'Berlin', 'only', 'ragged', 'ragged', 'impor-', 'tant']), ('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'], ['in', 'ter', 'na', 'tion', 'al'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['set'], ['hy', 'phen', 'at', 'ed'], ['of']], 11, 3, 4, 2, 2, False], ['the inter-', 'national', 'only typo-', 'graphy set', 'hyphenated', 'of']), ('control layout', [[['a'], ['rag', 'ged'], ['of'], ['of'], ['the'], ['of'], ['on', 'ly'], ['Mc', 'Don', 'ald'], ['the']], 11, 3, 7, 2, 2, False], ['a ragged of', 'of the of', 'only', 'McDonald', 'the'])]]
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: slack separator['McDonald', 'ragged', 'Berlin the', 'McDonald in-', 'ternational', 'ragged typo-', 'graphy in-', 'ternational']['McDonald', 'ragged', 'Berlin the', 'McDonald', 'interna-', 'tional rag-', 'ged typogra-', 'phy interna-', 'tional']Failed
regression: slack separator['a the hy-', 'phenated', 'a typo-', 'graphy', 'typogra-', 'phy', 'eBooking', 'important', 'important', 'interna-', 'tional']['a the', 'hyphen-', 'ated a', 'typogra-', 'phy typo-', 'graphy', 'eBooking', 'important', 'important', 'interna-', 'tional']Failed
regression: slack separator['hyphenated hy-', 'phenated inter-', 'national hy-', 'phenated']['hyphenated', 'hyphenated', 'international', 'hyphenated']Failed
partial-repair probe['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']Passed
zone exactly met['the typo-', 'graphy']['the typo-', 'graphy']Passed
capitalised word protected['the', 'McDonald']['the', 'McDonald']Passed
control layout['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']Passed
control layout['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a']['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a']Passed

SHA-256 / 231dfb26ee94b9a05b600b469986558f5174e4fdce57bfdafea2e18b66904a59

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: slack separator', [[['Mc', 'Don', 'ald'], ['rag', 'ged'], ['Ber', 'lin'], ['the'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al']], 12, 4, 6, 2, 3, False], ['McDonald', 'ragged', 'Berlin the', 'McDonald', 'interna-', 'tional rag-', 'ged typogra-', 'phy interna-', 'tional']), ('regression: slack separator', [[['a'], ['the'], ['hy', 'phen', 'at', 'ed'], ['a'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['in', 'ter', 'na', 'tion', 'al']], 9, 4, 7, 2, 3, False], ['a the', 'hyphen-', 'ated a', 'typogra-', 'phy typo-', 'graphy', 'eBooking', 'important', 'important', 'interna-', 'tional']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('partial-repair probe', [[['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['Ber', 'lin'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['hy', 'phen', 'at', 'ed']], 10, 5, 5, 2, 2, False], ['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']), ('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', [[['on', 'ly'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald'], ['hy', 'phen', 'at', 'ed']], 13, 3, 6, 2, 2, False], ['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']), ('control layout', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['a'], ['im', 'por', 'tant'], ['the'], ['Ber', 'lin'], ['set'], ['a']], 13, 2, 6, 3, 2, False], ['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a'])], [('regression: slack separator', [[['Mc', 'Don', 'ald'], ['of'], ['the'], ['Mc', 'Don', 'ald'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['hy', 'phen', 'at', 'ed'], ['on', 'ly']], 8, 4, 4, 1, 2, False], ['McDonald', 'of the', 'McDonald', 'impor-', 'tant', 'eBooking', 'hyphen-', 'ated', 'only']), ('regression: slack separator', [[['on', 'ly'], ['of'], ['set'], ['in', 'ter', 'na', 'tion', 'al'], ['set'], ['the'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['e', 'Book', 'ing']], 12, 3, 4, 1, 2, True], ['only of set', 'internation-', 'al set the', 'important', 'eBooking e-', 'Booking']), ('regression: slack separator', [[['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']), ('regression: slack separator', [[['on', 'ly'], ['the'], ['of'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy']], 15, 4, 6, 1, 3, True], ['only the of', 'McDonald typo-', 'graphy']), ('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', [[['hy', 'phen', 'at', 'ed'], ['Ber', 'lin'], ['set'], ['e', 'Book', 'ing'], ['e', 'Book', 'ing'], ['the']], 8, 3, 6, 2, 3, True], ['hyphen-', 'ated', 'Berlin', 'set', 'eBooking', 'eBooking', 'the']), ('control layout', [[['of'], ['of'], ['set'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged']], 9, 1, 6, 3, 2, True], ['of of set', 'typogra-', 'phy rag-', 'ged'])], [('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['the'], ['a'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Mc', 'Don', 'ald'], ['set'], ['Ber', 'lin']], 15, 5, 7, 2, 3, False], ['hyphenated', 'international', 'the a the typo-', 'graphy McDonald', 'set Berlin']), ('regression: slack separator', [[['e', 'Book', 'ing'], ['im', 'por', 'tant'], ['of'], ['hy', 'phen', 'at', 'ed'], ['im', 'por', 'tant'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing']], 14, 5, 5, 1, 2, True], ['eBooking im-', 'portant of', 'hyphenated', 'important', 'hyphenated', 'eBooking']), ('regression: slack separator', [[['Mc', 'Don', 'ald'], ['of'], ['the'], ['Mc', 'Don', 'ald'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['hy', 'phen', 'at', 'ed'], ['on', 'ly']], 8, 4, 4, 1, 2, False], ['McDonald', 'of the', 'McDonald', 'impor-', 'tant', 'eBooking', 'hyphen-', 'ated', 'only']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('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', [[['on', 'ly'], ['the'], ['im', 'por', 'tant'], ['of']], 14, 1, 4, 3, 2, True], ['only the', 'important of']), ('control layout', [[['a'], ['Ber', 'lin'], ['on', 'ly'], ['e', 'Book', 'ing']], 8, 5, 5, 2, 3, True], ['a Berlin', 'only', 'eBooking'])], [('regression: slack separator', [[['the'], ['in', 'ter', 'na', 'tion', 'al'], ['on', 'ly'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy']], 14, 4, 4, 2, 2, False], ['the interna-', 'tional only', 'hyphenated', 'international', 'international', 'typography', 'typography']), ('regression: slack separator', [[['the'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['set'], ['rag', 'ged'], ['set'], ['Mc', 'Don', 'ald'], ['rag', 'ged']], 8, 5, 4, 1, 2, True], ['the', 'typogra-', 'phy', 'typogra-', 'phy set', 'ragged', 'set', 'McDonald', 'ragged']), ('regression: slack separator', [[['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al'], ['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['rag', 'ged'], ['rag', 'ged'], ['on', 'ly'], ['of'], ['hy', 'phen', 'at', 'ed']], 11, 5, 5, 2, 3, False], ['typography', 'interna-', 'tional', 'McDonald', 'Berlin', 'ragged', 'ragged only', 'of hyphen-', 'ated']), ('regression: slack separator', [[['in', 'ter', 'na', 'tion', 'al'], ['a'], ['on', 'ly'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy']], 9, 5, 5, 1, 2, False], ['interna-', 'tional a', 'only', 'interna-', 'tional', 'typogra-', 'phy']), ('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', [[['a'], ['e', 'Book', 'ing'], ['rag', 'ged'], ['e', 'Book', 'ing'], ['the'], ['of'], ['a'], ['ty', 'po', 'gra', 'phy']], 11, 4, 7, 2, 2, False], ['a eBooking', 'ragged', 'eBooking', 'the of a', 'typography']), ('control layout', [[['of'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['rag', 'ged'], ['hy', 'phen', 'at', 'ed'], ['a'], ['im', 'por', 'tant'], ['a'], ['Mc', 'Don', 'ald']], 9, 1, 7, 2, 2, False], ['of only', 'typogra-', 'phy', 'Berlin', 'ragged', 'hyphenat-', 'ed a im-', 'portant a', 'McDonald'])], [('regression: slack separator', [[['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['the'], ['hy', 'phen', 'at', 'ed'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['of']], 13, 3, 7, 1, 3, True], ['typography', 'typography', 'eBooking Mc-', 'Donald the', 'hyphenated', 'McDonald in-', 'ternational', 'typography of']), ('regression: slack separator', [[['the'], ['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['a'], ['Ber', 'lin'], ['a'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed'], ['ty', 'po', 'gra', 'phy']], 11, 5, 5, 2, 2, False], ['the', 'McDonald', 'Berlin a', 'Berlin a a', 'interna-', 'tional', 'hyphenated', 'typography']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('regression: slack separator', [[['Mc', 'Don', 'ald'], ['on', 'ly'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing'], ['Ber', 'lin'], ['on', 'ly'], ['rag', 'ged'], ['rag', 'ged'], ['im', 'por', 'tant']], 8, 4, 7, 1, 2, False], ['McDonald', 'only', 'Berlin', 'hyphen-', 'ated', 'eBooking', 'Berlin', 'only', 'ragged', 'ragged', 'impor-', 'tant']), ('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'], ['in', 'ter', 'na', 'tion', 'al'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['set'], ['hy', 'phen', 'at', 'ed'], ['of']], 11, 3, 4, 2, 2, False], ['the inter-', 'national', 'only typo-', 'graphy set', 'hyphenated', 'of']), ('control layout', [[['a'], ['rag', 'ged'], ['of'], ['of'], ['the'], ['of'], ['on', 'ly'], ['Mc', 'Don', 'ald'], ['the']], 11, 3, 7, 2, 2, False], ['a ragged of', 'of the of', 'only', 'McDonald', 'the'])]]
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: slack separator['McDonald', 'ragged', 'Berlin the', 'McDonald in-', 'ternational', 'ragged typo-', 'graphy in-', 'ternational']['McDonald', 'ragged', 'Berlin the', 'McDonald', 'interna-', 'tional rag-', 'ged typogra-', 'phy interna-', 'tional']Failed
regression: slack separator['a the hy-', 'phenated', 'a typo-', 'graphy', 'typogra-', 'phy', 'eBooking', 'important', 'important', 'interna-', 'tional']['a the', 'hyphen-', 'ated a', 'typogra-', 'phy typo-', 'graphy', 'eBooking', 'important', 'important', 'interna-', 'tional']Failed
regression: slack separator['hyphenated hy-', 'phenated inter-', 'national hy-', 'phenated']['hyphenated', 'hyphenated', 'international', 'hyphenated']Failed
partial-repair probe['ragged ty-', 'pography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional ty-', 'pography', 'hyphenated']['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']Failed
zone exactly met['the typo-', 'graphy']['the typo-', 'graphy']Passed
capitalised word protected['the', 'McDonald']['the', 'McDonald']Passed
control layout['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']Passed
control layout['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a']['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a']Passed

SHA-256 / a7b9822ca1b459a49b570a6e7a0145c80dc6e73dbdc0aa9d75f65dd5a1d8a904

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: slack separator', [[['Mc', 'Don', 'ald'], ['rag', 'ged'], ['Ber', 'lin'], ['the'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al']], 12, 4, 6, 2, 3, False], ['McDonald', 'ragged', 'Berlin the', 'McDonald', 'interna-', 'tional rag-', 'ged typogra-', 'phy interna-', 'tional']), ('regression: slack separator', [[['a'], ['the'], ['hy', 'phen', 'at', 'ed'], ['a'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['im', 'por', 'tant'], ['im', 'por', 'tant'], ['in', 'ter', 'na', 'tion', 'al']], 9, 4, 7, 2, 3, False], ['a the', 'hyphen-', 'ated a', 'typogra-', 'phy typo-', 'graphy', 'eBooking', 'important', 'important', 'interna-', 'tional']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('partial-repair probe', [[['rag', 'ged'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['Ber', 'lin'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['hy', 'phen', 'at', 'ed']], 10, 5, 5, 2, 2, False], ['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']), ('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', [[['on', 'ly'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy'], ['Mc', 'Don', 'ald'], ['Mc', 'Don', 'ald'], ['hy', 'phen', 'at', 'ed']], 13, 3, 6, 2, 2, False], ['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']), ('control layout', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['a'], ['im', 'por', 'tant'], ['the'], ['Ber', 'lin'], ['set'], ['a']], 13, 2, 6, 3, 2, False], ['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a'])], [('regression: slack separator', [[['Mc', 'Don', 'ald'], ['of'], ['the'], ['Mc', 'Don', 'ald'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['hy', 'phen', 'at', 'ed'], ['on', 'ly']], 8, 4, 4, 1, 2, False], ['McDonald', 'of the', 'McDonald', 'impor-', 'tant', 'eBooking', 'hyphen-', 'ated', 'only']), ('regression: slack separator', [[['on', 'ly'], ['of'], ['set'], ['in', 'ter', 'na', 'tion', 'al'], ['set'], ['the'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['e', 'Book', 'ing']], 12, 3, 4, 1, 2, True], ['only of set', 'internation-', 'al set the', 'important', 'eBooking e-', 'Booking']), ('regression: slack separator', [[['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']), ('regression: slack separator', [[['on', 'ly'], ['the'], ['of'], ['Mc', 'Don', 'ald'], ['ty', 'po', 'gra', 'phy']], 15, 4, 6, 1, 3, True], ['only the of', 'McDonald typo-', 'graphy']), ('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', [[['hy', 'phen', 'at', 'ed'], ['Ber', 'lin'], ['set'], ['e', 'Book', 'ing'], ['e', 'Book', 'ing'], ['the']], 8, 3, 6, 2, 3, True], ['hyphen-', 'ated', 'Berlin', 'set', 'eBooking', 'eBooking', 'the']), ('control layout', [[['of'], ['of'], ['set'], ['ty', 'po', 'gra', 'phy'], ['rag', 'ged']], 9, 1, 6, 3, 2, True], ['of of set', 'typogra-', 'phy rag-', 'ged'])], [('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['the'], ['a'], ['the'], ['ty', 'po', 'gra', 'phy'], ['Mc', 'Don', 'ald'], ['set'], ['Ber', 'lin']], 15, 5, 7, 2, 3, False], ['hyphenated', 'international', 'the a the typo-', 'graphy McDonald', 'set Berlin']), ('regression: slack separator', [[['e', 'Book', 'ing'], ['im', 'por', 'tant'], ['of'], ['hy', 'phen', 'at', 'ed'], ['im', 'por', 'tant'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing']], 14, 5, 5, 1, 2, True], ['eBooking im-', 'portant of', 'hyphenated', 'important', 'hyphenated', 'eBooking']), ('regression: slack separator', [[['Mc', 'Don', 'ald'], ['of'], ['the'], ['Mc', 'Don', 'ald'], ['im', 'por', 'tant'], ['e', 'Book', 'ing'], ['hy', 'phen', 'at', 'ed'], ['on', 'ly']], 8, 4, 4, 1, 2, False], ['McDonald', 'of the', 'McDonald', 'impor-', 'tant', 'eBooking', 'hyphen-', 'ated', 'only']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('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', [[['on', 'ly'], ['the'], ['im', 'por', 'tant'], ['of']], 14, 1, 4, 3, 2, True], ['only the', 'important of']), ('control layout', [[['a'], ['Ber', 'lin'], ['on', 'ly'], ['e', 'Book', 'ing']], 8, 5, 5, 2, 3, True], ['a Berlin', 'only', 'eBooking'])], [('regression: slack separator', [[['the'], ['in', 'ter', 'na', 'tion', 'al'], ['on', 'ly'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy']], 14, 4, 4, 2, 2, False], ['the interna-', 'tional only', 'hyphenated', 'international', 'international', 'typography', 'typography']), ('regression: slack separator', [[['the'], ['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['set'], ['rag', 'ged'], ['set'], ['Mc', 'Don', 'ald'], ['rag', 'ged']], 8, 5, 4, 1, 2, True], ['the', 'typogra-', 'phy', 'typogra-', 'phy set', 'ragged', 'set', 'McDonald', 'ragged']), ('regression: slack separator', [[['ty', 'po', 'gra', 'phy'], ['in', 'ter', 'na', 'tion', 'al'], ['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['rag', 'ged'], ['rag', 'ged'], ['on', 'ly'], ['of'], ['hy', 'phen', 'at', 'ed']], 11, 5, 5, 2, 3, False], ['typography', 'interna-', 'tional', 'McDonald', 'Berlin', 'ragged', 'ragged only', 'of hyphen-', 'ated']), ('regression: slack separator', [[['in', 'ter', 'na', 'tion', 'al'], ['a'], ['on', 'ly'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy']], 9, 5, 5, 1, 2, False], ['interna-', 'tional a', 'only', 'interna-', 'tional', 'typogra-', 'phy']), ('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', [[['a'], ['e', 'Book', 'ing'], ['rag', 'ged'], ['e', 'Book', 'ing'], ['the'], ['of'], ['a'], ['ty', 'po', 'gra', 'phy']], 11, 4, 7, 2, 2, False], ['a eBooking', 'ragged', 'eBooking', 'the of a', 'typography']), ('control layout', [[['of'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['Ber', 'lin'], ['rag', 'ged'], ['hy', 'phen', 'at', 'ed'], ['a'], ['im', 'por', 'tant'], ['a'], ['Mc', 'Don', 'ald']], 9, 1, 7, 2, 2, False], ['of only', 'typogra-', 'phy', 'Berlin', 'ragged', 'hyphenat-', 'ed a im-', 'portant a', 'McDonald'])], [('regression: slack separator', [[['ty', 'po', 'gra', 'phy'], ['ty', 'po', 'gra', 'phy'], ['e', 'Book', 'ing'], ['Mc', 'Don', 'ald'], ['the'], ['hy', 'phen', 'at', 'ed'], ['Mc', 'Don', 'ald'], ['in', 'ter', 'na', 'tion', 'al'], ['ty', 'po', 'gra', 'phy'], ['of']], 13, 3, 7, 1, 3, True], ['typography', 'typography', 'eBooking Mc-', 'Donald the', 'hyphenated', 'McDonald in-', 'ternational', 'typography of']), ('regression: slack separator', [[['the'], ['Mc', 'Don', 'ald'], ['Ber', 'lin'], ['a'], ['Ber', 'lin'], ['a'], ['a'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed'], ['ty', 'po', 'gra', 'phy']], 11, 5, 5, 2, 2, False], ['the', 'McDonald', 'Berlin a', 'Berlin a a', 'interna-', 'tional', 'hyphenated', 'typography']), ('regression: slack separator', [[['hy', 'phen', 'at', 'ed'], ['hy', 'phen', 'at', 'ed'], ['in', 'ter', 'na', 'tion', 'al'], ['hy', 'phen', 'at', 'ed']], 15, 5, 7, 2, 2, False], ['hyphenated', 'hyphenated', 'international', 'hyphenated']), ('regression: slack separator', [[['Mc', 'Don', 'ald'], ['on', 'ly'], ['Ber', 'lin'], ['hy', 'phen', 'at', 'ed'], ['e', 'Book', 'ing'], ['Ber', 'lin'], ['on', 'ly'], ['rag', 'ged'], ['rag', 'ged'], ['im', 'por', 'tant']], 8, 4, 7, 1, 2, False], ['McDonald', 'only', 'Berlin', 'hyphen-', 'ated', 'eBooking', 'Berlin', 'only', 'ragged', 'ragged', 'impor-', 'tant']), ('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'], ['in', 'ter', 'na', 'tion', 'al'], ['on', 'ly'], ['ty', 'po', 'gra', 'phy'], ['set'], ['hy', 'phen', 'at', 'ed'], ['of']], 11, 3, 4, 2, 2, False], ['the inter-', 'national', 'only typo-', 'graphy set', 'hyphenated', 'of']), ('control layout', [[['a'], ['rag', 'ged'], ['of'], ['of'], ['the'], ['of'], ['on', 'ly'], ['Mc', 'Don', 'ald'], ['the']], 11, 3, 7, 2, 2, False], ['a ragged of', 'of the of', 'only', 'McDonald', 'the'])]]
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: slack separator['McDonald', 'ragged', 'Berlin the', 'McDonald', 'interna-', 'tional rag-', 'ged typogra-', 'phy interna-', 'tional']['McDonald', 'ragged', 'Berlin the', 'McDonald', 'interna-', 'tional rag-', 'ged typogra-', 'phy interna-', 'tional']Passed
regression: slack separator['a the', 'hyphen-', 'ated a', 'typogra-', 'phy typo-', 'graphy', 'eBooking', 'important', 'important', 'interna-', 'tional']['a the', 'hyphen-', 'ated a', 'typogra-', 'phy typo-', 'graphy', 'eBooking', 'important', 'important', 'interna-', 'tional']Passed
regression: slack separator['hyphenated', 'hyphenated', 'international', 'hyphenated']['hyphenated', 'hyphenated', 'international', 'hyphenated']Passed
partial-repair probe['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']['ragged', 'typography', 'eBooking', 'Berlin', 'McDonald', 'interna-', 'tional', 'typography', 'hyphenated']Passed
zone exactly met['the typo-', 'graphy']['the typo-', 'graphy']Passed
capitalised word protected['the', 'McDonald']['the', 'McDonald']Passed
control layout['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']['only impor-', 'tant eBooking', 'McDonald ty-', 'pography', 'McDonald', 'McDonald hy-', 'phenated']Passed
control layout['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a']['hyphenated', 'hyphenated', 'international', 'a important', 'the Berlin', 'set a']Passed

SHA-256 / 9f648ab64f419523641e932c16486c07130f22895eec97e25c68d2643ad89223

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

Case digest / dd40cde11b9140ce4fd440ec38c355d2e32d6fbab5308d80e5a1b5153be77dd1