FAILURE MAP
← Case archive

FA-79941 / Typography line breaking / Open access

Pattern-based hyphenation: exception letter case · case 01

Exception-driven hyphenation lowercases capitalised words.

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

ROOT CAUSE

The exception entry itself is returned instead of re-spelling the original word.

VERIFIED REPAIR

Rebuild the output from the word's own letters with the exception's hyphens.

Unsuccessful approach: Capitalising the exception wrongly capitalises lowercase words.

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 e
    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 = [[('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'), ('regression: exception letter case', ['Exception', ['he2n', '2io', 'n1g', '1p', 'ca1t', '2mp', 'l1l', 'li1', 'o2n', 'b2l', 's1s', '1na', '.re1', 'at1', 'pu2', 't1t', 'n2at', '1tio', '1ble', 'hen5at', 'con1', 'a2n', '1q', '5nd.', 'hena4', 'ex1', 'x1c', 'ter1', 'e2x', 'io3n.', '.un1', '3ty.', 'om1', '.ta4', 'a1b', 'ment1', 'c2ce', 'm1m', 'hy3ph', '4ing.', '1ca', 'r1r', 'an1d', '1m', 'e1c', 'gr2', 'p2h'], ['mis-sis-sip-pi', 'ex-cep-tion', 'gram-mar'], 2, 2], 'Ex-cep-tion'), ('partial-repair probe', ['table', ['5nd.', '2mp', 'an1d', 'om1', 'hen5at', 'io3n.', '2io', 'p2h', 'm1m', 'ter1', '1ca', 'hena4', 't1t', 'r1r', '1q', 'c2ce', 'gr2', 'at1', '3ty.', 'l1l', '4ing.', 'ca1t'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'ta-ble'), ('partial-repair probe', ['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'), ('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'), ('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'), ('control layout', ['Pentagon', ['.un1', '.ta4', 'b2l', 'x1c', '3ty.', 'hena4', 'con1', '.re1', '2io', 'e1c', '2mp', '1tio', 'he2n', 'a1b', '1na'], ['mis-sis-sip-pi', 'pro-ject'], 2, 1], 'Pentagon'), ('control layout', ['terminal', ['1p', 'gr2', '.ta4', '.re1', 'ter1', 'n2at', 'pu2', 'l1l', 'e2x', 'm1m', 'io3n.', 'a2n', '2mp', 'hena4', 'ca1t', 't1t', 'li1', '5nd.', 'o2n', 'x1c', '1m', 'e1c', 'r1r', 'hen5at', '.un1', '2io', 'at1', 'ment1', 'ex1', '1ble', '1na', 'om1', 's1s', 'c2ce', '1tio', 'he2n', 'con1', 'an1d', 'hy3ph', '1ca', '4ing.', 'p2h'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 1, 1], 'ter-mi-nal')], [('regression: exception letter case', ['Exception', ['2mp', 'om1', 'a2n', 'n2at', '1na', '1tio', 'c2ce', 'at1', 'x1c', 'hy3ph', 'e2x', '2io', 'gr2', 'r1r', 'li1', '.re1', 'hena4', '1ca', 's1s', 'p2h', 'ex1', '1p', 'ment1', 'con1', 'a1b', 'he2n', 'l1l', 'hen5at', '.un1', 'ter1', '1ble', 'io3n.', 'm1m', '5nd.', '1m', '4ing.', '1q'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 3], 'Ex-cep-tion'), ('regression: exception letter case', ['Table', ['1p', 'a1b', 'r1r', 'con1', '2io', 'ter1', '.ta4', '3ty.', 'm1m', 't1t', '.un1', 'ca1t', '1m', '1tio', 'hen5at', 'n1g', 'hy3ph', 'ex1', 'e1c', 'ment1', '1ca', 'he2n'], ['mis-sis-sip-pi', 'ta-ble', 'ex-cep-tion'], 1, 2], 'Ta-ble'), ('partial-repair probe', ['grammar', ['io3n.', 'n1g', '3ty.', 'm1m', 'gr2', 'a1b', 'e2x', 'pu2', 'n2at', 'r1r', '1ca', 'ca1t', '1tio', 't1t', 'o2n', '1m', '.un1', 'con1', 'om1', '5nd.', 'p2h', 'ment1', 'hena4', 'hy3ph', '.ta4', 'e1c', '.re1', 'li1', 'a2n', 'b2l', '1ble'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 3], 'gram-mar'), ('partial-repair probe', ['grammar', ['s1s', 'r1r', '5nd.', 'c2ce', 'a1b', 'hena4', 'o2n', 'b2l', 'l1l', 'x1c', 't1t', 'p2h', '1p', 'm1m', 'con1', 'io3n.', '3ty.', '1tio', 'ment1', 'e2x', 'ex1', '1m', '4ing.', 'at1', 'om1', 'an1d', 'ca1t', '1q', '1ble', 'gr2', '2io', 'hen5at', '1na', 'e1c', '2mp', '.un1'], ['ta-ble', 'mis-sis-sip-pi', 'gram-mar'], 3, 1], 'gram-mar'), ('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'), ('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'), ('control layout', ['Categories', ['at1', 'hena4', 'a1b', 'con1', 'li1', 'pu2', '2io', 'm1m', 'n2at', 'a2n', '.re1'], ['gram-mar'], 3, 2], 'Cat-egories'), ('control layout', ['understand', ['.ta4', '2mp', 'e2x', '2io', 'gr2', 'io3n.', 'a2n', '4ing.', 'he2n', 'p2h', 'b2l', '1m', 'o2n', 'con1', 'n1g', 'e1c', 'ca1t', '1p', 'ment1', 'n2at', 'om1', 'x1c', 'hen5at', 'ter1', 'm1m', 's1s', 'c2ce', '5nd.', '.un1', 'at1', '1na'], ['gram-mar'], 2, 3], 'un-derstand')], [('regression: exception letter case', ['Mississippi', ['l1l', 'n1g', 'pu2', 's1s', '2io', 'hen5at', '1q', '.un1', 'p2h', '5nd.', 'b2l', '2mp', 'ex1', 't1t', 'con1', 'at1', 'gr2', 'm1m', 'e2x', 'a2n', 'ter1', 'r1r', 'e1c', '.ta4', 'c2ce', 'io3n.', 'x1c', 'o2n', 'ment1', 'hy3ph', 'n2at'], ['mis-sis-sip-pi'], 1, 2], 'Mis-sis-sip-pi'), ('regression: exception letter case', ['Mississippi', ['om1', 'an1d', 'li1', '1ca', '.re1', 'r1r', '1tio', 'con1', 'n2at', 'b2l', 'pu2', 'c2ce', 'at1', 'gr2', '3ty.', '1ble', '1na', 'io3n.', 'n1g', '4ing.', 's1s', 'e1c', 'hy3ph', '5nd.', '2io', '1q', 'm1m', 'ment1', 'l1l', 't1t', 'hen5at', 'x1c', '1p', 'e2x', '1m', 'o2n', '.un1', 'ter1'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 3, 2], 'Mis-sis-sip-pi'), ('partial-repair probe', ['grammar', ['t1t', 'con1', 'ter1', '2mp', 'ex1', '1q', 'e1c', '.ta4', 'li1', 'e2x', 'm1m', '1ble', 'b2l', 'pu2', 'n2at', 'r1r', 'l1l', 'c2ce', 'gr2', 'ment1', 'a2n', '1m', '1ca', '3ty.', 'hena4', 'at1', 'he2n', 'a1b', 'om1', '4ing.', '5nd.', 's1s', '1na', 'hen5at', '2io', 'io3n.', 'x1c', 'n1g', 'an1d', 'p2h', '1tio', '.un1', 'hy3ph', '.re1', 'ca1t', 'o2n'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 3, 2], 'gram-mar'), ('partial-repair probe', ['table', ['x1c', '1tio', 'io3n.', 'gr2', '2io', 'o2n', 'ment1', '.re1', 'l1l', 'con1', 'n2at', 'hen5at', 'hena4', 'ter1', '.ta4', 'r1r', '1p', '.un1', 'ca1t', 'e1c', 'c2ce', '5nd.', 'b2l', '1na', 'e2x', 'm1m', 'a1b', '2mp', '3ty.', 'p2h', '1m', 't1t', 'an1d', 'n1g', 'pu2', 'ex1'], ['ta-ble', 'ex-cep-tion'], 3, 1], 'ta-ble'), ('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'), ('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', ['hyphenation', ['hy3ph', 'pu2', '1p', '3ty.', 'p2h', '2io', 'm1m', 'ex1', 'n2at', 'con1', 'a2n', '1na', 'e2x', '.ta4', 'at1', 'hen5at', 'c2ce', 'li1', 'n1g', 'an1d', 'a1b', '1m', '1tio', 'x1c', '5nd.', '4ing.', '.re1', 'hena4', 's1s', '1q'], ['ta-ble'], 3, 3], 'hyphe-n-ation'), ('control layout', ['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: exception letter case', ['Table', ['li1', '2io', 'hy3ph', '4ing.', 'at1', 'm1m', 'om1', 'ex1', 'p2h', 'e2x', 'a2n', '1q', '1na', 'n2at', 'r1r', 'hena4', '1p', 'an1d', 'gr2', '3ty.', 'ca1t', 'n1g', 'x1c', 'c2ce', '.re1', 'io3n.', '1m', 'hen5at', 'e1c', 'ter1', 'l1l', 'b2l', 'pu2'], ['ta-ble'], 2, 3], 'Ta-ble'), ('regression: exception letter case', ['Exception', ['r1r', '1tio', 'hena4', '1m', 'l1l', 'c2ce', 'ca1t', 'e1c', 'li1', 'p2h', 'hen5at', 'he2n', 'e2x', '.un1', '1ca', '1ble', 'ment1', '5nd.', '4ing.', 't1t', 'ex1', 'io3n.', 'con1', '1na', '1p', 'a1b', '3ty.', 's1s', '.re1', 'gr2', 'o2n', 'm1m', 'x1c', 'pu2', 'a2n', 'b2l', '2mp', 'n1g', 'at1', 'hy3ph', 'om1', '.ta4', 'an1d'], ['mis-sis-sip-pi', 'ex-cep-tion'], 1, 2], 'Ex-cep-tion'), ('partial-repair probe', ['table', ['1p', '2io', 'he2n', 'at1', 'ca1t', '3ty.', 'n1g', 'hen5at', '5nd.'], ['ta-ble', 'ex-cep-tion'], 1, 1], 'ta-ble'), ('partial-repair probe', ['table', ['5nd.', '2mp', 'an1d', 'om1', 'hen5at', 'io3n.', '2io', 'p2h', 'm1m', 'ter1', '1ca', 'hena4', 't1t', 'r1r', '1q', 'c2ce', 'gr2', 'at1', '3ty.', 'l1l', '4ing.', 'ca1t'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'ta-ble'), ('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', ['Categories', ['hena4', '3ty.', 'con1', 'e2x', 'n2at', 'he2n', '1ca', '.un1', 'gr2', 'at1', '1na', 'm1m', 'b2l', '1ble', 'pu2', 'c2ce', 'om1', 'o2n', 'p2h', 's1s', 'l1l', '.re1', '1m', '2io', 'hen5at', 'ca1t', 'e1c', '1q', '.ta4', 'li1', 'io3n.', 'ter1', 'hy3ph', 'ex1', 'a1b', '2mp'], ['gram-mar'], 2, 3], 'Ca-t-egories'), ('control layout', ['Paragraph', ['hen5at', 'at1', 'gr2', 'ex1', 'ter1', '1m', 'l1l', 'ment1', 'io3n.', 'a1b', '3ty.'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 1, 3], 'Paragraph')], [('regression: exception letter case', ['Mississippi', ['ter1', 'o2n', '.ta4', 'r1r', 'pu2', 'hy3ph', 'c2ce', '1p', 'ex1', 'gr2', '5nd.', 'm1m', 'b2l', 'a1b', 'con1', '1ca', '.re1', 'io3n.', 'a2n', 'om1', 'e2x', 'hena4', 'l1l', 'ca1t', '3ty.'], ['mis-sis-sip-pi', 'pro-ject', 'ta-ble'], 3, 3], 'Mis-sis-sip-pi'), ('regression: exception letter case', ['Exception', ['.ta4', '2mp', 'ca1t', 'pu2', 'gr2', 'm1m', 'li1', 't1t', 'p2h', 'b2l', 'hen5at', 'hena4', 'o2n', 'n1g', 'con1', '5nd.', '.re1', '3ty.', 'ment1', 'x1c', '1na', 's1s', 'an1d', 'l1l', 'io3n.', 'c2ce', 'a1b', 'he2n', 'ter1', '1tio', 'n2at', 'a2n', '1ca', 'ex1', '2io', '1ble', 'e2x', '4ing.', 'e1c', '.un1', 'hy3ph', '1p', '1q', 'r1r', 'at1', '1m', 'om1'], ['ex-cep-tion', 'ta-ble', 'gram-mar'], 2, 3], 'Ex-cep-tion'), ('partial-repair probe', ['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'), ('partial-repair probe', ['grammar', ['io3n.', 'n1g', '3ty.', 'm1m', 'gr2', 'a1b', 'e2x', 'pu2', 'n2at', 'r1r', '1ca', 'ca1t', '1tio', 't1t', 'o2n', '1m', '.un1', 'con1', 'om1', '5nd.', 'p2h', 'ment1', 'hena4', 'hy3ph', '.ta4', 'e1c', '.re1', 'li1', 'a2n', 'b2l', '1ble'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 3], 'gram-mar'), ('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', ['Commitment', ['3ty.', '4ing.', '1ca', '5nd.', 's1s', 'a1b', '.un1', 'n2at', 'pu2', 'a2n', 'x1c', 'io3n.', 'ex1', 'n1g', '2io', 'b2l', 'at1', '1na', 'li1', 'c2ce', '1m', 'r1r', 'm1m', 'gr2', 'e2x', 'p2h', 'con1', 'ment1', 'he2n', 'ter1', 'hena4', '1p', 'an1d', 'e1c', '1tio', 't1t', '1q', '1ble', '.re1', 'hy3ph', 'om1', '2mp', 'ca1t', 'o2n', 'l1l', 'hen5at', '.ta4'], ['gram-mar', 'mis-sis-sip-pi', 'ta-ble'], 3, 3], 'Com-mit-ment'), ('control layout', ['table', ['.un1', 'm1m', 'hena4', 'o2n', '1m', 'hen5at', 'li1', 'a2n', 'c2ce', 'b2l', '1ca', 'gr2', '.re1', 'pu2', '1q', '3ty.', 'e2x', '1p', 'an1d', 'l1l', 'at1', 'ex1', '1ble', 'io3n.', 'n2at', 'ca1t', 'ter1', 'om1', '1na', '1tio', 'x1c', '2mp', '4ing.', 'ment1', 'a1b', 'p2h', '5nd.', 'n1g', '.ta4', 'con1', 't1t', 'he2n', 'hy3ph', 'r1r', 's1s', 'e1c', '2io'], ['pro-ject'], 1, 1], '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
capitalised exceptionta-bleTa-bleFailed
regression: exception letter caseex-cep-tionEx-cep-tionFailed
partial-repair probeta-bleta-blePassed
partial-repair probepro-jectpro-jectPassed
left minimum boundaryex-cel-lentex-cel-lentPassed
word-final pattern ing.runningrunningPassed
control layoutPentagonPentagonPassed
control layoutter-mi-nalter-mi-nalPassed

SHA-256 / 2ac12ce989e6973fc85f9cbe959e5606c7eece7874afc9361a7170df726404d9

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 e.capitalize()
    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 = [[('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'), ('regression: exception letter case', ['Exception', ['he2n', '2io', 'n1g', '1p', 'ca1t', '2mp', 'l1l', 'li1', 'o2n', 'b2l', 's1s', '1na', '.re1', 'at1', 'pu2', 't1t', 'n2at', '1tio', '1ble', 'hen5at', 'con1', 'a2n', '1q', '5nd.', 'hena4', 'ex1', 'x1c', 'ter1', 'e2x', 'io3n.', '.un1', '3ty.', 'om1', '.ta4', 'a1b', 'ment1', 'c2ce', 'm1m', 'hy3ph', '4ing.', '1ca', 'r1r', 'an1d', '1m', 'e1c', 'gr2', 'p2h'], ['mis-sis-sip-pi', 'ex-cep-tion', 'gram-mar'], 2, 2], 'Ex-cep-tion'), ('partial-repair probe', ['table', ['5nd.', '2mp', 'an1d', 'om1', 'hen5at', 'io3n.', '2io', 'p2h', 'm1m', 'ter1', '1ca', 'hena4', 't1t', 'r1r', '1q', 'c2ce', 'gr2', 'at1', '3ty.', 'l1l', '4ing.', 'ca1t'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'ta-ble'), ('partial-repair probe', ['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'), ('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'), ('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'), ('control layout', ['Pentagon', ['.un1', '.ta4', 'b2l', 'x1c', '3ty.', 'hena4', 'con1', '.re1', '2io', 'e1c', '2mp', '1tio', 'he2n', 'a1b', '1na'], ['mis-sis-sip-pi', 'pro-ject'], 2, 1], 'Pentagon'), ('control layout', ['terminal', ['1p', 'gr2', '.ta4', '.re1', 'ter1', 'n2at', 'pu2', 'l1l', 'e2x', 'm1m', 'io3n.', 'a2n', '2mp', 'hena4', 'ca1t', 't1t', 'li1', '5nd.', 'o2n', 'x1c', '1m', 'e1c', 'r1r', 'hen5at', '.un1', '2io', 'at1', 'ment1', 'ex1', '1ble', '1na', 'om1', 's1s', 'c2ce', '1tio', 'he2n', 'con1', 'an1d', 'hy3ph', '1ca', '4ing.', 'p2h'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 1, 1], 'ter-mi-nal')], [('regression: exception letter case', ['Exception', ['2mp', 'om1', 'a2n', 'n2at', '1na', '1tio', 'c2ce', 'at1', 'x1c', 'hy3ph', 'e2x', '2io', 'gr2', 'r1r', 'li1', '.re1', 'hena4', '1ca', 's1s', 'p2h', 'ex1', '1p', 'ment1', 'con1', 'a1b', 'he2n', 'l1l', 'hen5at', '.un1', 'ter1', '1ble', 'io3n.', 'm1m', '5nd.', '1m', '4ing.', '1q'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 3], 'Ex-cep-tion'), ('regression: exception letter case', ['Table', ['1p', 'a1b', 'r1r', 'con1', '2io', 'ter1', '.ta4', '3ty.', 'm1m', 't1t', '.un1', 'ca1t', '1m', '1tio', 'hen5at', 'n1g', 'hy3ph', 'ex1', 'e1c', 'ment1', '1ca', 'he2n'], ['mis-sis-sip-pi', 'ta-ble', 'ex-cep-tion'], 1, 2], 'Ta-ble'), ('partial-repair probe', ['grammar', ['io3n.', 'n1g', '3ty.', 'm1m', 'gr2', 'a1b', 'e2x', 'pu2', 'n2at', 'r1r', '1ca', 'ca1t', '1tio', 't1t', 'o2n', '1m', '.un1', 'con1', 'om1', '5nd.', 'p2h', 'ment1', 'hena4', 'hy3ph', '.ta4', 'e1c', '.re1', 'li1', 'a2n', 'b2l', '1ble'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 3], 'gram-mar'), ('partial-repair probe', ['grammar', ['s1s', 'r1r', '5nd.', 'c2ce', 'a1b', 'hena4', 'o2n', 'b2l', 'l1l', 'x1c', 't1t', 'p2h', '1p', 'm1m', 'con1', 'io3n.', '3ty.', '1tio', 'ment1', 'e2x', 'ex1', '1m', '4ing.', 'at1', 'om1', 'an1d', 'ca1t', '1q', '1ble', 'gr2', '2io', 'hen5at', '1na', 'e1c', '2mp', '.un1'], ['ta-ble', 'mis-sis-sip-pi', 'gram-mar'], 3, 1], 'gram-mar'), ('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'), ('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'), ('control layout', ['Categories', ['at1', 'hena4', 'a1b', 'con1', 'li1', 'pu2', '2io', 'm1m', 'n2at', 'a2n', '.re1'], ['gram-mar'], 3, 2], 'Cat-egories'), ('control layout', ['understand', ['.ta4', '2mp', 'e2x', '2io', 'gr2', 'io3n.', 'a2n', '4ing.', 'he2n', 'p2h', 'b2l', '1m', 'o2n', 'con1', 'n1g', 'e1c', 'ca1t', '1p', 'ment1', 'n2at', 'om1', 'x1c', 'hen5at', 'ter1', 'm1m', 's1s', 'c2ce', '5nd.', '.un1', 'at1', '1na'], ['gram-mar'], 2, 3], 'un-derstand')], [('regression: exception letter case', ['Mississippi', ['l1l', 'n1g', 'pu2', 's1s', '2io', 'hen5at', '1q', '.un1', 'p2h', '5nd.', 'b2l', '2mp', 'ex1', 't1t', 'con1', 'at1', 'gr2', 'm1m', 'e2x', 'a2n', 'ter1', 'r1r', 'e1c', '.ta4', 'c2ce', 'io3n.', 'x1c', 'o2n', 'ment1', 'hy3ph', 'n2at'], ['mis-sis-sip-pi'], 1, 2], 'Mis-sis-sip-pi'), ('regression: exception letter case', ['Mississippi', ['om1', 'an1d', 'li1', '1ca', '.re1', 'r1r', '1tio', 'con1', 'n2at', 'b2l', 'pu2', 'c2ce', 'at1', 'gr2', '3ty.', '1ble', '1na', 'io3n.', 'n1g', '4ing.', 's1s', 'e1c', 'hy3ph', '5nd.', '2io', '1q', 'm1m', 'ment1', 'l1l', 't1t', 'hen5at', 'x1c', '1p', 'e2x', '1m', 'o2n', '.un1', 'ter1'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 3, 2], 'Mis-sis-sip-pi'), ('partial-repair probe', ['grammar', ['t1t', 'con1', 'ter1', '2mp', 'ex1', '1q', 'e1c', '.ta4', 'li1', 'e2x', 'm1m', '1ble', 'b2l', 'pu2', 'n2at', 'r1r', 'l1l', 'c2ce', 'gr2', 'ment1', 'a2n', '1m', '1ca', '3ty.', 'hena4', 'at1', 'he2n', 'a1b', 'om1', '4ing.', '5nd.', 's1s', '1na', 'hen5at', '2io', 'io3n.', 'x1c', 'n1g', 'an1d', 'p2h', '1tio', '.un1', 'hy3ph', '.re1', 'ca1t', 'o2n'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 3, 2], 'gram-mar'), ('partial-repair probe', ['table', ['x1c', '1tio', 'io3n.', 'gr2', '2io', 'o2n', 'ment1', '.re1', 'l1l', 'con1', 'n2at', 'hen5at', 'hena4', 'ter1', '.ta4', 'r1r', '1p', '.un1', 'ca1t', 'e1c', 'c2ce', '5nd.', 'b2l', '1na', 'e2x', 'm1m', 'a1b', '2mp', '3ty.', 'p2h', '1m', 't1t', 'an1d', 'n1g', 'pu2', 'ex1'], ['ta-ble', 'ex-cep-tion'], 3, 1], 'ta-ble'), ('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'), ('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', ['hyphenation', ['hy3ph', 'pu2', '1p', '3ty.', 'p2h', '2io', 'm1m', 'ex1', 'n2at', 'con1', 'a2n', '1na', 'e2x', '.ta4', 'at1', 'hen5at', 'c2ce', 'li1', 'n1g', 'an1d', 'a1b', '1m', '1tio', 'x1c', '5nd.', '4ing.', '.re1', 'hena4', 's1s', '1q'], ['ta-ble'], 3, 3], 'hyphe-n-ation'), ('control layout', ['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: exception letter case', ['Table', ['li1', '2io', 'hy3ph', '4ing.', 'at1', 'm1m', 'om1', 'ex1', 'p2h', 'e2x', 'a2n', '1q', '1na', 'n2at', 'r1r', 'hena4', '1p', 'an1d', 'gr2', '3ty.', 'ca1t', 'n1g', 'x1c', 'c2ce', '.re1', 'io3n.', '1m', 'hen5at', 'e1c', 'ter1', 'l1l', 'b2l', 'pu2'], ['ta-ble'], 2, 3], 'Ta-ble'), ('regression: exception letter case', ['Exception', ['r1r', '1tio', 'hena4', '1m', 'l1l', 'c2ce', 'ca1t', 'e1c', 'li1', 'p2h', 'hen5at', 'he2n', 'e2x', '.un1', '1ca', '1ble', 'ment1', '5nd.', '4ing.', 't1t', 'ex1', 'io3n.', 'con1', '1na', '1p', 'a1b', '3ty.', 's1s', '.re1', 'gr2', 'o2n', 'm1m', 'x1c', 'pu2', 'a2n', 'b2l', '2mp', 'n1g', 'at1', 'hy3ph', 'om1', '.ta4', 'an1d'], ['mis-sis-sip-pi', 'ex-cep-tion'], 1, 2], 'Ex-cep-tion'), ('partial-repair probe', ['table', ['1p', '2io', 'he2n', 'at1', 'ca1t', '3ty.', 'n1g', 'hen5at', '5nd.'], ['ta-ble', 'ex-cep-tion'], 1, 1], 'ta-ble'), ('partial-repair probe', ['table', ['5nd.', '2mp', 'an1d', 'om1', 'hen5at', 'io3n.', '2io', 'p2h', 'm1m', 'ter1', '1ca', 'hena4', 't1t', 'r1r', '1q', 'c2ce', 'gr2', 'at1', '3ty.', 'l1l', '4ing.', 'ca1t'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'ta-ble'), ('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', ['Categories', ['hena4', '3ty.', 'con1', 'e2x', 'n2at', 'he2n', '1ca', '.un1', 'gr2', 'at1', '1na', 'm1m', 'b2l', '1ble', 'pu2', 'c2ce', 'om1', 'o2n', 'p2h', 's1s', 'l1l', '.re1', '1m', '2io', 'hen5at', 'ca1t', 'e1c', '1q', '.ta4', 'li1', 'io3n.', 'ter1', 'hy3ph', 'ex1', 'a1b', '2mp'], ['gram-mar'], 2, 3], 'Ca-t-egories'), ('control layout', ['Paragraph', ['hen5at', 'at1', 'gr2', 'ex1', 'ter1', '1m', 'l1l', 'ment1', 'io3n.', 'a1b', '3ty.'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 1, 3], 'Paragraph')], [('regression: exception letter case', ['Mississippi', ['ter1', 'o2n', '.ta4', 'r1r', 'pu2', 'hy3ph', 'c2ce', '1p', 'ex1', 'gr2', '5nd.', 'm1m', 'b2l', 'a1b', 'con1', '1ca', '.re1', 'io3n.', 'a2n', 'om1', 'e2x', 'hena4', 'l1l', 'ca1t', '3ty.'], ['mis-sis-sip-pi', 'pro-ject', 'ta-ble'], 3, 3], 'Mis-sis-sip-pi'), ('regression: exception letter case', ['Exception', ['.ta4', '2mp', 'ca1t', 'pu2', 'gr2', 'm1m', 'li1', 't1t', 'p2h', 'b2l', 'hen5at', 'hena4', 'o2n', 'n1g', 'con1', '5nd.', '.re1', '3ty.', 'ment1', 'x1c', '1na', 's1s', 'an1d', 'l1l', 'io3n.', 'c2ce', 'a1b', 'he2n', 'ter1', '1tio', 'n2at', 'a2n', '1ca', 'ex1', '2io', '1ble', 'e2x', '4ing.', 'e1c', '.un1', 'hy3ph', '1p', '1q', 'r1r', 'at1', '1m', 'om1'], ['ex-cep-tion', 'ta-ble', 'gram-mar'], 2, 3], 'Ex-cep-tion'), ('partial-repair probe', ['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'), ('partial-repair probe', ['grammar', ['io3n.', 'n1g', '3ty.', 'm1m', 'gr2', 'a1b', 'e2x', 'pu2', 'n2at', 'r1r', '1ca', 'ca1t', '1tio', 't1t', 'o2n', '1m', '.un1', 'con1', 'om1', '5nd.', 'p2h', 'ment1', 'hena4', 'hy3ph', '.ta4', 'e1c', '.re1', 'li1', 'a2n', 'b2l', '1ble'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 3], 'gram-mar'), ('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', ['Commitment', ['3ty.', '4ing.', '1ca', '5nd.', 's1s', 'a1b', '.un1', 'n2at', 'pu2', 'a2n', 'x1c', 'io3n.', 'ex1', 'n1g', '2io', 'b2l', 'at1', '1na', 'li1', 'c2ce', '1m', 'r1r', 'm1m', 'gr2', 'e2x', 'p2h', 'con1', 'ment1', 'he2n', 'ter1', 'hena4', '1p', 'an1d', 'e1c', '1tio', 't1t', '1q', '1ble', '.re1', 'hy3ph', 'om1', '2mp', 'ca1t', 'o2n', 'l1l', 'hen5at', '.ta4'], ['gram-mar', 'mis-sis-sip-pi', 'ta-ble'], 3, 3], 'Com-mit-ment'), ('control layout', ['table', ['.un1', 'm1m', 'hena4', 'o2n', '1m', 'hen5at', 'li1', 'a2n', 'c2ce', 'b2l', '1ca', 'gr2', '.re1', 'pu2', '1q', '3ty.', 'e2x', '1p', 'an1d', 'l1l', 'at1', 'ex1', '1ble', 'io3n.', 'n2at', 'ca1t', 'ter1', 'om1', '1na', '1tio', 'x1c', '2mp', '4ing.', 'ment1', 'a1b', 'p2h', '5nd.', 'n1g', '.ta4', 'con1', 't1t', 'he2n', 'hy3ph', 'r1r', 's1s', 'e1c', '2io'], ['pro-ject'], 1, 1], '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
capitalised exceptionTa-bleTa-blePassed
regression: exception letter caseEx-cep-tionEx-cep-tionPassed
partial-repair probeTa-bleta-bleFailed
partial-repair probePro-jectpro-jectFailed
left minimum boundaryex-cel-lentex-cel-lentPassed
word-final pattern ing.runningrunningPassed
control layoutPentagonPentagonPassed
control layoutter-mi-nalter-mi-nalPassed

SHA-256 / 53ac26353ba36b6cf3193a0753ad89568fabc0a5959cc58379cb23253b33d130

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 = [[('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'), ('regression: exception letter case', ['Exception', ['he2n', '2io', 'n1g', '1p', 'ca1t', '2mp', 'l1l', 'li1', 'o2n', 'b2l', 's1s', '1na', '.re1', 'at1', 'pu2', 't1t', 'n2at', '1tio', '1ble', 'hen5at', 'con1', 'a2n', '1q', '5nd.', 'hena4', 'ex1', 'x1c', 'ter1', 'e2x', 'io3n.', '.un1', '3ty.', 'om1', '.ta4', 'a1b', 'ment1', 'c2ce', 'm1m', 'hy3ph', '4ing.', '1ca', 'r1r', 'an1d', '1m', 'e1c', 'gr2', 'p2h'], ['mis-sis-sip-pi', 'ex-cep-tion', 'gram-mar'], 2, 2], 'Ex-cep-tion'), ('partial-repair probe', ['table', ['5nd.', '2mp', 'an1d', 'om1', 'hen5at', 'io3n.', '2io', 'p2h', 'm1m', 'ter1', '1ca', 'hena4', 't1t', 'r1r', '1q', 'c2ce', 'gr2', 'at1', '3ty.', 'l1l', '4ing.', 'ca1t'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'ta-ble'), ('partial-repair probe', ['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'), ('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'), ('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'), ('control layout', ['Pentagon', ['.un1', '.ta4', 'b2l', 'x1c', '3ty.', 'hena4', 'con1', '.re1', '2io', 'e1c', '2mp', '1tio', 'he2n', 'a1b', '1na'], ['mis-sis-sip-pi', 'pro-ject'], 2, 1], 'Pentagon'), ('control layout', ['terminal', ['1p', 'gr2', '.ta4', '.re1', 'ter1', 'n2at', 'pu2', 'l1l', 'e2x', 'm1m', 'io3n.', 'a2n', '2mp', 'hena4', 'ca1t', 't1t', 'li1', '5nd.', 'o2n', 'x1c', '1m', 'e1c', 'r1r', 'hen5at', '.un1', '2io', 'at1', 'ment1', 'ex1', '1ble', '1na', 'om1', 's1s', 'c2ce', '1tio', 'he2n', 'con1', 'an1d', 'hy3ph', '1ca', '4ing.', 'p2h'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 1, 1], 'ter-mi-nal')], [('regression: exception letter case', ['Exception', ['2mp', 'om1', 'a2n', 'n2at', '1na', '1tio', 'c2ce', 'at1', 'x1c', 'hy3ph', 'e2x', '2io', 'gr2', 'r1r', 'li1', '.re1', 'hena4', '1ca', 's1s', 'p2h', 'ex1', '1p', 'ment1', 'con1', 'a1b', 'he2n', 'l1l', 'hen5at', '.un1', 'ter1', '1ble', 'io3n.', 'm1m', '5nd.', '1m', '4ing.', '1q'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 3], 'Ex-cep-tion'), ('regression: exception letter case', ['Table', ['1p', 'a1b', 'r1r', 'con1', '2io', 'ter1', '.ta4', '3ty.', 'm1m', 't1t', '.un1', 'ca1t', '1m', '1tio', 'hen5at', 'n1g', 'hy3ph', 'ex1', 'e1c', 'ment1', '1ca', 'he2n'], ['mis-sis-sip-pi', 'ta-ble', 'ex-cep-tion'], 1, 2], 'Ta-ble'), ('partial-repair probe', ['grammar', ['io3n.', 'n1g', '3ty.', 'm1m', 'gr2', 'a1b', 'e2x', 'pu2', 'n2at', 'r1r', '1ca', 'ca1t', '1tio', 't1t', 'o2n', '1m', '.un1', 'con1', 'om1', '5nd.', 'p2h', 'ment1', 'hena4', 'hy3ph', '.ta4', 'e1c', '.re1', 'li1', 'a2n', 'b2l', '1ble'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 3], 'gram-mar'), ('partial-repair probe', ['grammar', ['s1s', 'r1r', '5nd.', 'c2ce', 'a1b', 'hena4', 'o2n', 'b2l', 'l1l', 'x1c', 't1t', 'p2h', '1p', 'm1m', 'con1', 'io3n.', '3ty.', '1tio', 'ment1', 'e2x', 'ex1', '1m', '4ing.', 'at1', 'om1', 'an1d', 'ca1t', '1q', '1ble', 'gr2', '2io', 'hen5at', '1na', 'e1c', '2mp', '.un1'], ['ta-ble', 'mis-sis-sip-pi', 'gram-mar'], 3, 1], 'gram-mar'), ('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'), ('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'), ('control layout', ['Categories', ['at1', 'hena4', 'a1b', 'con1', 'li1', 'pu2', '2io', 'm1m', 'n2at', 'a2n', '.re1'], ['gram-mar'], 3, 2], 'Cat-egories'), ('control layout', ['understand', ['.ta4', '2mp', 'e2x', '2io', 'gr2', 'io3n.', 'a2n', '4ing.', 'he2n', 'p2h', 'b2l', '1m', 'o2n', 'con1', 'n1g', 'e1c', 'ca1t', '1p', 'ment1', 'n2at', 'om1', 'x1c', 'hen5at', 'ter1', 'm1m', 's1s', 'c2ce', '5nd.', '.un1', 'at1', '1na'], ['gram-mar'], 2, 3], 'un-derstand')], [('regression: exception letter case', ['Mississippi', ['l1l', 'n1g', 'pu2', 's1s', '2io', 'hen5at', '1q', '.un1', 'p2h', '5nd.', 'b2l', '2mp', 'ex1', 't1t', 'con1', 'at1', 'gr2', 'm1m', 'e2x', 'a2n', 'ter1', 'r1r', 'e1c', '.ta4', 'c2ce', 'io3n.', 'x1c', 'o2n', 'ment1', 'hy3ph', 'n2at'], ['mis-sis-sip-pi'], 1, 2], 'Mis-sis-sip-pi'), ('regression: exception letter case', ['Mississippi', ['om1', 'an1d', 'li1', '1ca', '.re1', 'r1r', '1tio', 'con1', 'n2at', 'b2l', 'pu2', 'c2ce', 'at1', 'gr2', '3ty.', '1ble', '1na', 'io3n.', 'n1g', '4ing.', 's1s', 'e1c', 'hy3ph', '5nd.', '2io', '1q', 'm1m', 'ment1', 'l1l', 't1t', 'hen5at', 'x1c', '1p', 'e2x', '1m', 'o2n', '.un1', 'ter1'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 3, 2], 'Mis-sis-sip-pi'), ('partial-repair probe', ['grammar', ['t1t', 'con1', 'ter1', '2mp', 'ex1', '1q', 'e1c', '.ta4', 'li1', 'e2x', 'm1m', '1ble', 'b2l', 'pu2', 'n2at', 'r1r', 'l1l', 'c2ce', 'gr2', 'ment1', 'a2n', '1m', '1ca', '3ty.', 'hena4', 'at1', 'he2n', 'a1b', 'om1', '4ing.', '5nd.', 's1s', '1na', 'hen5at', '2io', 'io3n.', 'x1c', 'n1g', 'an1d', 'p2h', '1tio', '.un1', 'hy3ph', '.re1', 'ca1t', 'o2n'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 3, 2], 'gram-mar'), ('partial-repair probe', ['table', ['x1c', '1tio', 'io3n.', 'gr2', '2io', 'o2n', 'ment1', '.re1', 'l1l', 'con1', 'n2at', 'hen5at', 'hena4', 'ter1', '.ta4', 'r1r', '1p', '.un1', 'ca1t', 'e1c', 'c2ce', '5nd.', 'b2l', '1na', 'e2x', 'm1m', 'a1b', '2mp', '3ty.', 'p2h', '1m', 't1t', 'an1d', 'n1g', 'pu2', 'ex1'], ['ta-ble', 'ex-cep-tion'], 3, 1], 'ta-ble'), ('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'), ('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', ['hyphenation', ['hy3ph', 'pu2', '1p', '3ty.', 'p2h', '2io', 'm1m', 'ex1', 'n2at', 'con1', 'a2n', '1na', 'e2x', '.ta4', 'at1', 'hen5at', 'c2ce', 'li1', 'n1g', 'an1d', 'a1b', '1m', '1tio', 'x1c', '5nd.', '4ing.', '.re1', 'hena4', 's1s', '1q'], ['ta-ble'], 3, 3], 'hyphe-n-ation'), ('control layout', ['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: exception letter case', ['Table', ['li1', '2io', 'hy3ph', '4ing.', 'at1', 'm1m', 'om1', 'ex1', 'p2h', 'e2x', 'a2n', '1q', '1na', 'n2at', 'r1r', 'hena4', '1p', 'an1d', 'gr2', '3ty.', 'ca1t', 'n1g', 'x1c', 'c2ce', '.re1', 'io3n.', '1m', 'hen5at', 'e1c', 'ter1', 'l1l', 'b2l', 'pu2'], ['ta-ble'], 2, 3], 'Ta-ble'), ('regression: exception letter case', ['Exception', ['r1r', '1tio', 'hena4', '1m', 'l1l', 'c2ce', 'ca1t', 'e1c', 'li1', 'p2h', 'hen5at', 'he2n', 'e2x', '.un1', '1ca', '1ble', 'ment1', '5nd.', '4ing.', 't1t', 'ex1', 'io3n.', 'con1', '1na', '1p', 'a1b', '3ty.', 's1s', '.re1', 'gr2', 'o2n', 'm1m', 'x1c', 'pu2', 'a2n', 'b2l', '2mp', 'n1g', 'at1', 'hy3ph', 'om1', '.ta4', 'an1d'], ['mis-sis-sip-pi', 'ex-cep-tion'], 1, 2], 'Ex-cep-tion'), ('partial-repair probe', ['table', ['1p', '2io', 'he2n', 'at1', 'ca1t', '3ty.', 'n1g', 'hen5at', '5nd.'], ['ta-ble', 'ex-cep-tion'], 1, 1], 'ta-ble'), ('partial-repair probe', ['table', ['5nd.', '2mp', 'an1d', 'om1', 'hen5at', 'io3n.', '2io', 'p2h', 'm1m', 'ter1', '1ca', 'hena4', 't1t', 'r1r', '1q', 'c2ce', 'gr2', 'at1', '3ty.', 'l1l', '4ing.', 'ca1t'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'ta-ble'), ('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', ['Categories', ['hena4', '3ty.', 'con1', 'e2x', 'n2at', 'he2n', '1ca', '.un1', 'gr2', 'at1', '1na', 'm1m', 'b2l', '1ble', 'pu2', 'c2ce', 'om1', 'o2n', 'p2h', 's1s', 'l1l', '.re1', '1m', '2io', 'hen5at', 'ca1t', 'e1c', '1q', '.ta4', 'li1', 'io3n.', 'ter1', 'hy3ph', 'ex1', 'a1b', '2mp'], ['gram-mar'], 2, 3], 'Ca-t-egories'), ('control layout', ['Paragraph', ['hen5at', 'at1', 'gr2', 'ex1', 'ter1', '1m', 'l1l', 'ment1', 'io3n.', 'a1b', '3ty.'], ['ta-ble', 'pro-ject', 'mis-sis-sip-pi'], 1, 3], 'Paragraph')], [('regression: exception letter case', ['Mississippi', ['ter1', 'o2n', '.ta4', 'r1r', 'pu2', 'hy3ph', 'c2ce', '1p', 'ex1', 'gr2', '5nd.', 'm1m', 'b2l', 'a1b', 'con1', '1ca', '.re1', 'io3n.', 'a2n', 'om1', 'e2x', 'hena4', 'l1l', 'ca1t', '3ty.'], ['mis-sis-sip-pi', 'pro-ject', 'ta-ble'], 3, 3], 'Mis-sis-sip-pi'), ('regression: exception letter case', ['Exception', ['.ta4', '2mp', 'ca1t', 'pu2', 'gr2', 'm1m', 'li1', 't1t', 'p2h', 'b2l', 'hen5at', 'hena4', 'o2n', 'n1g', 'con1', '5nd.', '.re1', '3ty.', 'ment1', 'x1c', '1na', 's1s', 'an1d', 'l1l', 'io3n.', 'c2ce', 'a1b', 'he2n', 'ter1', '1tio', 'n2at', 'a2n', '1ca', 'ex1', '2io', '1ble', 'e2x', '4ing.', 'e1c', '.un1', 'hy3ph', '1p', '1q', 'r1r', 'at1', '1m', 'om1'], ['ex-cep-tion', 'ta-ble', 'gram-mar'], 2, 3], 'Ex-cep-tion'), ('partial-repair probe', ['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'), ('partial-repair probe', ['grammar', ['io3n.', 'n1g', '3ty.', 'm1m', 'gr2', 'a1b', 'e2x', 'pu2', 'n2at', 'r1r', '1ca', 'ca1t', '1tio', 't1t', 'o2n', '1m', '.un1', 'con1', 'om1', '5nd.', 'p2h', 'ment1', 'hena4', 'hy3ph', '.ta4', 'e1c', '.re1', 'li1', 'a2n', 'b2l', '1ble'], ['pro-ject', 'gram-mar', 'ta-ble'], 1, 3], 'gram-mar'), ('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', ['Commitment', ['3ty.', '4ing.', '1ca', '5nd.', 's1s', 'a1b', '.un1', 'n2at', 'pu2', 'a2n', 'x1c', 'io3n.', 'ex1', 'n1g', '2io', 'b2l', 'at1', '1na', 'li1', 'c2ce', '1m', 'r1r', 'm1m', 'gr2', 'e2x', 'p2h', 'con1', 'ment1', 'he2n', 'ter1', 'hena4', '1p', 'an1d', 'e1c', '1tio', 't1t', '1q', '1ble', '.re1', 'hy3ph', 'om1', '2mp', 'ca1t', 'o2n', 'l1l', 'hen5at', '.ta4'], ['gram-mar', 'mis-sis-sip-pi', 'ta-ble'], 3, 3], 'Com-mit-ment'), ('control layout', ['table', ['.un1', 'm1m', 'hena4', 'o2n', '1m', 'hen5at', 'li1', 'a2n', 'c2ce', 'b2l', '1ca', 'gr2', '.re1', 'pu2', '1q', '3ty.', 'e2x', '1p', 'an1d', 'l1l', 'at1', 'ex1', '1ble', 'io3n.', 'n2at', 'ca1t', 'ter1', 'om1', '1na', '1tio', 'x1c', '2mp', '4ing.', 'ment1', 'a1b', 'p2h', '5nd.', 'n1g', '.ta4', 'con1', 't1t', 'he2n', 'hy3ph', 'r1r', 's1s', 'e1c', '2io'], ['pro-ject'], 1, 1], '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
capitalised exceptionTa-bleTa-blePassed
regression: exception letter caseEx-cep-tionEx-cep-tionPassed
partial-repair probeta-bleta-blePassed
partial-repair probepro-jectpro-jectPassed
left minimum boundaryex-cel-lentex-cel-lentPassed
word-final pattern ing.runningrunningPassed
control layoutPentagonPentagonPassed
control layoutter-mi-nalter-mi-nalPassed

SHA-256 / ebd219a82cab09ed5cbb784363b965fcaa063b1ce9d7fd2a58c87e46de6c415d

Verification & scope

A deterministic toy typesetting model with integer widths and a stipulated rule set; it does not claim conformance to any engine. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:49:49.177708+00:00.

Case digest / 7e77a2bf42bfd778bd2596c2f039649b9f850fe901e1ee3fe7503410c0ef1f28