FAILURE MAP
← Case archive

FA-79931 / Typography line breaking / Open access

Pattern-based hyphenation: right hyphen minimum · case 01

The last legal hyphen before the word end is suppressed.

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

ROOT CAUSE

The right minimum requires strictly more than righthyphenmin trailing letters.

VERIFIED REPAIR

Require at least righthyphenmin letters after the hyphen.

Unsuccessful approach: Relaxing to rmin - 1 permits too-short word tails.

Case contract

Input [word, patterns, exceptions, lefthyphenmin, righthyphenmin]. An exception (hyphenated, lowercase) matching the lowercased word dictates the hyphens and keeps the word's own letters. Otherwise the lowercased word is padded with dots, every substring pattern contributes its digits and the maximum digit per gap wins; odd values allow a hyphen. A hyphen before letter i needs i>=lefthyphenmin and len-i>=righthyphenmin. Return the word with "-" inserted.

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):
    word, patterns, exceptions, lmin, rmin = x
    low = word.lower()
    for e in exceptions:
        if e.replace('-', '') == low:
            out, count = '', 0
            for c in e:
                if c == '-':
                    out += '-'
                else:
                    out += word[count]
                    count += 1
            return out
    table = {}
    for p in patterns:
        letters = ''
        vals = [0]
        for c in p:
            if c.isdigit():
                vals[-1] = int(c)
            else:
                letters += c
                vals.append(0)
        table[letters] = vals
    dotted = '.' + low + '.'
    score = [0] * (len(dotted) + 1)
    for s in range(len(dotted)):
        for e in range(s + 1, len(dotted) + 1):
            vals = table.get(dotted[s:e])
            if vals:
                for k, v in enumerate(vals):
                    score[s + k] = max(score[s + k], v)
    points = [i for i in range(1, len(word)) if score[i + 1] % 2 == 1 and i >= lmin and len(word) - i > rmin]
    out = ''
    for i, c in enumerate(word):
        if i in points:
            out += '-'
        out += c
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: right hyphen minimum', ['running', ['t1t', 'li1', 'b2l', 'm1m', '.un1', 'e2x', 'x1c', 'a2n', 'l1l', 'pu2', 's1s', 'n1g', 'o2n', 'hy3ph', '.re1', '2mp', 'gr2', '2io', '.ta4', '1m', 'at1', '1p', 'e1c', 'c2ce', '1tio', '5nd.', 'hena4', 'he2n', '1ble', 'ment1', '3ty.', 'p2h', 'ca1t', 'ter1', 'hen5at', 'om1', 'a1b', 'ex1', 'an1d', 'con1', '4ing.', 'r1r', '1na', '1q', '1ca', 'n2at', 'io3n.'], ['ex-cep-tion', 'ta-ble'], 2, 1], 'runnin-g'), ('regression: right hyphen minimum', ['Mississippi', ['1q', '1tio', 'n1g', 'e2x', 'ca1t', '1p', 'hen5at', 'hena4', 'gr2', 'n2at', 'an1d', 'x1c', 'ment1', 'r1r', 'io3n.', '.un1', '.re1', 'c2ce', '1ble', 'hy3ph', '3ty.', '5nd.', 'e1c', 't1t', 'pu2', '.ta4', 'm1m', 'b2l', 'o2n', 'a1b', 'li1', 'he2n', 's1s', '4ing.'], ['ex-cep-tion'], 1, 3], 'Mis-sis-si-ppi'), ('partial-repair probe', ['understand', ['io3n.', 'n1g', 'x1c', 'e1c', 'l1l', 'con1', 's1s', 'm1m', 'li1', '.re1', '2mp', 'ter1', '1ca', 'hena4', '5nd.', 'an1d', '3ty.', 'b2l', 't1t', 'ex1', 'c2ce', 'om1', '1tio', '4ing.', 'e2x', 'hy3ph', '1p', 'a1b', 'pu2', 'he2n', 'ment1', '1ble', 'gr2', 'hen5at', '.ta4', 'r1r', '.un1', '1m', 'n2at', 'ca1t', 'p2h', '1na', '2io', '1q'], ['ta-ble', 'gram-mar', 'ex-cep-tion'], 2, 3], 'un-derstand'), ('partial-repair probe', ['understand', ['ca1t', 'l1l', 'an1d', 'n2at', 'a2n', 'gr2', 'c2ce', '3ty.', '1m', 'r1r', '1na', '2mp', 'he2n', '4ing.', 'ter1', 'a1b', 'om1', 'e1c', 'hen5at', 'n1g', '1ca', 'm1m', '2io', 'b2l', '.un1', 'pu2', 'hena4', 'o2n', '1p'], ['mis-sis-sip-pi', 'ta-ble'], 3, 2], 'understand'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('right minimum boundary', ['category', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 1, 3], 'ca-t-egory'), ('control layout', ['connection', ['.un1', 'ment1', 'ter1', '.re1', '1m', '1q', 'a1b', 'hena4', 'e1c', 'm1m', '1ble', 'p2h', 'c2ce', 'o2n', 'n1g', 'pu2', 'e2x', '1tio', 'x1c', 'r1r', 's1s', 'om1', 'con1', 'ex1'], ['pro-ject', 'ta-ble'], 3, 1], 'con-ne-c-tion'), ('control layout', ['Exception', ['ex1', '2io', 'io3n.', 'x1c', 'pu2', 'at1', '1m', 'hy3ph', 'om1', 'n2at', '1na', '2mp', '1p', 'n1g', '1tio', '.un1', 'e1c', '.re1', 'c2ce', 'o2n', 'b2l', '1ca', 'l1l'], ['gram-mar', 'pro-ject', 'ex-cep-tion'], 3, 1], 'Ex-cep-tion')], [('regression: right hyphen minimum', ['running', ['e1c', 'at1', '5nd.', '1na', 'hena4', 'pu2', 'li1', 'r1r', '2mp', '.ta4', '2io', 'ment1', 'an1d', 't1t', 'p2h', '.re1', '1m', 'ter1', 'hy3ph', 'ex1', 'n2at', '1tio', 'om1', 'b2l', 'c2ce', '4ing.', 'io3n.', 'con1', 'a2n', 'gr2', '.un1', 'a1b', 'x1c', '1ca', 'o2n', 'm1m', 'n1g'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 1], 'runnin-g'), ('regression: right hyphen minimum', ['literally', ['n2at', 'c2ce', '1q', '5nd.', 'p2h', '1p', '2io', 'l1l', '1ble', 'con1', 'n1g', '.ta4', 'r1r', 'he2n', '4ing.', 'hen5at', '2mp', 's1s', 'om1', '3ty.', 'hy3ph', '.un1', 'x1c', 'io3n.', 'a1b', 'an1d', 't1t', '1tio', 'li1', 'm1m', '1ca', 'ex1', '1na', '.re1', 'at1', 'pu2', 'e1c', 'gr2', '1m'], [], 1, 2], 'li-teral-ly'), ('partial-repair probe', ['understand', ['ca1t', 'l1l', 'an1d', 'n2at', 'a2n', 'gr2', 'c2ce', '3ty.', '1m', 'r1r', '1na', '2mp', 'he2n', '4ing.', 'ter1', 'a1b', 'om1', 'e1c', 'hen5at', 'n1g', '1ca', 'm1m', '2io', 'b2l', '.un1', 'pu2', 'hena4', 'o2n', '1p'], ['mis-sis-sip-pi', 'ta-ble'], 3, 2], 'understand'), ('partial-repair probe', ['Paragraph', ['x1c', '1na', 'n1g', 'b2l', 'hen5at', '.un1', '.ta4', 'con1', '1q', 'a2n', 'hena4', 'gr2', 'a1b', 'm1m', 'r1r', '1ca', 'n2at', 'c2ce', 'e1c', '4ing.', '2io', 's1s', 'io3n.', 'ex1', 'hy3ph', 'an1d', 'o2n', '1p', 'he2n', 'om1', 't1t', '1m', '.re1', 'at1', 'li1', '1tio'], ['ta-ble', 'gram-mar'], 1, 3], 'Paragraph'), ('word-final pattern ing.', ['running', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 2], 'running'), ('left minimum boundary', ['excellent', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 3], 'ex-cel-lent'), ('control layout', ['project', ['hy3ph', 'x1c', '.un1', '.ta4', 'con1', 'ment1', 'pu2', 'l1l', 'ca1t', 'a2n', '3ty.', 'hen5at', 'e2x', 's1s', 'gr2', 'a1b', 'e1c', 'o2n', 'hena4', '1ca', 'c2ce', '1q', 'n1g', 't1t', 'io3n.', 'li1', '1p', '2mp', 'ex1', '4ing.', 'b2l', 'om1', '1ble', 'p2h', 'n2at', 'm1m', '.re1', '1na', '5nd.', 'an1d', '2io', 'ter1', '1m', 'he2n', '1tio'], ['pro-ject', 'ta-ble'], 1, 2], 'pro-ject'), ('control layout', ['computer', ['ment1', 'gr2', 'pu2', 'hy3ph', 'r1r', '2mp', 'o2n', 'c2ce', 'a2n', '2io', '.re1', 's1s', 'hen5at', '.un1', 'm1m', 'hena4', '4ing.', 'x1c', 'ex1', 'ca1t', 'a1b', 'io3n.', 'l1l', '5nd.', '1m', '3ty.', 'n2at', 'ter1', '1ble', '1q', '1p', 'b2l', 'li1', 'e1c', '1ca', 'he2n'], ['ta-ble'], 2, 3], 'com-puter')], [('regression: right hyphen minimum', ['grammar', ['1p', 'io3n.', 'r1r', '4ing.', 'li1', 'ca1t', 'e1c', '1m', 'ment1', '.ta4', 'hen5at', 'm1m', 'ex1', '.un1', 'at1', 'gr2', '1na', 'an1d', '3ty.', '.re1', 'l1l', '2mp', 'a2n', 'b2l', '2io', 'c2ce', 'n1g', 'he2n', 'o2n', '1ca', '1tio', '1q'], ['ta-ble', 'pro-ject'], 2, 3], 'gra-m-mar'), ('regression: right hyphen minimum', ['understand', ['b2l', '1ca', '1m', '1tio', '2mp', 'ment1', 't1t', '1p', '.ta4', 'li1', 'e1c', '1q', '4ing.', 'ex1', '5nd.', 'om1', 'o2n', 'hen5at', 'l1l', 'ter1', 'hena4', '.un1', 'r1r', 'pu2', 'p2h'], ['mis-sis-sip-pi'], 3, 2], 'understa-nd'), ('partial-repair probe', ['hyphenation', ['ter1', 'b2l', 'o2n', '5nd.', 'e1c', '.ta4', 'n1g', 'om1', 'hena4', 'pu2', 'l1l', 'a2n', 'r1r', 'hy3ph', 't1t', '.re1', '1p', 'e2x', '1q', 'ca1t', '3ty.', '2mp', '1m', 'ment1', '4ing.', 'x1c', '1ble', 'p2h', 'li1', 'c2ce', 'n2at', '2io', 'an1d', 'con1', 'io3n.', 'm1m', 'gr2', 'ex1', '1na'], ['gram-mar'], 2, 2], 'hy-phe-nation'), ('partial-repair probe', ['Paragraph', ['1na', '1ca', '2io', '3ty.', 'p2h', '1p', '.un1', 'a1b', 'an1d', 'li1', 'io3n.', '1m', 'a2n', 'n1g'], [], 1, 3], 'Paragraph'), ('lowercase exception', ['project', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['pro-ject'], 2, 3], 'pro-ject'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['Paragraph', ['1m', '2mp', '.ta4', 'hy3ph', 'pu2', 'e2x', 'om1', '1tio', 'at1', '.un1', 'n2at', '1na', 'hena4', 'r1r', 'ca1t', '1q', '2io', '.re1', 'a2n', 'n1g', 'o2n', 'ter1', 'l1l', 'x1c', 'p2h', 'con1', '5nd.', 'he2n', '4ing.', 'b2l', 'm1m', '1ble', '1p', 'c2ce', 's1s'], ['gram-mar', 'pro-ject'], 3, 1], 'Paragra-ph'), ('control layout', ['Recreation', ['li1', 'an1d', 'at1', '1ble', 'io3n.', 'a2n', 'e2x', '1tio', '.un1', '3ty.', 'r1r', '2io', 'e1c', 'he2n', '1m', 'om1', 'hen5at', '.ta4', 'n1g', 'a1b', 'ment1', 'p2h', '4ing.', '.re1', '1na', 'b2l', 'c2ce', 't1t'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 3], 'Re-crea-tion')], [('regression: right hyphen minimum', ['understand', ['hy3ph', 'ex1', 'p2h', 'e2x', 'm1m', 'hena4', 'an1d', '4ing.', 't1t', 'hen5at', 'a1b', 's1s', 'l1l', '.un1', 'n2at'], ['mis-sis-sip-pi', 'ex-cep-tion', 'pro-ject'], 2, 1], 'un-derstan-d'), ('regression: right hyphen minimum', ['Mississippi', ['5nd.', 'n2at', 'hena4', 'r1r', 'om1', 'e2x', 'hy3ph', 'an1d', '1p', 't1t', 'o2n', '.ta4', 'n1g', 'x1c', 'ter1', 's1s', 'li1', 'gr2', '2mp', '3ty.', 'p2h', 'c2ce', 'ex1', 'l1l', 'm1m', 'at1', 'a2n', '1ble', '4ing.', 'io3n.', '1tio', 'pu2', 'ca1t', '1m', 'a1b', 'con1', '.un1'], [], 1, 2], 'Mis-sis-si-p-pi'), ('partial-repair probe', ['Paragraph', ['s1s', 'io3n.', 'ca1t', 'x1c', 'hen5at', '.un1', '2mp', '4ing.', 'l1l', '1m', '1tio', 'gr2', 'b2l', '3ty.', 't1t', 'a1b', 'e1c', 'c2ce', 'pu2', 'ter1', 'o2n', '1q', 'r1r', '1p', 'm1m', 'n2at'], ['pro-ject'], 3, 3], 'Paragraph'), ('partial-repair probe', ['typesetting', ['he2n', '5nd.', 'x1c', '2mp', 'e1c', 'ment1', 'p2h', 'ca1t', 'a2n', 'hena4', '1tio', '.re1', 'gr2', 'hen5at', 'hy3ph', 'ex1', 'an1d', 'pu2', 'm1m', 't1t', '1ble', '1ca', 'b2l', 'n1g', '2io', 'r1r', '.un1', 'o2n', '4ing.', '.ta4', '1p', '3ty.', 'io3n.', 'e2x', 's1s', '1m', 'l1l', '1na', 'ter1'], [], 3, 2], 'typeset-ting'), ('left minimum boundary', ['excellent', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 3], 'ex-cel-lent'), ('right minimum boundary', ['category', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 1, 3], 'ca-t-egory'), ('control layout', ['Unexpected', ['1m', '1tio', 'ment1', 'm1m', 'c2ce', 'r1r', '1ca', '4ing.'], [], 1, 3], 'Unexpected'), ('control layout', ['battle', ['m1m', '3ty.', 'at1', '.un1', '2io', 'c2ce', '.ta4', 'gr2', 'an1d', '5nd.', 'a2n', 'he2n', 'p2h', 'li1', 'io3n.', '2mp', '4ing.', 't1t', '.re1', 'x1c', '1q', 'hena4', 'con1', 'n1g', 'a1b', 'n2at', 'e2x', 'om1', 'l1l', 'ter1', 'o2n', '1m', '1ble', 'ment1', '1p', 's1s', 'b2l', '1tio', '1ca', 'e1c', 'hy3ph', 'r1r', 'ex1', 'ca1t'], ['mis-sis-sip-pi', 'pro-ject'], 3, 2], 'bat-tle')], [('regression: right hyphen minimum', ['hyphenation', ['a2n', 'at1', 'e1c', '1tio', 'p2h', 'n2at', 'gr2', 'pu2', '.re1', 'an1d', 'ca1t', 'e2x', 't1t', 'l1l', '1ca', 'n1g', '1p', 'li1', '3ty.', 'hy3ph', '5nd.', '.un1', 'c2ce', '.ta4', 'om1', '1na'], ['pro-ject', 'gram-mar'], 1, 3], 'hy-phe-na-t-ion'), ('regression: right hyphen minimum', ['hyphenation', ['5nd.', 'om1', 'm1m', '1ca', 'a2n', '.ta4', 'o2n', 'an1d', 'ca1t', 'x1c', 'ter1', 'p2h', '1tio', 'n2at', 'hena4', '1ble', 'ex1', 'n1g', 's1s', 'io3n.', '1q', '2io', 'e2x', 'r1r', '1p', 't1t', 'gr2', 'ment1', 'hy3ph', 'l1l', '4ing.', '1m', 'pu2', '2mp', 'a1b', 'con1', 'b2l', '.re1', 'li1', '3ty.'], ['gram-mar', 'mis-sis-sip-pi', 'ta-ble'], 2, 1], 'hy-phenatio-n'), ('partial-repair probe', ['understand', ['1na', 'ment1', 'x1c', 'l1l', 'b2l', '.un1', 'gr2', 'an1d', '1p', '2mp', '2io', '1q', 'hen5at', 'hy3ph', 'a1b', 'n2at', 'om1', '5nd.', '3ty.', 'ex1', 'he2n', 'n1g', 'at1', 'ter1'], [], 1, 3], 'un-derstand'), ('partial-repair probe', ['running', ['p2h', '1m', '5nd.', 'c2ce', '1q', 'hen5at', '1ca', 'ment1', 's1s', 'io3n.', 'ex1', 'x1c', 'he2n', 'hy3ph', 'e2x', '2mp', '1tio', 'a2n', 'l1l', '1na', 'm1m', '3ty.', 'at1', 'ter1', 't1t', 'gr2', 'om1', '.ta4', 'ca1t', 'n2at', 'e1c', 'b2l', 'r1r', 'o2n', '1ble', '2io', '4ing.', 'con1', 'pu2', 'n1g', '.un1', 'hena4', 'a1b', '.re1', 'an1d'], ['gram-mar', 'mis-sis-sip-pi', 'pro-ject'], 2, 2], 'running'), ('word-final pattern ing.', ['running', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 2], 'running'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['Paragraph', ['1ble', 'e2x', 'hena4', '1p', '3ty.', 'hy3ph', 's1s', 'n1g', '.ta4', 'io3n.', '2io', '.un1', 'at1'], [], 3, 1], 'Paragra-ph'), ('control layout', ['Table', ['ment1', 'o2n', '1ca', 'n2at', '5nd.', 'x1c', '2io', 'hena4', 'con1', 'l1l', 'ter1', 'r1r', 't1t', 'hen5at', '.un1', 'io3n.', '1m', '1tio', 'm1m', 'e1c', 'ca1t', 'p2h', '.re1', 'a2n', 'pu2', 'an1d'], [], 1, 3], 'Table')]]
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: right hyphen minimumrunningrunnin-gFailed
regression: right hyphen minimumMis-sis-sippiMis-sis-si-ppiFailed
partial-repair probeun-derstandun-derstandPassed
partial-repair probeunderstandunderstandPassed
capitalised exceptionTa-bleTa-blePassed
right minimum boundaryca-t-egoryca-t-egoryPassed
control layoutcon-ne-c-tioncon-ne-c-tionPassed
control layoutEx-cep-tionEx-cep-tionPassed

