FAILURE MAP
← Case archive

FA-79921 / Typography line breaking / Open access

Pattern-based hyphenation: odd-value break rule · case 01

Hyphens appear at gaps explicitly inhibited by even digits.

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

ROOT CAUSE

Any nonzero gap value is accepted as a hyphenation point.

VERIFIED REPAIR

Allow a hyphen only when the winning value is odd.

Unsuccessful approach: Accepting even nonzero values inverts the rule.

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] > 0 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 = [[('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'), ('regression: odd-value break rule', ['hyphenation', ['m1m', 'x1c', 'con1', '1m', 'p2h', 'li1', '1p', '.un1', 'hena4', 'io3n.', 'e1c', 'a2n', 'ment1', 'pu2', 'ter1', 'e2x', 'hen5at', 't1t', 'gr2', 'r1r', '2mp', 's1s', 'hy3ph', '2io', 'c2ce', 'om1', 'n2at', 'o2n'], ['mis-sis-sip-pi'], 2, 2], 'hy-phen-ation'), ('regression: odd-value break rule', ['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'), ('regression: odd-value break rule', ['Unexpected', ['con1', 'r1r', 'e1c', '5nd.', 'o2n', 'p2h', 'm1m', 'gr2', '3ty.', '.ta4', 'l1l', 'an1d', 'om1', 'he2n', 'x1c', 'li1', '2io', '1q', 'ex1', 'n2at', 'hena4', '4ing.', 'io3n.', 'a1b', 'hen5at', 'c2ce', 'pu2', 'e2x', '1ca', '1p', '.re1', 'ment1', 'hy3ph', 'ter1', '.un1', '2mp', 'a2n', 'b2l', '1na', '1ble', 'ca1t', 'n1g', 'at1'], [], 2, 2], 'Un-ex-pe-cted'), ('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'), ('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'), ('control layout', ['running', ['.ta4', 'a2n', 'hena4', 's1s', '2io', 'hen5at', 'e1c', '1p', 'e2x', 'n2at', '.un1', 'hy3ph', 'con1', 'a1b', '1m', '.re1', 'b2l'], [], 2, 2], 'running'), ('control layout', ['understand', ['m1m', '4ing.', '1m', '1q', '1na', 't1t', 'ex1', '.re1'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'understand')], [('regression: odd-value break rule', ['grammar', ['m1m', 'hy3ph', '1ble', 'r1r', 'a2n', 'li1', '1q', 't1t', '1p', 'at1', 'l1l', '2io', 'e2x', 'a1b', 'n1g', 'con1', '1ca', '.re1', '1m', 'e1c', '4ing.', '1tio', 'p2h', 'o2n', '.ta4', 'he2n', 's1s', 'io3n.', '5nd.', 'b2l', 'pu2', 'an1d', 'c2ce', '1na', 'ex1', '3ty.', 'n2at', 'hen5at', '2mp', 'ter1', 'ca1t', 'om1', 'ment1', 'x1c', 'gr2'], [], 1, 3], 'gra-m-mar'), ('regression: odd-value break rule', ['Recreation', ['at1', 't1t', 'om1', 'a2n', 'ex1', 'p2h', 'pu2', '3ty.', 'm1m', 'x1c', '1q', '1na', 'r1r', 'ter1', 'o2n', '.re1', 'hena4', '1m', '4ing.', 'io3n.', 'n1g', '1ble', 'l1l', 'b2l', 's1s', '2io', 'ment1', '1p', 'n2at', 'con1', '1tio', 'gr2', 'hy3ph', 'he2n', 'hen5at', '2mp', 'ca1t', 'e2x', 'e1c', '.ta4', '1ca', 'li1', '.un1', 'an1d'], [], 1, 2], 'Re-crea-tion'), ('regression: odd-value break rule', ['Pentagon', ['p2h', '2io', 'hen5at', 'r1r', 'o2n', 'x1c', 'e1c', '5nd.'], ['mis-sis-sip-pi', 'ta-ble', 'gram-mar'], 1, 1], 'Pentagon'), ('regression: odd-value break rule', ['Unexpected', ['hena4', 'ment1', 'hen5at', '5nd.', '1na', 'a1b', '1p', '3ty.', 'n2at', 'x1c', 'hy3ph', '2io', '4ing.', 't1t', '.un1', 's1s', 'p2h', 'ter1', 'gr2', '1m', 'o2n', 'e2x', '1ca', 'at1', 'e1c', '1ble', 'io3n.'], [], 2, 2], 'Un-ex-pe-cted'), ('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'), ('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', ['running', ['pu2', 'a1b', '1m', '5nd.', 'e2x', '1q', '.re1', 'ex1', 'con1', 'hena4', '1na', '2mp', 'om1', 'ter1', 'an1d', 'ca1t', 'at1', '.un1', 'o2n', 's1s', 'l1l'], ['ex-cep-tion', 'gram-mar'], 3, 1], 'running'), ('control layout', ['terminal', ['hy3ph', 'con1', '1q', 'n1g', 'b2l', 'ca1t', 'hena4', 'a2n', 'p2h', 'pu2', 'he2n', 'li1', 'om1', 'm1m', 'at1', 'o2n', '.un1'], [], 1, 3], 'terminal')], [('regression: odd-value break rule', ['Paragraph', ['ter1', 'l1l', 'he2n', '3ty.', 'hen5at', '2mp', 't1t', 'ex1', 'gr2', 'io3n.', 'con1', 'o2n', 'a2n', '1ca', 'm1m', 'hy3ph', 'r1r', '1p', 'n1g', 'pu2', '1na', '1m', 's1s', '.re1', '4ing.', '.un1'], ['ta-ble'], 1, 2], 'Paragra-ph'), ('regression: odd-value break rule', ['hyphenation', ['2io', '1ca', '1na', 'n1g', 'ter1', 'b2l', 'at1', 'he2n', 'io3n.', 'm1m', 'l1l', 'an1d', 'ment1', 'gr2', '1p', 's1s', '3ty.', '5nd.', 'hy3ph', 'con1', 'n2at', 'o2n', 'hena4', '.un1', '2mp', '.ta4', 'a1b', 'e1c', '4ing.', '1ble', 'a2n', 'ex1', '1m', 'hen5at', 'om1', 't1t', 'c2ce', 'p2h', '.re1', 'pu2'], ['ta-ble'], 1, 2], 'hy-phen-ation'), ('partial-repair probe', ['Mississippi', ['n2at', 's1s', 'hena4', 'x1c', 'p2h', '1ble', '.re1', 'r1r', '.ta4', 'ex1', '1ca', 'at1', 'io3n.', 'o2n', 'e2x', '3ty.', '1tio', 'b2l', '2mp', 'he2n', 'li1', 'an1d', 'a1b', 'pu2', 'a2n', 'hen5at', 'n1g', '5nd.', 't1t', 'm1m'], ['gram-mar', 'pro-ject'], 2, 2], 'Mis-sis-sippi'), ('partial-repair probe', ['excellent', ['p2h', 'n2at', 'b2l', 'gr2', 'e2x', 'an1d', 'x1c', '.ta4', 'ex1', 'om1', 'a2n', '1ca', 'hena4', 'e1c', 'he2n', 'c2ce', 'l1l', 'ca1t', '.un1', '1na', '5nd.', 'at1', 'hen5at', 'm1m', '2mp', '1q', 'a1b', 'con1', 'hy3ph', '3ty.', 'li1', '1m', '.re1', 'r1r', 'pu2', 'ment1', 'n1g', 't1t', 's1s', 'o2n', '1tio', '1p'], [], 2, 2], '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'), ('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', ['grammar', ['.ta4', '.un1', '.re1', 'n2at', 'at1', 'hena4', 'p2h', '3ty.', 'io3n.', 'hy3ph', 'r1r', 'hen5at', 'a1b', 'he2n', '1ble', '1tio', 'pu2', 'b2l', 'e1c', 'e2x', 'm1m', 'c2ce', 'gr2', '5nd.', 'ment1', 'li1', 's1s', 'n1g', 'x1c', 'a2n', 'om1', 'con1', 'ca1t', '1ca', '1q', '1na', 'ex1', '1p', '2io', 'ter1', 't1t', '2mp'], ['gram-mar', 'ex-cep-tion'], 1, 1], 'gram-mar'), ('control layout', ['running', ['li1', '1q', 'a1b', 'hy3ph', '.re1', '.un1', 'gr2', '2mp', 'b2l'], ['mis-sis-sip-pi', 'ex-cep-tion'], 1, 2], 'running')], [('regression: odd-value break rule', ['Exception', ['he2n', 'e1c', 'b2l', 'ment1', '.ta4', 'con1', '.un1', 'e2x', 'n2at', '2mp', '1na', 'pu2', 'li1', 'o2n', 'a1b', 'om1', 's1s', 'io3n.', '3ty.', 'at1', 'gr2', 'p2h', 'ca1t', 'hy3ph', '2io', 'hen5at', 'x1c', 'm1m', '.re1', '1tio', 'ex1', '1q', 'l1l', 't1t'], ['pro-ject', 'gram-mar', 'ta-ble'], 3, 3], 'Excep-tion'), ('regression: odd-value break rule', ['typesetting', ['ex1', 'b2l', '1ble', 'hena4', 'pu2', 'e2x', '.un1', 'a1b', 'r1r', '5nd.', 'con1', 'io3n.', 'c2ce', '1q', 'n2at', 'ter1', 'l1l', '1na', 'o2n', 'hen5at', 'x1c', 's1s', '2io', 'an1d', 'a2n', 'hy3ph', '3ty.', 'n1g', 'at1', '1p', 'gr2', '4ing.', 't1t', '2mp', 'li1', 'ca1t', '1m', 'he2n', 'p2h', '1ca', 'ment1', '1tio', 'm1m', '.re1', 'om1', 'e1c', '.ta4'], [], 2, 3], 'ty-peset-ting'), ('regression: odd-value break rule', ['computer', ['r1r', 'pu2', 'hena4', 'ment1', 'li1', '.re1', 'an1d', 'a1b', 'a2n', 'e1c', 'o2n', 'io3n.', 'con1'], ['mis-sis-sip-pi', 'ex-cep-tion', 'pro-ject'], 2, 1], 'computer'), ('partial-repair probe', ['Commitment', ['.ta4', 'gr2', 'om1', 't1t', 'e1c', 'a2n', '1q', '1ble', '1tio', 'hen5at', '2mp'], [], 3, 1], 'Com-mitment'), ('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'), ('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', ['b2l', 'hen5at', 'he2n', 'con1', 'ex1', '.un1', 'x1c', '5nd.', 'a2n', 'gr2', 'om1', 'r1r', '1q', '1ble', 's1s', 'l1l', '.ta4'], [], 2, 1], 'Categories'), ('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')], [('regression: odd-value break rule', ['running', ['s1s', 'p2h', '4ing.', 'e1c', '2io', '1ca', 'e2x', 'ex1', '1na', 'at1', 'li1', 'gr2', '.re1', 'x1c', 'ment1', 'ter1', 'n1g', 'ca1t', 'n2at', '1q', 'r1r', '1tio', 'hy3ph', 'm1m', 'io3n.', 'l1l', 'pu2', '.un1', 'o2n', 'a1b', '5nd.', 'c2ce', 'hen5at', '1m', 'hena4'], ['ex-cep-tion', 'pro-ject', 'gram-mar'], 2, 2], 'running'), ('regression: odd-value break rule', ['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'), ('regression: odd-value break rule', ['Paragraph', ['an1d', '5nd.', '.re1', '1ca', '1na', '1p', 'e1c', 'he2n', 'gr2', '.un1', 'ex1', '4ing.', 't1t', 'p2h', 'hen5at', 'li1'], ['mis-sis-sip-pi', 'pro-ject', 'gram-mar'], 1, 1], 'Paragra-ph'), ('regression: odd-value break rule', ['typesetting', ['s1s', '2io', '5nd.', '.re1', 'r1r', '.ta4', '1na', '1ca', 'li1', 'ex1', '4ing.', 'n2at', 'an1d', 'x1c', 'om1', 'hy3ph', 'p2h', '1m', 'a1b', '2mp', 'gr2'], ['pro-ject', 'mis-sis-sip-pi', 'ta-ble'], 1, 3], 'typesetting'), ('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'), ('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'), ('control layout', ['connection', ['e2x', 't1t', 'li1', 'c2ce', 'he2n', 'r1r', '1ble', '5nd.', 'b2l', 'p2h', 'n2at'], ['pro-ject', 'gram-mar'], 2, 2], 'connection'), ('control layout', ['project', ['2mp', 'li1', 'n1g', 'om1', 'e2x', '1tio', '.re1', 'p2h', '1p', 'gr2', 'c2ce', 'hena4', 'ter1', 'he2n', '1m', '1q', '1na', '1ble', 'n2at', 'x1c'], [], 2, 1], 'project')]]
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
word-final pattern ing.runn-ingrunningFailed
regression: odd-value break rulehy-p-hen-a-t-ionhy-phen-ationFailed
regression: odd-value break ruleta-b-letableFailed
regression: odd-value break ruleUn-e-x-pe-ctedUn-ex-pe-ctedFailed
right minimum boundaryca-t-egoryca-t-egoryPassed
lowercase exceptionpro-jectpro-jectPassed
control layoutrunningrunningPassed
control layoutunderstandunderstandPassed

SHA-256 / f6a7068bd21ac24aadedf004ac2d2b3cf1989ff391ff1fce4f10922ea4dcfc24

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 == 0 and score[i + 1] > 0 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 = [[('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'), ('regression: odd-value break rule', ['hyphenation', ['m1m', 'x1c', 'con1', '1m', 'p2h', 'li1', '1p', '.un1', 'hena4', 'io3n.', 'e1c', 'a2n', 'ment1', 'pu2', 'ter1', 'e2x', 'hen5at', 't1t', 'gr2', 'r1r', '2mp', 's1s', 'hy3ph', '2io', 'c2ce', 'om1', 'n2at', 'o2n'], ['mis-sis-sip-pi'], 2, 2], 'hy-phen-ation'), ('regression: odd-value break rule', ['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'), ('regression: odd-value break rule', ['Unexpected', ['con1', 'r1r', 'e1c', '5nd.', 'o2n', 'p2h', 'm1m', 'gr2', '3ty.', '.ta4', 'l1l', 'an1d', 'om1', 'he2n', 'x1c', 'li1', '2io', '1q', 'ex1', 'n2at', 'hena4', '4ing.', 'io3n.', 'a1b', 'hen5at', 'c2ce', 'pu2', 'e2x', '1ca', '1p', '.re1', 'ment1', 'hy3ph', 'ter1', '.un1', '2mp', 'a2n', 'b2l', '1na', '1ble', 'ca1t', 'n1g', 'at1'], [], 2, 2], 'Un-ex-pe-cted'), ('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'), ('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'), ('control layout', ['running', ['.ta4', 'a2n', 'hena4', 's1s', '2io', 'hen5at', 'e1c', '1p', 'e2x', 'n2at', '.un1', 'hy3ph', 'con1', 'a1b', '1m', '.re1', 'b2l'], [], 2, 2], 'running'), ('control layout', ['understand', ['m1m', '4ing.', '1m', '1q', '1na', 't1t', 'ex1', '.re1'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'understand')], [('regression: odd-value break rule', ['grammar', ['m1m', 'hy3ph', '1ble', 'r1r', 'a2n', 'li1', '1q', 't1t', '1p', 'at1', 'l1l', '2io', 'e2x', 'a1b', 'n1g', 'con1', '1ca', '.re1', '1m', 'e1c', '4ing.', '1tio', 'p2h', 'o2n', '.ta4', 'he2n', 's1s', 'io3n.', '5nd.', 'b2l', 'pu2', 'an1d', 'c2ce', '1na', 'ex1', '3ty.', 'n2at', 'hen5at', '2mp', 'ter1', 'ca1t', 'om1', 'ment1', 'x1c', 'gr2'], [], 1, 3], 'gra-m-mar'), ('regression: odd-value break rule', ['Recreation', ['at1', 't1t', 'om1', 'a2n', 'ex1', 'p2h', 'pu2', '3ty.', 'm1m', 'x1c', '1q', '1na', 'r1r', 'ter1', 'o2n', '.re1', 'hena4', '1m', '4ing.', 'io3n.', 'n1g', '1ble', 'l1l', 'b2l', 's1s', '2io', 'ment1', '1p', 'n2at', 'con1', '1tio', 'gr2', 'hy3ph', 'he2n', 'hen5at', '2mp', 'ca1t', 'e2x', 'e1c', '.ta4', '1ca', 'li1', '.un1', 'an1d'], [], 1, 2], 'Re-crea-tion'), ('regression: odd-value break rule', ['Pentagon', ['p2h', '2io', 'hen5at', 'r1r', 'o2n', 'x1c', 'e1c', '5nd.'], ['mis-sis-sip-pi', 'ta-ble', 'gram-mar'], 1, 1], 'Pentagon'), ('regression: odd-value break rule', ['Unexpected', ['hena4', 'ment1', 'hen5at', '5nd.', '1na', 'a1b', '1p', '3ty.', 'n2at', 'x1c', 'hy3ph', '2io', '4ing.', 't1t', '.un1', 's1s', 'p2h', 'ter1', 'gr2', '1m', 'o2n', 'e2x', '1ca', 'at1', 'e1c', '1ble', 'io3n.'], [], 2, 2], 'Un-ex-pe-cted'), ('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'), ('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', ['running', ['pu2', 'a1b', '1m', '5nd.', 'e2x', '1q', '.re1', 'ex1', 'con1', 'hena4', '1na', '2mp', 'om1', 'ter1', 'an1d', 'ca1t', 'at1', '.un1', 'o2n', 's1s', 'l1l'], ['ex-cep-tion', 'gram-mar'], 3, 1], 'running'), ('control layout', ['terminal', ['hy3ph', 'con1', '1q', 'n1g', 'b2l', 'ca1t', 'hena4', 'a2n', 'p2h', 'pu2', 'he2n', 'li1', 'om1', 'm1m', 'at1', 'o2n', '.un1'], [], 1, 3], 'terminal')], [('regression: odd-value break rule', ['Paragraph', ['ter1', 'l1l', 'he2n', '3ty.', 'hen5at', '2mp', 't1t', 'ex1', 'gr2', 'io3n.', 'con1', 'o2n', 'a2n', '1ca', 'm1m', 'hy3ph', 'r1r', '1p', 'n1g', 'pu2', '1na', '1m', 's1s', '.re1', '4ing.', '.un1'], ['ta-ble'], 1, 2], 'Paragra-ph'), ('regression: odd-value break rule', ['hyphenation', ['2io', '1ca', '1na', 'n1g', 'ter1', 'b2l', 'at1', 'he2n', 'io3n.', 'm1m', 'l1l', 'an1d', 'ment1', 'gr2', '1p', 's1s', '3ty.', '5nd.', 'hy3ph', 'con1', 'n2at', 'o2n', 'hena4', '.un1', '2mp', '.ta4', 'a1b', 'e1c', '4ing.', '1ble', 'a2n', 'ex1', '1m', 'hen5at', 'om1', 't1t', 'c2ce', 'p2h', '.re1', 'pu2'], ['ta-ble'], 1, 2], 'hy-phen-ation'), ('partial-repair probe', ['Mississippi', ['n2at', 's1s', 'hena4', 'x1c', 'p2h', '1ble', '.re1', 'r1r', '.ta4', 'ex1', '1ca', 'at1', 'io3n.', 'o2n', 'e2x', '3ty.', '1tio', 'b2l', '2mp', 'he2n', 'li1', 'an1d', 'a1b', 'pu2', 'a2n', 'hen5at', 'n1g', '5nd.', 't1t', 'm1m'], ['gram-mar', 'pro-ject'], 2, 2], 'Mis-sis-sippi'), ('partial-repair probe', ['excellent', ['p2h', 'n2at', 'b2l', 'gr2', 'e2x', 'an1d', 'x1c', '.ta4', 'ex1', 'om1', 'a2n', '1ca', 'hena4', 'e1c', 'he2n', 'c2ce', 'l1l', 'ca1t', '.un1', '1na', '5nd.', 'at1', 'hen5at', 'm1m', '2mp', '1q', 'a1b', 'con1', 'hy3ph', '3ty.', 'li1', '1m', '.re1', 'r1r', 'pu2', 'ment1', 'n1g', 't1t', 's1s', 'o2n', '1tio', '1p'], [], 2, 2], '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'), ('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', ['grammar', ['.ta4', '.un1', '.re1', 'n2at', 'at1', 'hena4', 'p2h', '3ty.', 'io3n.', 'hy3ph', 'r1r', 'hen5at', 'a1b', 'he2n', '1ble', '1tio', 'pu2', 'b2l', 'e1c', 'e2x', 'm1m', 'c2ce', 'gr2', '5nd.', 'ment1', 'li1', 's1s', 'n1g', 'x1c', 'a2n', 'om1', 'con1', 'ca1t', '1ca', '1q', '1na', 'ex1', '1p', '2io', 'ter1', 't1t', '2mp'], ['gram-mar', 'ex-cep-tion'], 1, 1], 'gram-mar'), ('control layout', ['running', ['li1', '1q', 'a1b', 'hy3ph', '.re1', '.un1', 'gr2', '2mp', 'b2l'], ['mis-sis-sip-pi', 'ex-cep-tion'], 1, 2], 'running')], [('regression: odd-value break rule', ['Exception', ['he2n', 'e1c', 'b2l', 'ment1', '.ta4', 'con1', '.un1', 'e2x', 'n2at', '2mp', '1na', 'pu2', 'li1', 'o2n', 'a1b', 'om1', 's1s', 'io3n.', '3ty.', 'at1', 'gr2', 'p2h', 'ca1t', 'hy3ph', '2io', 'hen5at', 'x1c', 'm1m', '.re1', '1tio', 'ex1', '1q', 'l1l', 't1t'], ['pro-ject', 'gram-mar', 'ta-ble'], 3, 3], 'Excep-tion'), ('regression: odd-value break rule', ['typesetting', ['ex1', 'b2l', '1ble', 'hena4', 'pu2', 'e2x', '.un1', 'a1b', 'r1r', '5nd.', 'con1', 'io3n.', 'c2ce', '1q', 'n2at', 'ter1', 'l1l', '1na', 'o2n', 'hen5at', 'x1c', 's1s', '2io', 'an1d', 'a2n', 'hy3ph', '3ty.', 'n1g', 'at1', '1p', 'gr2', '4ing.', 't1t', '2mp', 'li1', 'ca1t', '1m', 'he2n', 'p2h', '1ca', 'ment1', '1tio', 'm1m', '.re1', 'om1', 'e1c', '.ta4'], [], 2, 3], 'ty-peset-ting'), ('regression: odd-value break rule', ['computer', ['r1r', 'pu2', 'hena4', 'ment1', 'li1', '.re1', 'an1d', 'a1b', 'a2n', 'e1c', 'o2n', 'io3n.', 'con1'], ['mis-sis-sip-pi', 'ex-cep-tion', 'pro-ject'], 2, 1], 'computer'), ('partial-repair probe', ['Commitment', ['.ta4', 'gr2', 'om1', 't1t', 'e1c', 'a2n', '1q', '1ble', '1tio', 'hen5at', '2mp'], [], 3, 1], 'Com-mitment'), ('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'), ('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', ['b2l', 'hen5at', 'he2n', 'con1', 'ex1', '.un1', 'x1c', '5nd.', 'a2n', 'gr2', 'om1', 'r1r', '1q', '1ble', 's1s', 'l1l', '.ta4'], [], 2, 1], 'Categories'), ('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')], [('regression: odd-value break rule', ['running', ['s1s', 'p2h', '4ing.', 'e1c', '2io', '1ca', 'e2x', 'ex1', '1na', 'at1', 'li1', 'gr2', '.re1', 'x1c', 'ment1', 'ter1', 'n1g', 'ca1t', 'n2at', '1q', 'r1r', '1tio', 'hy3ph', 'm1m', 'io3n.', 'l1l', 'pu2', '.un1', 'o2n', 'a1b', '5nd.', 'c2ce', 'hen5at', '1m', 'hena4'], ['ex-cep-tion', 'pro-ject', 'gram-mar'], 2, 2], 'running'), ('regression: odd-value break rule', ['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'), ('regression: odd-value break rule', ['Paragraph', ['an1d', '5nd.', '.re1', '1ca', '1na', '1p', 'e1c', 'he2n', 'gr2', '.un1', 'ex1', '4ing.', 't1t', 'p2h', 'hen5at', 'li1'], ['mis-sis-sip-pi', 'pro-ject', 'gram-mar'], 1, 1], 'Paragra-ph'), ('regression: odd-value break rule', ['typesetting', ['s1s', '2io', '5nd.', '.re1', 'r1r', '.ta4', '1na', '1ca', 'li1', 'ex1', '4ing.', 'n2at', 'an1d', 'x1c', 'om1', 'hy3ph', 'p2h', '1m', 'a1b', '2mp', 'gr2'], ['pro-ject', 'mis-sis-sip-pi', 'ta-ble'], 1, 3], 'typesetting'), ('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'), ('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'), ('control layout', ['connection', ['e2x', 't1t', 'li1', 'c2ce', 'he2n', 'r1r', '1ble', '5nd.', 'b2l', 'p2h', 'n2at'], ['pro-ject', 'gram-mar'], 2, 2], 'connection'), ('control layout', ['project', ['2mp', 'li1', 'n1g', 'om1', 'e2x', '1tio', '.re1', 'p2h', '1p', 'gr2', 'c2ce', 'hena4', 'ter1', 'he2n', '1m', '1q', '1na', '1ble', 'n2at', 'x1c'], [], 2, 1], 'project')]]
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
word-final pattern ing.runn-ingrunningFailed
regression: odd-value break rulehyp-hena-t-ionhy-phen-ationFailed
regression: odd-value break ruleta-b-letableFailed
regression: odd-value break ruleUne-xpectedUn-ex-pe-ctedFailed
right minimum boundarycategoryca-t-egoryFailed
lowercase exceptionpro-jectpro-jectPassed
control layoutrunningrunningPassed
control layoutunderstandunderstandPassed

SHA-256 / 73bd36b7688ab8a212a0e3edde0be14eec37b773eea3c73bf21508975610d38a

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 = [[('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'), ('regression: odd-value break rule', ['hyphenation', ['m1m', 'x1c', 'con1', '1m', 'p2h', 'li1', '1p', '.un1', 'hena4', 'io3n.', 'e1c', 'a2n', 'ment1', 'pu2', 'ter1', 'e2x', 'hen5at', 't1t', 'gr2', 'r1r', '2mp', 's1s', 'hy3ph', '2io', 'c2ce', 'om1', 'n2at', 'o2n'], ['mis-sis-sip-pi'], 2, 2], 'hy-phen-ation'), ('regression: odd-value break rule', ['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'), ('regression: odd-value break rule', ['Unexpected', ['con1', 'r1r', 'e1c', '5nd.', 'o2n', 'p2h', 'm1m', 'gr2', '3ty.', '.ta4', 'l1l', 'an1d', 'om1', 'he2n', 'x1c', 'li1', '2io', '1q', 'ex1', 'n2at', 'hena4', '4ing.', 'io3n.', 'a1b', 'hen5at', 'c2ce', 'pu2', 'e2x', '1ca', '1p', '.re1', 'ment1', 'hy3ph', 'ter1', '.un1', '2mp', 'a2n', 'b2l', '1na', '1ble', 'ca1t', 'n1g', 'at1'], [], 2, 2], 'Un-ex-pe-cted'), ('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'), ('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'), ('control layout', ['running', ['.ta4', 'a2n', 'hena4', 's1s', '2io', 'hen5at', 'e1c', '1p', 'e2x', 'n2at', '.un1', 'hy3ph', 'con1', 'a1b', '1m', '.re1', 'b2l'], [], 2, 2], 'running'), ('control layout', ['understand', ['m1m', '4ing.', '1m', '1q', '1na', 't1t', 'ex1', '.re1'], ['ta-ble', 'mis-sis-sip-pi', 'ex-cep-tion'], 2, 2], 'understand')], [('regression: odd-value break rule', ['grammar', ['m1m', 'hy3ph', '1ble', 'r1r', 'a2n', 'li1', '1q', 't1t', '1p', 'at1', 'l1l', '2io', 'e2x', 'a1b', 'n1g', 'con1', '1ca', '.re1', '1m', 'e1c', '4ing.', '1tio', 'p2h', 'o2n', '.ta4', 'he2n', 's1s', 'io3n.', '5nd.', 'b2l', 'pu2', 'an1d', 'c2ce', '1na', 'ex1', '3ty.', 'n2at', 'hen5at', '2mp', 'ter1', 'ca1t', 'om1', 'ment1', 'x1c', 'gr2'], [], 1, 3], 'gra-m-mar'), ('regression: odd-value break rule', ['Recreation', ['at1', 't1t', 'om1', 'a2n', 'ex1', 'p2h', 'pu2', '3ty.', 'm1m', 'x1c', '1q', '1na', 'r1r', 'ter1', 'o2n', '.re1', 'hena4', '1m', '4ing.', 'io3n.', 'n1g', '1ble', 'l1l', 'b2l', 's1s', '2io', 'ment1', '1p', 'n2at', 'con1', '1tio', 'gr2', 'hy3ph', 'he2n', 'hen5at', '2mp', 'ca1t', 'e2x', 'e1c', '.ta4', '1ca', 'li1', '.un1', 'an1d'], [], 1, 2], 'Re-crea-tion'), ('regression: odd-value break rule', ['Pentagon', ['p2h', '2io', 'hen5at', 'r1r', 'o2n', 'x1c', 'e1c', '5nd.'], ['mis-sis-sip-pi', 'ta-ble', 'gram-mar'], 1, 1], 'Pentagon'), ('regression: odd-value break rule', ['Unexpected', ['hena4', 'ment1', 'hen5at', '5nd.', '1na', 'a1b', '1p', '3ty.', 'n2at', 'x1c', 'hy3ph', '2io', '4ing.', 't1t', '.un1', 's1s', 'p2h', 'ter1', 'gr2', '1m', 'o2n', 'e2x', '1ca', 'at1', 'e1c', '1ble', 'io3n.'], [], 2, 2], 'Un-ex-pe-cted'), ('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'), ('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', ['running', ['pu2', 'a1b', '1m', '5nd.', 'e2x', '1q', '.re1', 'ex1', 'con1', 'hena4', '1na', '2mp', 'om1', 'ter1', 'an1d', 'ca1t', 'at1', '.un1', 'o2n', 's1s', 'l1l'], ['ex-cep-tion', 'gram-mar'], 3, 1], 'running'), ('control layout', ['terminal', ['hy3ph', 'con1', '1q', 'n1g', 'b2l', 'ca1t', 'hena4', 'a2n', 'p2h', 'pu2', 'he2n', 'li1', 'om1', 'm1m', 'at1', 'o2n', '.un1'], [], 1, 3], 'terminal')], [('regression: odd-value break rule', ['Paragraph', ['ter1', 'l1l', 'he2n', '3ty.', 'hen5at', '2mp', 't1t', 'ex1', 'gr2', 'io3n.', 'con1', 'o2n', 'a2n', '1ca', 'm1m', 'hy3ph', 'r1r', '1p', 'n1g', 'pu2', '1na', '1m', 's1s', '.re1', '4ing.', '.un1'], ['ta-ble'], 1, 2], 'Paragra-ph'), ('regression: odd-value break rule', ['hyphenation', ['2io', '1ca', '1na', 'n1g', 'ter1', 'b2l', 'at1', 'he2n', 'io3n.', 'm1m', 'l1l', 'an1d', 'ment1', 'gr2', '1p', 's1s', '3ty.', '5nd.', 'hy3ph', 'con1', 'n2at', 'o2n', 'hena4', '.un1', '2mp', '.ta4', 'a1b', 'e1c', '4ing.', '1ble', 'a2n', 'ex1', '1m', 'hen5at', 'om1', 't1t', 'c2ce', 'p2h', '.re1', 'pu2'], ['ta-ble'], 1, 2], 'hy-phen-ation'), ('partial-repair probe', ['Mississippi', ['n2at', 's1s', 'hena4', 'x1c', 'p2h', '1ble', '.re1', 'r1r', '.ta4', 'ex1', '1ca', 'at1', 'io3n.', 'o2n', 'e2x', '3ty.', '1tio', 'b2l', '2mp', 'he2n', 'li1', 'an1d', 'a1b', 'pu2', 'a2n', 'hen5at', 'n1g', '5nd.', 't1t', 'm1m'], ['gram-mar', 'pro-ject'], 2, 2], 'Mis-sis-sippi'), ('partial-repair probe', ['excellent', ['p2h', 'n2at', 'b2l', 'gr2', 'e2x', 'an1d', 'x1c', '.ta4', 'ex1', 'om1', 'a2n', '1ca', 'hena4', 'e1c', 'he2n', 'c2ce', 'l1l', 'ca1t', '.un1', '1na', '5nd.', 'at1', 'hen5at', 'm1m', '2mp', '1q', 'a1b', 'con1', 'hy3ph', '3ty.', 'li1', '1m', '.re1', 'r1r', 'pu2', 'ment1', 'n1g', 't1t', 's1s', 'o2n', '1tio', '1p'], [], 2, 2], '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'), ('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', ['grammar', ['.ta4', '.un1', '.re1', 'n2at', 'at1', 'hena4', 'p2h', '3ty.', 'io3n.', 'hy3ph', 'r1r', 'hen5at', 'a1b', 'he2n', '1ble', '1tio', 'pu2', 'b2l', 'e1c', 'e2x', 'm1m', 'c2ce', 'gr2', '5nd.', 'ment1', 'li1', 's1s', 'n1g', 'x1c', 'a2n', 'om1', 'con1', 'ca1t', '1ca', '1q', '1na', 'ex1', '1p', '2io', 'ter1', 't1t', '2mp'], ['gram-mar', 'ex-cep-tion'], 1, 1], 'gram-mar'), ('control layout', ['running', ['li1', '1q', 'a1b', 'hy3ph', '.re1', '.un1', 'gr2', '2mp', 'b2l'], ['mis-sis-sip-pi', 'ex-cep-tion'], 1, 2], 'running')], [('regression: odd-value break rule', ['Exception', ['he2n', 'e1c', 'b2l', 'ment1', '.ta4', 'con1', '.un1', 'e2x', 'n2at', '2mp', '1na', 'pu2', 'li1', 'o2n', 'a1b', 'om1', 's1s', 'io3n.', '3ty.', 'at1', 'gr2', 'p2h', 'ca1t', 'hy3ph', '2io', 'hen5at', 'x1c', 'm1m', '.re1', '1tio', 'ex1', '1q', 'l1l', 't1t'], ['pro-ject', 'gram-mar', 'ta-ble'], 3, 3], 'Excep-tion'), ('regression: odd-value break rule', ['typesetting', ['ex1', 'b2l', '1ble', 'hena4', 'pu2', 'e2x', '.un1', 'a1b', 'r1r', '5nd.', 'con1', 'io3n.', 'c2ce', '1q', 'n2at', 'ter1', 'l1l', '1na', 'o2n', 'hen5at', 'x1c', 's1s', '2io', 'an1d', 'a2n', 'hy3ph', '3ty.', 'n1g', 'at1', '1p', 'gr2', '4ing.', 't1t', '2mp', 'li1', 'ca1t', '1m', 'he2n', 'p2h', '1ca', 'ment1', '1tio', 'm1m', '.re1', 'om1', 'e1c', '.ta4'], [], 2, 3], 'ty-peset-ting'), ('regression: odd-value break rule', ['computer', ['r1r', 'pu2', 'hena4', 'ment1', 'li1', '.re1', 'an1d', 'a1b', 'a2n', 'e1c', 'o2n', 'io3n.', 'con1'], ['mis-sis-sip-pi', 'ex-cep-tion', 'pro-ject'], 2, 1], 'computer'), ('partial-repair probe', ['Commitment', ['.ta4', 'gr2', 'om1', 't1t', 'e1c', 'a2n', '1q', '1ble', '1tio', 'hen5at', '2mp'], [], 3, 1], 'Com-mitment'), ('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'), ('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', ['b2l', 'hen5at', 'he2n', 'con1', 'ex1', '.un1', 'x1c', '5nd.', 'a2n', 'gr2', 'om1', 'r1r', '1q', '1ble', 's1s', 'l1l', '.ta4'], [], 2, 1], 'Categories'), ('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')], [('regression: odd-value break rule', ['running', ['s1s', 'p2h', '4ing.', 'e1c', '2io', '1ca', 'e2x', 'ex1', '1na', 'at1', 'li1', 'gr2', '.re1', 'x1c', 'ment1', 'ter1', 'n1g', 'ca1t', 'n2at', '1q', 'r1r', '1tio', 'hy3ph', 'm1m', 'io3n.', 'l1l', 'pu2', '.un1', 'o2n', 'a1b', '5nd.', 'c2ce', 'hen5at', '1m', 'hena4'], ['ex-cep-tion', 'pro-ject', 'gram-mar'], 2, 2], 'running'), ('regression: odd-value break rule', ['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'), ('regression: odd-value break rule', ['Paragraph', ['an1d', '5nd.', '.re1', '1ca', '1na', '1p', 'e1c', 'he2n', 'gr2', '.un1', 'ex1', '4ing.', 't1t', 'p2h', 'hen5at', 'li1'], ['mis-sis-sip-pi', 'pro-ject', 'gram-mar'], 1, 1], 'Paragra-ph'), ('regression: odd-value break rule', ['typesetting', ['s1s', '2io', '5nd.', '.re1', 'r1r', '.ta4', '1na', '1ca', 'li1', 'ex1', '4ing.', 'n2at', 'an1d', 'x1c', 'om1', 'hy3ph', 'p2h', '1m', 'a1b', '2mp', 'gr2'], ['pro-ject', 'mis-sis-sip-pi', 'ta-ble'], 1, 3], 'typesetting'), ('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'), ('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'), ('control layout', ['connection', ['e2x', 't1t', 'li1', 'c2ce', 'he2n', 'r1r', '1ble', '5nd.', 'b2l', 'p2h', 'n2at'], ['pro-ject', 'gram-mar'], 2, 2], 'connection'), ('control layout', ['project', ['2mp', 'li1', 'n1g', 'om1', 'e2x', '1tio', '.re1', 'p2h', '1p', 'gr2', 'c2ce', 'hena4', 'ter1', 'he2n', '1m', '1q', '1na', '1ble', 'n2at', 'x1c'], [], 2, 1], 'project')]]
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
word-final pattern ing.runningrunningPassed
regression: odd-value break rulehy-phen-ationhy-phen-ationPassed
regression: odd-value break ruletabletablePassed
regression: odd-value break ruleUn-ex-pe-ctedUn-ex-pe-ctedPassed
right minimum boundaryca-t-egoryca-t-egoryPassed
lowercase exceptionpro-jectpro-jectPassed
control layoutrunningrunningPassed
control layoutunderstandunderstandPassed

SHA-256 / 8e7d23e5f97afc02935e384cc71b870296dfc50d271e2b0ed228bfd329e39a90

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

Case digest / 8bd7c90e5df37260f42259459b695f90f8e62db02300809758fe06b5c123b09b