SHA-256 / cfad5106d361aabe8eae31c1714584bb92a8d9892349d986ff3ee5e029abee4e

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    word, patterns, exceptions, lmin, rmin = x
    low = word.lower()
    for e in exceptions:
        if e.replace('-', '') == low:
            out, count = '', 0
            for c in e:
                if c == '-':
                    out += '-'
                else:
                    out += word[count]
                    count += 1
            return out
    table = {}
    for p in patterns:
        letters = ''
        vals = [0]
        for c in p:
            if c.isdigit():
                vals[-1] = int(c)
            else:
                letters += c
                vals.append(0)
        table[letters] = vals
    dotted = '.' + low + '.'
    score = [0] * (len(dotted) + 1)
    for s in range(len(dotted)):
        for e in range(s + 1, len(dotted) + 1):
            vals = table.get(dotted[s:e])
            if vals:
                for k, v in enumerate(vals):
                    score[s + k] = max(score[s + k], v)
    points = [i for i in range(1, len(word)) if score[i + 1] % 2 == 1 and i >= lmin and len(word) - i >= rmin - 1]
    out = ''
    for i, c in enumerate(word):
        if i in points:
            out += '-'
        out += c
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: right hyphen minimum', ['running', ['t1t', 'li1', 'b2l', 'm1m', '.un1', 'e2x', 'x1c', 'a2n', 'l1l', 'pu2', 's1s', 'n1g', 'o2n', 'hy3ph', '.re1', '2mp', 'gr2', '2io', '.ta4', '1m', 'at1', '1p', 'e1c', 'c2ce', '1tio', '5nd.', 'hena4', 'he2n', '1ble', 'ment1', '3ty.', 'p2h', 'ca1t', 'ter1', 'hen5at', 'om1', 'a1b', 'ex1', 'an1d', 'con1', '4ing.', 'r1r', '1na', '1q', '1ca', 'n2at', 'io3n.'], ['ex-cep-tion', 'ta-ble'], 2, 1], 'runnin-g'), ('regression: right hyphen minimum', ['Mississippi', ['1q', '1tio', 'n1g', 'e2x', 'ca1t', '1p', 'hen5at', 'hena4', 'gr2', 'n2at', 'an1d', 'x1c', 'ment1', 'r1r', 'io3n.', '.un1', '.re1', 'c2ce', '1ble', 'hy3ph', '3ty.', '5nd.', 'e1c', 't1t', 'pu2', '.ta4', 'm1m', 'b2l', 'o2n', 'a1b', 'li1', 'he2n', 's1s', '4ing.'], ['ex-cep-tion'], 1, 3], 'Mis-sis-si-ppi'), ('partial-repair probe', ['understand', ['io3n.', 'n1g', 'x1c', 'e1c', 'l1l', 'con1', 's1s', 'm1m', 'li1', '.re1', '2mp', 'ter1', '1ca', 'hena4', '5nd.', 'an1d', '3ty.', 'b2l', 't1t', 'ex1', 'c2ce', 'om1', '1tio', '4ing.', 'e2x', 'hy3ph', '1p', 'a1b', 'pu2', 'he2n', 'ment1', '1ble', 'gr2', 'hen5at', '.ta4', 'r1r', '.un1', '1m', 'n2at', 'ca1t', 'p2h', '1na', '2io', '1q'], ['ta-ble', 'gram-mar', 'ex-cep-tion'], 2, 3], 'un-derstand'), ('partial-repair probe', ['understand', ['ca1t', 'l1l', 'an1d', 'n2at', 'a2n', 'gr2', 'c2ce', '3ty.', '1m', 'r1r', '1na', '2mp', 'he2n', '4ing.', 'ter1', 'a1b', 'om1', 'e1c', 'hen5at', 'n1g', '1ca', 'm1m', '2io', 'b2l', '.un1', 'pu2', 'hena4', 'o2n', '1p'], ['mis-sis-sip-pi', 'ta-ble'], 3, 2], 'understand'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('right minimum boundary', ['category', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 1, 3], 'ca-t-egory'), ('control layout', ['connection', ['.un1', 'ment1', 'ter1', '.re1', '1m', '1q', 'a1b', 'hena4', 'e1c', 'm1m', '1ble', 'p2h', 'c2ce', 'o2n', 'n1g', 'pu2', 'e2x', '1tio', 'x1c', 'r1r', 's1s', 'om1', 'con1', 'ex1'], ['pro-ject', 'ta-ble'], 3, 1], 'con-ne-c-tion'), ('control layout', ['Exception', ['ex1', '2io', 'io3n.', 'x1c', 'pu2', 'at1', '1m', 'hy3ph', 'om1', 'n2at', '1na', '2mp', '1p', 'n1g', '1tio', '.un1', 'e1c', '.re1', 'c2ce', 'o2n', 'b2l', '1ca', 'l1l'], ['gram-mar', 'pro-ject', 'ex-cep-tion'], 3, 1], 'Ex-cep-tion')], [('regression: right hyphen minimum', ['running', ['e1c', 'at1', '5nd.', '1na', 'hena4', 'pu2', 'li1', 'r1r', '2mp', '.ta4', '2io', 'ment1', 'an1d', 't1t', 'p2h', '.re1', '1m', 'ter1', 'hy3ph', 'ex1', 'n2at', '1tio', 'om1', 'b2l', 'c2ce', '4ing.', 'io3n.', 'con1', 'a2n', 'gr2', '.un1', 'a1b', 'x1c', '1ca', 'o2n', 'm1m', 'n1g'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 1], 'runnin-g'), ('regression: right hyphen minimum', ['literally', ['n2at', 'c2ce', '1q', '5nd.', 'p2h', '1p', '2io', 'l1l', '1ble', 'con1', 'n1g', '.ta4', 'r1r', 'he2n', '4ing.', 'hen5at', '2mp', 's1s', 'om1', '3ty.', 'hy3ph', '.un1', 'x1c', 'io3n.', 'a1b', 'an1d', 't1t', '1tio', 'li1', 'm1m', '1ca', 'ex1', '1na', '.re1', 'at1', 'pu2', 'e1c', 'gr2', '1m'], [], 1, 2], 'li-teral-ly'), ('partial-repair probe', ['understand', ['ca1t', 'l1l', 'an1d', 'n2at', 'a2n', 'gr2', 'c2ce', '3ty.', '1m', 'r1r', '1na', '2mp', 'he2n', '4ing.', 'ter1', 'a1b', 'om1', 'e1c', 'hen5at', 'n1g', '1ca', 'm1m', '2io', 'b2l', '.un1', 'pu2', 'hena4', 'o2n', '1p'], ['mis-sis-sip-pi', 'ta-ble'], 3, 2], 'understand'), ('partial-repair probe', ['Paragraph', ['x1c', '1na', 'n1g', 'b2l', 'hen5at', '.un1', '.ta4', 'con1', '1q', 'a2n', 'hena4', 'gr2', 'a1b', 'm1m', 'r1r', '1ca', 'n2at', 'c2ce', 'e1c', '4ing.', '2io', 's1s', 'io3n.', 'ex1', 'hy3ph', 'an1d', 'o2n', '1p', 'he2n', 'om1', 't1t', '1m', '.re1', 'at1', 'li1', '1tio'], ['ta-ble', 'gram-mar'], 1, 3], 'Paragraph'), ('word-final pattern ing.', ['running', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 2], 'running'), ('left minimum boundary', ['excellent', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 3], 'ex-cel-lent'), ('control layout', ['project', ['hy3ph', 'x1c', '.un1', '.ta4', 'con1', 'ment1', 'pu2', 'l1l', 'ca1t', 'a2n', '3ty.', 'hen5at', 'e2x', 's1s', 'gr2', 'a1b', 'e1c', 'o2n', 'hena4', '1ca', 'c2ce', '1q', 'n1g', 't1t', 'io3n.', 'li1', '1p', '2mp', 'ex1', '4ing.', 'b2l', 'om1', '1ble', 'p2h', 'n2at', 'm1m', '.re1', '1na', '5nd.', 'an1d', '2io', 'ter1', '1m', 'he2n', '1tio'], ['pro-ject', 'ta-ble'], 1, 2], 'pro-ject'), ('control layout', ['computer', ['ment1', 'gr2', 'pu2', 'hy3ph', 'r1r', '2mp', 'o2n', 'c2ce', 'a2n', '2io', '.re1', 's1s', 'hen5at', '.un1', 'm1m', 'hena4', '4ing.', 'x1c', 'ex1', 'ca1t', 'a1b', 'io3n.', 'l1l', '5nd.', '1m', '3ty.', 'n2at', 'ter1', '1ble', '1q', '1p', 'b2l', 'li1', 'e1c', '1ca', 'he2n'], ['ta-ble'], 2, 3], 'com-puter')], [('regression: right hyphen minimum', ['grammar', ['1p', 'io3n.', 'r1r', '4ing.', 'li1', 'ca1t', 'e1c', '1m', 'ment1', '.ta4', 'hen5at', 'm1m', 'ex1', '.un1', 'at1', 'gr2', '1na', 'an1d', '3ty.', '.re1', 'l1l', '2mp', 'a2n', 'b2l', '2io', 'c2ce', 'n1g', 'he2n', 'o2n', '1ca', '1tio', '1q'], ['ta-ble', 'pro-ject'], 2, 3], 'gra-m-mar'), ('regression: right hyphen minimum', ['understand', ['b2l', '1ca', '1m', '1tio', '2mp', 'ment1', 't1t', '1p', '.ta4', 'li1', 'e1c', '1q', '4ing.', 'ex1', '5nd.', 'om1', 'o2n', 'hen5at', 'l1l', 'ter1', 'hena4', '.un1', 'r1r', 'pu2', 'p2h'], ['mis-sis-sip-pi'], 3, 2], 'understa-nd'), ('partial-repair probe', ['hyphenation', ['ter1', 'b2l', 'o2n', '5nd.', 'e1c', '.ta4', 'n1g', 'om1', 'hena4', 'pu2', 'l1l', 'a2n', 'r1r', 'hy3ph', 't1t', '.re1', '1p', 'e2x', '1q', 'ca1t', '3ty.', '2mp', '1m', 'ment1', '4ing.', 'x1c', '1ble', 'p2h', 'li1', 'c2ce', 'n2at', '2io', 'an1d', 'con1', 'io3n.', 'm1m', 'gr2', 'ex1', '1na'], ['gram-mar'], 2, 2], 'hy-phe-nation'), ('partial-repair probe', ['Paragraph', ['1na', '1ca', '2io', '3ty.', 'p2h', '1p', '.un1', 'a1b', 'an1d', 'li1', 'io3n.', '1m', 'a2n', 'n1g'], [], 1, 3], 'Paragraph'), ('lowercase exception', ['project', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['pro-ject'], 2, 3], 'pro-ject'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['Paragraph', ['1m', '2mp', '.ta4', 'hy3ph', 'pu2', 'e2x', 'om1', '1tio', 'at1', '.un1', 'n2at', '1na', 'hena4', 'r1r', 'ca1t', '1q', '2io', '.re1', 'a2n', 'n1g', 'o2n', 'ter1', 'l1l', 'x1c', 'p2h', 'con1', '5nd.', 'he2n', '4ing.', 'b2l', 'm1m', '1ble', '1p', 'c2ce', 's1s'], ['gram-mar', 'pro-ject'], 3, 1], 'Paragra-ph'), ('control layout', ['Recreation', ['li1', 'an1d', 'at1', '1ble', 'io3n.', 'a2n', 'e2x', '1tio', '.un1', '3ty.', 'r1r', '2io', 'e1c', 'he2n', '1m', 'om1', 'hen5at', '.ta4', 'n1g', 'a1b', 'ment1', 'p2h', '4ing.', '.re1', '1na', 'b2l', 'c2ce', 't1t'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 3], 'Re-crea-tion')], [('regression: right hyphen minimum', ['understand', ['hy3ph', 'ex1', 'p2h', 'e2x', 'm1m', 'hena4', 'an1d', '4ing.', 't1t', 'hen5at', 'a1b', 's1s', 'l1l', '.un1', 'n2at'], ['mis-sis-sip-pi', 'ex-cep-tion', 'pro-ject'], 2, 1], 'un-derstan-d'), ('regression: right hyphen minimum', ['Mississippi', ['5nd.', 'n2at', 'hena4', 'r1r', 'om1', 'e2x', 'hy3ph', 'an1d', '1p', 't1t', 'o2n', '.ta4', 'n1g', 'x1c', 'ter1', 's1s', 'li1', 'gr2', '2mp', '3ty.', 'p2h', 'c2ce', 'ex1', 'l1l', 'm1m', 'at1', 'a2n', '1ble', '4ing.', 'io3n.', '1tio', 'pu2', 'ca1t', '1m', 'a1b', 'con1', '.un1'], [], 1, 2], 'Mis-sis-si-p-pi'), ('partial-repair probe', ['Paragraph', ['s1s', 'io3n.', 'ca1t', 'x1c', 'hen5at', '.un1', '2mp', '4ing.', 'l1l', '1m', '1tio', 'gr2', 'b2l', '3ty.', 't1t', 'a1b', 'e1c', 'c2ce', 'pu2', 'ter1', 'o2n', '1q', 'r1r', '1p', 'm1m', 'n2at'], ['pro-ject'], 3, 3], 'Paragraph'), ('partial-repair probe', ['typesetting', ['he2n', '5nd.', 'x1c', '2mp', 'e1c', 'ment1', 'p2h', 'ca1t', 'a2n', 'hena4', '1tio', '.re1', 'gr2', 'hen5at', 'hy3ph', 'ex1', 'an1d', 'pu2', 'm1m', 't1t', '1ble', '1ca', 'b2l', 'n1g', '2io', 'r1r', '.un1', 'o2n', '4ing.', '.ta4', '1p', '3ty.', 'io3n.', 'e2x', 's1s', '1m', 'l1l', '1na', 'ter1'], [], 3, 2], 'typeset-ting'), ('left minimum boundary', ['excellent', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 3], 'ex-cel-lent'), ('right minimum boundary', ['category', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 1, 3], 'ca-t-egory'), ('control layout', ['Unexpected', ['1m', '1tio', 'ment1', 'm1m', 'c2ce', 'r1r', '1ca', '4ing.'], [], 1, 3], 'Unexpected'), ('control layout', ['battle', ['m1m', '3ty.', 'at1', '.un1', '2io', 'c2ce', '.ta4', 'gr2', 'an1d', '5nd.', 'a2n', 'he2n', 'p2h', 'li1', 'io3n.', '2mp', '4ing.', 't1t', '.re1', 'x1c', '1q', 'hena4', 'con1', 'n1g', 'a1b', 'n2at', 'e2x', 'om1', 'l1l', 'ter1', 'o2n', '1m', '1ble', 'ment1', '1p', 's1s', 'b2l', '1tio', '1ca', 'e1c', 'hy3ph', 'r1r', 'ex1', 'ca1t'], ['mis-sis-sip-pi', 'pro-ject'], 3, 2], 'bat-tle')], [('regression: right hyphen minimum', ['hyphenation', ['a2n', 'at1', 'e1c', '1tio', 'p2h', 'n2at', 'gr2', 'pu2', '.re1', 'an1d', 'ca1t', 'e2x', 't1t', 'l1l', '1ca', 'n1g', '1p', 'li1', '3ty.', 'hy3ph', '5nd.', '.un1', 'c2ce', '.ta4', 'om1', '1na'], ['pro-ject', 'gram-mar'], 1, 3], 'hy-phe-na-t-ion'), ('regression: right hyphen minimum', ['hyphenation', ['5nd.', 'om1', 'm1m', '1ca', 'a2n', '.ta4', 'o2n', 'an1d', 'ca1t', 'x1c', 'ter1', 'p2h', '1tio', 'n2at', 'hena4', '1ble', 'ex1', 'n1g', 's1s', 'io3n.', '1q', '2io', 'e2x', 'r1r', '1p', 't1t', 'gr2', 'ment1', 'hy3ph', 'l1l', '4ing.', '1m', 'pu2', '2mp', 'a1b', 'con1', 'b2l', '.re1', 'li1', '3ty.'], ['gram-mar', 'mis-sis-sip-pi', 'ta-ble'], 2, 1], 'hy-phenatio-n'), ('partial-repair probe', ['understand', ['1na', 'ment1', 'x1c', 'l1l', 'b2l', '.un1', 'gr2', 'an1d', '1p', '2mp', '2io', '1q', 'hen5at', 'hy3ph', 'a1b', 'n2at', 'om1', '5nd.', '3ty.', 'ex1', 'he2n', 'n1g', 'at1', 'ter1'], [], 1, 3], 'un-derstand'), ('partial-repair probe', ['running', ['p2h', '1m', '5nd.', 'c2ce', '1q', 'hen5at', '1ca', 'ment1', 's1s', 'io3n.', 'ex1', 'x1c', 'he2n', 'hy3ph', 'e2x', '2mp', '1tio', 'a2n', 'l1l', '1na', 'm1m', '3ty.', 'at1', 'ter1', 't1t', 'gr2', 'om1', '.ta4', 'ca1t', 'n2at', 'e1c', 'b2l', 'r1r', 'o2n', '1ble', '2io', '4ing.', 'con1', 'pu2', 'n1g', '.un1', 'hena4', 'a1b', '.re1', 'an1d'], ['gram-mar', 'mis-sis-sip-pi', 'pro-ject'], 2, 2], 'running'), ('word-final pattern ing.', ['running', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 2], 'running'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['Paragraph', ['1ble', 'e2x', 'hena4', '1p', '3ty.', 'hy3ph', 's1s', 'n1g', '.ta4', 'io3n.', '2io', '.un1', 'at1'], [], 3, 1], 'Paragra-ph'), ('control layout', ['Table', ['ment1', 'o2n', '1ca', 'n2at', '5nd.', 'x1c', '2io', 'hena4', 'con1', 'l1l', 'ter1', 'r1r', 't1t', 'hen5at', '.un1', 'io3n.', '1m', '1tio', 'm1m', 'e1c', 'ca1t', 'p2h', '.re1', 'a2n', 'pu2', 'an1d'], [], 1, 3], 'Table')]]
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: right hyphen minimumrunnin-grunnin-gPassed
regression: right hyphen minimumMis-sis-si-p-piMis-sis-si-ppiFailed
partial-repair probeun-dersta-ndun-derstandFailed
partial-repair probeunderstan-dunderstandFailed
capitalised exceptionTa-bleTa-blePassed
right minimum boundaryca-t-egoryca-t-egoryPassed
control layoutcon-ne-c-tioncon-ne-c-tionPassed
control layoutEx-cep-tionEx-cep-tionPassed

SHA-256 / 944fd35b46f8bd9c4a60ed8a0b559cce7a95c5c7c710ca88fe90b14f7c847dc7

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    word, patterns, exceptions, lmin, rmin = x
    low = word.lower()
    for e in exceptions:
        if e.replace('-', '') == low:
            out, count = '', 0
            for c in e:
                if c == '-':
                    out += '-'
                else:
                    out += word[count]
                    count += 1
            return out
    table = {}
    for p in patterns:
        letters = ''
        vals = [0]
        for c in p:
            if c.isdigit():
                vals[-1] = int(c)
            else:
                letters += c
                vals.append(0)
        table[letters] = vals
    dotted = '.' + low + '.'
    score = [0] * (len(dotted) + 1)
    for s in range(len(dotted)):
        for e in range(s + 1, len(dotted) + 1):
            vals = table.get(dotted[s:e])
            if vals:
                for k, v in enumerate(vals):
                    score[s + k] = max(score[s + k], v)
    points = [i for i in range(1, len(word)) if score[i + 1] % 2 == 1 and i >= lmin and len(word) - i >= rmin]
    out = ''
    for i, c in enumerate(word):
        if i in points:
            out += '-'
        out += c
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: right hyphen minimum', ['running', ['t1t', 'li1', 'b2l', 'm1m', '.un1', 'e2x', 'x1c', 'a2n', 'l1l', 'pu2', 's1s', 'n1g', 'o2n', 'hy3ph', '.re1', '2mp', 'gr2', '2io', '.ta4', '1m', 'at1', '1p', 'e1c', 'c2ce', '1tio', '5nd.', 'hena4', 'he2n', '1ble', 'ment1', '3ty.', 'p2h', 'ca1t', 'ter1', 'hen5at', 'om1', 'a1b', 'ex1', 'an1d', 'con1', '4ing.', 'r1r', '1na', '1q', '1ca', 'n2at', 'io3n.'], ['ex-cep-tion', 'ta-ble'], 2, 1], 'runnin-g'), ('regression: right hyphen minimum', ['Mississippi', ['1q', '1tio', 'n1g', 'e2x', 'ca1t', '1p', 'hen5at', 'hena4', 'gr2', 'n2at', 'an1d', 'x1c', 'ment1', 'r1r', 'io3n.', '.un1', '.re1', 'c2ce', '1ble', 'hy3ph', '3ty.', '5nd.', 'e1c', 't1t', 'pu2', '.ta4', 'm1m', 'b2l', 'o2n', 'a1b', 'li1', 'he2n', 's1s', '4ing.'], ['ex-cep-tion'], 1, 3], 'Mis-sis-si-ppi'), ('partial-repair probe', ['understand', ['io3n.', 'n1g', 'x1c', 'e1c', 'l1l', 'con1', 's1s', 'm1m', 'li1', '.re1', '2mp', 'ter1', '1ca', 'hena4', '5nd.', 'an1d', '3ty.', 'b2l', 't1t', 'ex1', 'c2ce', 'om1', '1tio', '4ing.', 'e2x', 'hy3ph', '1p', 'a1b', 'pu2', 'he2n', 'ment1', '1ble', 'gr2', 'hen5at', '.ta4', 'r1r', '.un1', '1m', 'n2at', 'ca1t', 'p2h', '1na', '2io', '1q'], ['ta-ble', 'gram-mar', 'ex-cep-tion'], 2, 3], 'un-derstand'), ('partial-repair probe', ['understand', ['ca1t', 'l1l', 'an1d', 'n2at', 'a2n', 'gr2', 'c2ce', '3ty.', '1m', 'r1r', '1na', '2mp', 'he2n', '4ing.', 'ter1', 'a1b', 'om1', 'e1c', 'hen5at', 'n1g', '1ca', 'm1m', '2io', 'b2l', '.un1', 'pu2', 'hena4', 'o2n', '1p'], ['mis-sis-sip-pi', 'ta-ble'], 3, 2], 'understand'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('right minimum boundary', ['category', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 1, 3], 'ca-t-egory'), ('control layout', ['connection', ['.un1', 'ment1', 'ter1', '.re1', '1m', '1q', 'a1b', 'hena4', 'e1c', 'm1m', '1ble', 'p2h', 'c2ce', 'o2n', 'n1g', 'pu2', 'e2x', '1tio', 'x1c', 'r1r', 's1s', 'om1', 'con1', 'ex1'], ['pro-ject', 'ta-ble'], 3, 1], 'con-ne-c-tion'), ('control layout', ['Exception', ['ex1', '2io', 'io3n.', 'x1c', 'pu2', 'at1', '1m', 'hy3ph', 'om1', 'n2at', '1na', '2mp', '1p', 'n1g', '1tio', '.un1', 'e1c', '.re1', 'c2ce', 'o2n', 'b2l', '1ca', 'l1l'], ['gram-mar', 'pro-ject', 'ex-cep-tion'], 3, 1], 'Ex-cep-tion')], [('regression: right hyphen minimum', ['running', ['e1c', 'at1', '5nd.', '1na', 'hena4', 'pu2', 'li1', 'r1r', '2mp', '.ta4', '2io', 'ment1', 'an1d', 't1t', 'p2h', '.re1', '1m', 'ter1', 'hy3ph', 'ex1', 'n2at', '1tio', 'om1', 'b2l', 'c2ce', '4ing.', 'io3n.', 'con1', 'a2n', 'gr2', '.un1', 'a1b', 'x1c', '1ca', 'o2n', 'm1m', 'n1g'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 1], 'runnin-g'), ('regression: right hyphen minimum', ['literally', ['n2at', 'c2ce', '1q', '5nd.', 'p2h', '1p', '2io', 'l1l', '1ble', 'con1', 'n1g', '.ta4', 'r1r', 'he2n', '4ing.', 'hen5at', '2mp', 's1s', 'om1', '3ty.', 'hy3ph', '.un1', 'x1c', 'io3n.', 'a1b', 'an1d', 't1t', '1tio', 'li1', 'm1m', '1ca', 'ex1', '1na', '.re1', 'at1', 'pu2', 'e1c', 'gr2', '1m'], [], 1, 2], 'li-teral-ly'), ('partial-repair probe', ['understand', ['ca1t', 'l1l', 'an1d', 'n2at', 'a2n', 'gr2', 'c2ce', '3ty.', '1m', 'r1r', '1na', '2mp', 'he2n', '4ing.', 'ter1', 'a1b', 'om1', 'e1c', 'hen5at', 'n1g', '1ca', 'm1m', '2io', 'b2l', '.un1', 'pu2', 'hena4', 'o2n', '1p'], ['mis-sis-sip-pi', 'ta-ble'], 3, 2], 'understand'), ('partial-repair probe', ['Paragraph', ['x1c', '1na', 'n1g', 'b2l', 'hen5at', '.un1', '.ta4', 'con1', '1q', 'a2n', 'hena4', 'gr2', 'a1b', 'm1m', 'r1r', '1ca', 'n2at', 'c2ce', 'e1c', '4ing.', '2io', 's1s', 'io3n.', 'ex1', 'hy3ph', 'an1d', 'o2n', '1p', 'he2n', 'om1', 't1t', '1m', '.re1', 'at1', 'li1', '1tio'], ['ta-ble', 'gram-mar'], 1, 3], 'Paragraph'), ('word-final pattern ing.', ['running', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 2], 'running'), ('left minimum boundary', ['excellent', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 3], 'ex-cel-lent'), ('control layout', ['project', ['hy3ph', 'x1c', '.un1', '.ta4', 'con1', 'ment1', 'pu2', 'l1l', 'ca1t', 'a2n', '3ty.', 'hen5at', 'e2x', 's1s', 'gr2', 'a1b', 'e1c', 'o2n', 'hena4', '1ca', 'c2ce', '1q', 'n1g', 't1t', 'io3n.', 'li1', '1p', '2mp', 'ex1', '4ing.', 'b2l', 'om1', '1ble', 'p2h', 'n2at', 'm1m', '.re1', '1na', '5nd.', 'an1d', '2io', 'ter1', '1m', 'he2n', '1tio'], ['pro-ject', 'ta-ble'], 1, 2], 'pro-ject'), ('control layout', ['computer', ['ment1', 'gr2', 'pu2', 'hy3ph', 'r1r', '2mp', 'o2n', 'c2ce', 'a2n', '2io', '.re1', 's1s', 'hen5at', '.un1', 'm1m', 'hena4', '4ing.', 'x1c', 'ex1', 'ca1t', 'a1b', 'io3n.', 'l1l', '5nd.', '1m', '3ty.', 'n2at', 'ter1', '1ble', '1q', '1p', 'b2l', 'li1', 'e1c', '1ca', 'he2n'], ['ta-ble'], 2, 3], 'com-puter')], [('regression: right hyphen minimum', ['grammar', ['1p', 'io3n.', 'r1r', '4ing.', 'li1', 'ca1t', 'e1c', '1m', 'ment1', '.ta4', 'hen5at', 'm1m', 'ex1', '.un1', 'at1', 'gr2', '1na', 'an1d', '3ty.', '.re1', 'l1l', '2mp', 'a2n', 'b2l', '2io', 'c2ce', 'n1g', 'he2n', 'o2n', '1ca', '1tio', '1q'], ['ta-ble', 'pro-ject'], 2, 3], 'gra-m-mar'), ('regression: right hyphen minimum', ['understand', ['b2l', '1ca', '1m', '1tio', '2mp', 'ment1', 't1t', '1p', '.ta4', 'li1', 'e1c', '1q', '4ing.', 'ex1', '5nd.', 'om1', 'o2n', 'hen5at', 'l1l', 'ter1', 'hena4', '.un1', 'r1r', 'pu2', 'p2h'], ['mis-sis-sip-pi'], 3, 2], 'understa-nd'), ('partial-repair probe', ['hyphenation', ['ter1', 'b2l', 'o2n', '5nd.', 'e1c', '.ta4', 'n1g', 'om1', 'hena4', 'pu2', 'l1l', 'a2n', 'r1r', 'hy3ph', 't1t', '.re1', '1p', 'e2x', '1q', 'ca1t', '3ty.', '2mp', '1m', 'ment1', '4ing.', 'x1c', '1ble', 'p2h', 'li1', 'c2ce', 'n2at', '2io', 'an1d', 'con1', 'io3n.', 'm1m', 'gr2', 'ex1', '1na'], ['gram-mar'], 2, 2], 'hy-phe-nation'), ('partial-repair probe', ['Paragraph', ['1na', '1ca', '2io', '3ty.', 'p2h', '1p', '.un1', 'a1b', 'an1d', 'li1', 'io3n.', '1m', 'a2n', 'n1g'], [], 1, 3], 'Paragraph'), ('lowercase exception', ['project', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['pro-ject'], 2, 3], 'pro-ject'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['Paragraph', ['1m', '2mp', '.ta4', 'hy3ph', 'pu2', 'e2x', 'om1', '1tio', 'at1', '.un1', 'n2at', '1na', 'hena4', 'r1r', 'ca1t', '1q', '2io', '.re1', 'a2n', 'n1g', 'o2n', 'ter1', 'l1l', 'x1c', 'p2h', 'con1', '5nd.', 'he2n', '4ing.', 'b2l', 'm1m', '1ble', '1p', 'c2ce', 's1s'], ['gram-mar', 'pro-ject'], 3, 1], 'Paragra-ph'), ('control layout', ['Recreation', ['li1', 'an1d', 'at1', '1ble', 'io3n.', 'a2n', 'e2x', '1tio', '.un1', '3ty.', 'r1r', '2io', 'e1c', 'he2n', '1m', 'om1', 'hen5at', '.ta4', 'n1g', 'a1b', 'ment1', 'p2h', '4ing.', '.re1', '1na', 'b2l', 'c2ce', 't1t'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 3], 'Re-crea-tion')], [('regression: right hyphen minimum', ['understand', ['hy3ph', 'ex1', 'p2h', 'e2x', 'm1m', 'hena4', 'an1d', '4ing.', 't1t', 'hen5at', 'a1b', 's1s', 'l1l', '.un1', 'n2at'], ['mis-sis-sip-pi', 'ex-cep-tion', 'pro-ject'], 2, 1], 'un-derstan-d'), ('regression: right hyphen minimum', ['Mississippi', ['5nd.', 'n2at', 'hena4', 'r1r', 'om1', 'e2x', 'hy3ph', 'an1d', '1p', 't1t', 'o2n', '.ta4', 'n1g', 'x1c', 'ter1', 's1s', 'li1', 'gr2', '2mp', '3ty.', 'p2h', 'c2ce', 'ex1', 'l1l', 'm1m', 'at1', 'a2n', '1ble', '4ing.', 'io3n.', '1tio', 'pu2', 'ca1t', '1m', 'a1b', 'con1', '.un1'], [], 1, 2], 'Mis-sis-si-p-pi'), ('partial-repair probe', ['Paragraph', ['s1s', 'io3n.', 'ca1t', 'x1c', 'hen5at', '.un1', '2mp', '4ing.', 'l1l', '1m', '1tio', 'gr2', 'b2l', '3ty.', 't1t', 'a1b', 'e1c', 'c2ce', 'pu2', 'ter1', 'o2n', '1q', 'r1r', '1p', 'm1m', 'n2at'], ['pro-ject'], 3, 3], 'Paragraph'), ('partial-repair probe', ['typesetting', ['he2n', '5nd.', 'x1c', '2mp', 'e1c', 'ment1', 'p2h', 'ca1t', 'a2n', 'hena4', '1tio', '.re1', 'gr2', 'hen5at', 'hy3ph', 'ex1', 'an1d', 'pu2', 'm1m', 't1t', '1ble', '1ca', 'b2l', 'n1g', '2io', 'r1r', '.un1', 'o2n', '4ing.', '.ta4', '1p', '3ty.', 'io3n.', 'e2x', 's1s', '1m', 'l1l', '1na', 'ter1'], [], 3, 2], 'typeset-ting'), ('left minimum boundary', ['excellent', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 3], 'ex-cel-lent'), ('right minimum boundary', ['category', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 1, 3], 'ca-t-egory'), ('control layout', ['Unexpected', ['1m', '1tio', 'ment1', 'm1m', 'c2ce', 'r1r', '1ca', '4ing.'], [], 1, 3], 'Unexpected'), ('control layout', ['battle', ['m1m', '3ty.', 'at1', '.un1', '2io', 'c2ce', '.ta4', 'gr2', 'an1d', '5nd.', 'a2n', 'he2n', 'p2h', 'li1', 'io3n.', '2mp', '4ing.', 't1t', '.re1', 'x1c', '1q', 'hena4', 'con1', 'n1g', 'a1b', 'n2at', 'e2x', 'om1', 'l1l', 'ter1', 'o2n', '1m', '1ble', 'ment1', '1p', 's1s', 'b2l', '1tio', '1ca', 'e1c', 'hy3ph', 'r1r', 'ex1', 'ca1t'], ['mis-sis-sip-pi', 'pro-ject'], 3, 2], 'bat-tle')], [('regression: right hyphen minimum', ['hyphenation', ['a2n', 'at1', 'e1c', '1tio', 'p2h', 'n2at', 'gr2', 'pu2', '.re1', 'an1d', 'ca1t', 'e2x', 't1t', 'l1l', '1ca', 'n1g', '1p', 'li1', '3ty.', 'hy3ph', '5nd.', '.un1', 'c2ce', '.ta4', 'om1', '1na'], ['pro-ject', 'gram-mar'], 1, 3], 'hy-phe-na-t-ion'), ('regression: right hyphen minimum', ['hyphenation', ['5nd.', 'om1', 'm1m', '1ca', 'a2n', '.ta4', 'o2n', 'an1d', 'ca1t', 'x1c', 'ter1', 'p2h', '1tio', 'n2at', 'hena4', '1ble', 'ex1', 'n1g', 's1s', 'io3n.', '1q', '2io', 'e2x', 'r1r', '1p', 't1t', 'gr2', 'ment1', 'hy3ph', 'l1l', '4ing.', '1m', 'pu2', '2mp', 'a1b', 'con1', 'b2l', '.re1', 'li1', '3ty.'], ['gram-mar', 'mis-sis-sip-pi', 'ta-ble'], 2, 1], 'hy-phenatio-n'), ('partial-repair probe', ['understand', ['1na', 'ment1', 'x1c', 'l1l', 'b2l', '.un1', 'gr2', 'an1d', '1p', '2mp', '2io', '1q', 'hen5at', 'hy3ph', 'a1b', 'n2at', 'om1', '5nd.', '3ty.', 'ex1', 'he2n', 'n1g', 'at1', 'ter1'], [], 1, 3], 'un-derstand'), ('partial-repair probe', ['running', ['p2h', '1m', '5nd.', 'c2ce', '1q', 'hen5at', '1ca', 'ment1', 's1s', 'io3n.', 'ex1', 'x1c', 'he2n', 'hy3ph', 'e2x', '2mp', '1tio', 'a2n', 'l1l', '1na', 'm1m', '3ty.', 'at1', 'ter1', 't1t', 'gr2', 'om1', '.ta4', 'ca1t', 'n2at', 'e1c', 'b2l', 'r1r', 'o2n', '1ble', '2io', '4ing.', 'con1', 'pu2', 'n1g', '.un1', 'hena4', 'a1b', '.re1', 'an1d'], ['gram-mar', 'mis-sis-sip-pi', 'pro-ject'], 2, 2], 'running'), ('word-final pattern ing.', ['running', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], [], 2, 2], 'running'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['Paragraph', ['1ble', 'e2x', 'hena4', '1p', '3ty.', 'hy3ph', 's1s', 'n1g', '.ta4', 'io3n.', '2io', '.un1', 'at1'], [], 3, 1], 'Paragra-ph'), ('control layout', ['Table', ['ment1', 'o2n', '1ca', 'n2at', '5nd.', 'x1c', '2io', 'hena4', 'con1', 'l1l', 'ter1', 'r1r', 't1t', 'hen5at', '.un1', 'io3n.', '1m', '1tio', 'm1m', 'e1c', 'ca1t', 'p2h', '.re1', 'a2n', 'pu2', 'an1d'], [], 1, 3], 'Table')]]
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: right hyphen minimumrunnin-grunnin-gPassed
regression: right hyphen minimumMis-sis-si-ppiMis-sis-si-ppiPassed
partial-repair probeun-derstandun-derstandPassed
partial-repair probeunderstandunderstandPassed
capitalised exceptionTa-bleTa-blePassed
right minimum boundaryca-t-egoryca-t-egoryPassed
control layoutcon-ne-c-tioncon-ne-c-tionPassed
control layoutEx-cep-tionEx-cep-tionPassed

SHA-256 / e5d5305ac95d3d198ce261a9c3ac875c3c0b1d8fb3ea984a127b1de498f8730b

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

Case digest / e3053ab1cf0ab156625b399ee6a1e5ffb93506419f6a66aca945398ffc6ec319