FAILURE MAP
← Case archive

FA-79916 / Typography line breaking / Open access

Pattern-based hyphenation: competing digit resolution · case 01

Inhibiting even digits are overwritten by later odd digits.

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

ROOT CAUSE

Each matched pattern overwrites the gap value instead of keeping the maximum.

VERIFIED REPAIR

Keep the maximum digit contributed to each gap.

Unsuccessful approach: Summing the digits turns two odd values into an even inhibition.

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] = 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 = [[('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'), ('regression: competing digit resolution', ['Commitment', ['pu2', '.re1', 'b2l', '2io', 'o2n', 'an1d', 'at1', 'a2n', '1m', 'l1l', 'ca1t', 'con1', 'e2x', 'ter1', 'n2at', 't1t', 'hen5at', '1p', '1q', '3ty.', 'ment1', 'ex1', '1na', 'hy3ph', 's1s'], ['ta-ble', 'pro-ject'], 3, 3], 'Com-mit-ment'), ('partial-repair probe', ['Recreation', ['.re1', '5nd.', 'li1', 'ment1', 'o2n', 'hen5at', 's1s', 'n1g', 'ca1t', 'io3n.', 'e2x', '1na', 'c2ce', '1tio', '1p', '2io', 'l1l', 'hena4', 'm1m', 'a2n', 'hy3ph', 'om1', '1m', 'a1b', '.ta4', 'an1d', '.un1', 't1t', 'x1c', 'pu2', 'he2n', 'b2l', 'at1', 'con1', '1q', 'r1r', 'ter1'], [], 2, 2], 'Re-crea-tion'), ('regression: competing digit resolution', ['hyphenation', ['1m', 'n2at', '3ty.', '1tio', '2io', 't1t', 'a2n', 'ca1t', '1p', 'x1c', '1na', '.un1', 'he2n', 'm1m', 'e1c', 'con1', 's1s', 'ex1', '4ing.', 'c2ce', 'hen5at', '1q', 'an1d', 'p2h', 'gr2', '2mp', 'hy3ph', 'l1l', 'r1r', 'n1g', 'ment1', 'ter1', '.re1', 'io3n.', 'at1', '.ta4', '1ble', 'b2l', 'o2n', 'e2x', 'li1', '1ca'], ['gram-mar'], 3, 2], 'hyphen-a-tion'), ('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'), ('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', ['Recreation', ['o2n', '.re1', 't1t', '4ing.', 'l1l', 'm1m', 'gr2', 'li1', 'ter1', '2io'], ['ta-ble', 'ex-cep-tion', 'mis-sis-sip-pi'], 2, 3], 'Re-creation'), ('control layout', ['Paragraph', ['s1s', 'io3n.', 'ca1t', 'x1c', 'hen5at', '.un1', '2mp', '4ing.', 'l1l', '1m', '1tio', 'gr2', 'b2l', '3ty.', 't1t', 'a1b', 'e1c', 'c2ce', 'pu2', 'ter1', 'o2n', '1q', 'r1r', '1p', 'm1m', 'n2at'], ['pro-ject'], 3, 3], 'Paragraph')], [('regression: competing digit resolution', ['Recreation', ['2io', 'li1', 'io3n.', 'a2n', 'ment1', 'n1g', 'e1c', 'ter1', '1q', 'x1c', 'he2n', 'p2h', '1tio', '4ing.', 'm1m', '.re1', 'o2n', 'gr2', 'l1l', '1na', 'om1', '.ta4', 'hena4', '.un1', '1ble', 'con1', '1m', 'ex1', 'hen5at', 'pu2', 'n2at', 'hy3ph', '1ca'], ['pro-ject'], 3, 1], 'Recrea-tio-n'), ('regression: competing digit resolution', ['Table', ['ca1t', '2io', '.re1', 'ex1', 'io3n.', '.un1', 'x1c', 'he2n', 'c2ce', 'a1b', '.ta4', 'gr2', 't1t', '1m', '1ble', 'an1d', 'om1', '4ing.', 'o2n', 'a2n', '5nd.', 'pu2', 'n1g', 's1s', 'con1', 'hena4', 'e2x', 'ter1', '2mp', 'hen5at', 'e1c', 'm1m', 'p2h', 'ment1', '1p', '1q', '1na', '3ty.', '1ca', 'at1', 'b2l', 'n2at'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 1, 1], 'Table'), ('regression: competing digit resolution', ['hyphenation', ['e2x', 'he2n', 'ex1', 'hy3ph', 'io3n.', '5nd.', 'con1', 'om1', '.un1', 'm1m', 'pu2', '1ca', 'n1g', 'ca1t', 'n2at', '2io', '1tio', '4ing.', 's1s', '2mp', 'e1c', 'at1', 't1t', 'x1c', 'hena4', 'ter1', 'ment1', 'gr2', '1m', '1p', 'b2l', 'c2ce', '.re1', '1ble', 'r1r', '.ta4', 'hen5at', 'a1b', 'p2h', '1q'], [], 1, 2], 'hy-phen-ation'), ('regression: competing digit resolution', ['computer', ['1tio', 'om1', 'a1b', 't1t', 'he2n', 'e1c', 'ment1', 'io3n.', '1ble', 'b2l', 'an1d', '2mp', 'pu2', 'o2n', '3ty.', 'l1l', '1na', 'hena4', 'hy3ph', '.ta4', 'con1', 'ex1', 'at1', 'r1r', 'ter1', '5nd.', 'li1', 'ca1t', '1p', '1ca', 'gr2', 'n2at', '.re1', '4ing.', '1m', '.un1', 'a2n', 'x1c', 'e2x', 'n1g', '1q', '2io', 's1s', 'c2ce'], [], 1, 1], 'com-puter'), ('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'), ('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', ['category', ['o2n', '2mp', 'ment1', 't1t', 'con1', 'ca1t', '4ing.', 'm1m', '1ca', '1q', '1ble', 'om1', 'r1r', 'hena4', '.re1', 'n1g', 'at1', 'pu2', 'a1b', 'he2n', '1na', 'gr2', '1m', 'ter1', 'x1c', 'li1', '.ta4', 'hy3ph', 'hen5at', 'n2at', 'io3n.', 'a2n', '3ty.', 'b2l', 'ex1', 'l1l', 'e2x', 'p2h', 's1s', '.un1', '2io', 'an1d'], ['pro-ject', 'mis-sis-sip-pi', 'ex-cep-tion'], 3, 3], 'cat-egory'), ('control layout', ['table', ['e2x', '3ty.', '1tio', 'p2h', 'he2n', 'li1', '.un1', 'con1', '1ca', 'hy3ph', 'm1m', 'b2l', 'r1r', 'io3n.', 'c2ce', 'ca1t'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 1], 'table')], [('regression: competing digit resolution', ['Commitment', ['b2l', 'pu2', 'e1c', 'li1', 'e2x', 'r1r', 'ex1', '1ble', 'm1m', '1tio', 'con1', 'he2n', '1q', '1ca', 'p2h', '5nd.', 'o2n', 'ment1', '2io', 'n2at', '3ty.', '.un1', '.re1', 'om1', 'a1b', '1m', 's1s', 'ca1t', 'hy3ph'], ['ta-ble', 'mis-sis-sip-pi'], 3, 2], 'Com-mit-ment'), ('regression: competing digit resolution', ['Table', ['ca1t', '2io', '.re1', 'ex1', 'io3n.', '.un1', 'x1c', 'he2n', 'c2ce', 'a1b', '.ta4', 'gr2', 't1t', '1m', '1ble', 'an1d', 'om1', '4ing.', 'o2n', 'a2n', '5nd.', 'pu2', 'n1g', 's1s', 'con1', 'hena4', 'e2x', 'ter1', '2mp', 'hen5at', 'e1c', 'm1m', 'p2h', 'ment1', '1p', '1q', '1na', '3ty.', '1ca', 'at1', 'b2l', 'n2at'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 1, 1], 'Table'), ('partial-repair probe', ['battle', ['con1', 'e1c', 't1t', 'om1', 'ca1t', 'he2n', 'o2n', 'x1c', '1ca', 'e2x', 'ex1', 'b2l', 'li1', '1m', 'r1r', 'at1', 'a1b'], [], 2, 3], 'bat-tle'), ('regression: competing digit resolution', ['hyphenation', ['ter1', 'b2l', 'o2n', '5nd.', 'e1c', '.ta4', 'n1g', 'om1', 'hena4', 'pu2', 'l1l', 'a2n', 'r1r', 'hy3ph', 't1t', '.re1', '1p', 'e2x', '1q', 'ca1t', '3ty.', '2mp', '1m', 'ment1', '4ing.', 'x1c', '1ble', 'p2h', 'li1', 'c2ce', 'n2at', '2io', 'an1d', 'con1', 'io3n.', 'm1m', 'gr2', 'ex1', '1na'], ['gram-mar'], 2, 2], 'hy-phe-nation'), ('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', ['running', ['.ta4', 'a2n', 'hena4', 's1s', '2io', 'hen5at', 'e1c', '1p', 'e2x', 'n2at', '.un1', 'hy3ph', 'con1', 'a1b', '1m', '.re1', 'b2l'], [], 2, 2], 'running'), ('control layout', ['Paragraph', ['hena4', 's1s', 'p2h', 'hen5at', '1tio', 'con1', '3ty.', 'x1c', 'e2x', 'o2n', '.re1', '2io', 't1t', '4ing.', '.ta4', '5nd.', 'io3n.', '1ca', 'an1d', '1q', 'ex1', 'at1', '1m', 'gr2', 'ment1', 'hy3ph', 'r1r', '1na', 'pu2', 'om1', 'n2at'], ['pro-ject', 'ex-cep-tion', 'mis-sis-sip-pi'], 1, 2], 'Paragraph')], [('regression: competing digit resolution', ['connection', ['om1', '1ca', '.ta4', 'gr2', 'an1d', '3ty.', 's1s', '2mp', 'p2h', 'a1b', 'con1', 'pu2', 'hena4', '4ing.', 'r1r', '5nd.', 'e2x', '1na', 'hy3ph', '.un1', '1tio', 'c2ce', 'li1', 'l1l', 'ter1', 'o2n', 'he2n', 'ex1', 'a2n', '.re1', 'n2at'], ['ta-ble', 'mis-sis-sip-pi'], 1, 2], 'con-nec-tion'), ('regression: competing digit resolution', ['literally', ['hena4', 'li1', '5nd.', 'om1', 'ex1', 'pu2', '1na', 'ca1t', 'hen5at', 'p2h', 'b2l', 'hy3ph', 's1s', 'ter1'], ['mis-sis-sip-pi'], 1, 3], 'li-ter-ally'), ('regression: competing digit resolution', ['hyphenation', ['c2ce', '1ble', '2mp', 'a1b', '1q', 'n1g', 'a2n', '3ty.', 'o2n', 't1t', '1na', '4ing.', 'he2n', 'ment1', 'io3n.', 'e2x', 'hen5at', 'ter1', 'hy3ph', 's1s', 'pu2', 'ca1t', '.re1', '1m', 'con1', 'm1m', 'p2h', '5nd.', 'li1', 'r1r', '1tio', 'b2l', 'l1l', 'at1', 'ex1', 'om1', '.un1', 'e1c', 'gr2', '.ta4', 'an1d', 'x1c', '1p', 'hena4', '2io', '1ca', 'n2at'], ['gram-mar'], 2, 3], 'hy-phen-ation'), ('regression: competing digit resolution', ['hyphenation', ['1ble', '1ca', 'hy3ph', 'gr2', '5nd.', 'at1', '1tio', 'n2at', 'ex1', 'x1c', '1na', 'ter1', 'b2l', 'e1c', 't1t', '1q', 'li1', '.ta4', 'm1m', 's1s', 'e2x', 'con1', '2mp', 'r1r', 'hena4', '.re1', '2io', 'c2ce', 'om1', 'p2h', '1p', 'ca1t', 'l1l', 'o2n', 'pu2', 'n1g', 'a1b', 'io3n.', '1m', 'ment1'], ['mis-sis-sip-pi', 'ta-ble'], 1, 1], 'hy-phe-natio-n'), ('lowercase exception', ['project', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['pro-ject'], 2, 3], 'pro-ject'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['understand', ['io3n.', 'n1g', 'x1c', 'e1c', 'l1l', 'con1', 's1s', 'm1m', 'li1', '.re1', '2mp', 'ter1', '1ca', 'hena4', '5nd.', 'an1d', '3ty.', 'b2l', 't1t', 'ex1', 'c2ce', 'om1', '1tio', '4ing.', 'e2x', 'hy3ph', '1p', 'a1b', 'pu2', 'he2n', 'ment1', '1ble', 'gr2', 'hen5at', '.ta4', 'r1r', '.un1', '1m', 'n2at', 'ca1t', 'p2h', '1na', '2io', '1q'], ['ta-ble', 'gram-mar', 'ex-cep-tion'], 2, 3], 'un-derstand'), ('control layout', ['terminal', ['hen5at', 'con1', 'a2n', 'gr2', '1m', 'at1', '.re1', 'n1g', 'e2x', '4ing.', '.ta4', 'p2h'], [], 3, 2], 'ter-minal')], [('regression: competing digit resolution', ['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: competing digit resolution', ['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'), ('regression: competing digit resolution', ['computer', ['1tio', 'om1', 'a1b', 't1t', 'he2n', 'e1c', 'ment1', 'io3n.', '1ble', 'b2l', 'an1d', '2mp', 'pu2', 'o2n', '3ty.', 'l1l', '1na', 'hena4', 'hy3ph', '.ta4', 'con1', 'ex1', 'at1', 'r1r', 'ter1', '5nd.', 'li1', 'ca1t', '1p', '1ca', 'gr2', 'n2at', '.re1', '4ing.', '1m', '.un1', 'a2n', 'x1c', 'e2x', 'n1g', '1q', '2io', 's1s', 'c2ce'], [], 1, 1], 'com-puter'), ('partial-repair probe', ['Recreation', ['4ing.', 'r1r', '.ta4', 't1t', 'pu2', 'ter1', 'at1', 'c2ce', '2mp', 'li1', 'l1l', '1m', 'a1b', 'n2at', '.un1', 'n1g', 'm1m', 'hy3ph', 'e2x', 'om1', '1ble', 'a2n', 'x1c', 'he2n', '1tio', '.re1', 'ca1t', '1ca', '2io', 'gr2', 's1s', '1q', 'io3n.', 'o2n', 'hen5at', 'p2h', '3ty.', 'ex1', 'e1c', '1na', 'b2l'], ['ta-ble', 'gram-mar', 'pro-ject'], 1, 3], 'Re-crea-tion'), ('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', ['grammar', ['l1l', '5nd.', 'ter1', 'gr2', 't1t', 'ex1', 'b2l', 'om1', 'a2n', 'm1m', 'n1g', 'p2h', '1tio', 'hen5at', '1ca', '.ta4', 'n2at', '1na', 'hena4', '.re1', 'ment1', 'e2x', 'c2ce', '2mp', 'ca1t', '4ing.', 'r1r', 'io3n.', 'x1c'], [], 2, 2], 'gram-mar'), ('control layout', ['Mississippi', ['b2l', 't1t', 'o2n', 'io3n.', 'ment1', 'hen5at', 'hy3ph', 'hena4', 'con1', 's1s', '.re1', 'ca1t', 'li1', '4ing.', 'l1l', '2mp', 'e2x', 'om1'], ['gram-mar', 'pro-ject', 'ta-ble'], 1, 2], 'Mis-sis-sippi')]]
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
right minimum boundarycat-egoryca-t-egoryFailed
regression: competing digit resolutionCom-mitmentCom-mit-mentFailed
partial-repair probeRe-crea-tionRe-crea-tionPassed
regression: competing digit resolutionhyphena-tionhyphen-a-tionFailed
lowercase exceptionpro-jectpro-jectPassed
left minimum boundaryex-cel-lentex-cel-lentPassed
control layoutRe-creationRe-creationPassed
control layoutParagraphParagraphPassed

SHA-256 / 42792e5e7a44470875ea542998841dc394e2eb3d9b62fbe05eec833d208e34d7

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] = 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 = [[('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'), ('regression: competing digit resolution', ['Commitment', ['pu2', '.re1', 'b2l', '2io', 'o2n', 'an1d', 'at1', 'a2n', '1m', 'l1l', 'ca1t', 'con1', 'e2x', 'ter1', 'n2at', 't1t', 'hen5at', '1p', '1q', '3ty.', 'ment1', 'ex1', '1na', 'hy3ph', 's1s'], ['ta-ble', 'pro-ject'], 3, 3], 'Com-mit-ment'), ('partial-repair probe', ['Recreation', ['.re1', '5nd.', 'li1', 'ment1', 'o2n', 'hen5at', 's1s', 'n1g', 'ca1t', 'io3n.', 'e2x', '1na', 'c2ce', '1tio', '1p', '2io', 'l1l', 'hena4', 'm1m', 'a2n', 'hy3ph', 'om1', '1m', 'a1b', '.ta4', 'an1d', '.un1', 't1t', 'x1c', 'pu2', 'he2n', 'b2l', 'at1', 'con1', '1q', 'r1r', 'ter1'], [], 2, 2], 'Re-crea-tion'), ('regression: competing digit resolution', ['hyphenation', ['1m', 'n2at', '3ty.', '1tio', '2io', 't1t', 'a2n', 'ca1t', '1p', 'x1c', '1na', '.un1', 'he2n', 'm1m', 'e1c', 'con1', 's1s', 'ex1', '4ing.', 'c2ce', 'hen5at', '1q', 'an1d', 'p2h', 'gr2', '2mp', 'hy3ph', 'l1l', 'r1r', 'n1g', 'ment1', 'ter1', '.re1', 'io3n.', 'at1', '.ta4', '1ble', 'b2l', 'o2n', 'e2x', 'li1', '1ca'], ['gram-mar'], 3, 2], 'hyphen-a-tion'), ('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'), ('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', ['Recreation', ['o2n', '.re1', 't1t', '4ing.', 'l1l', 'm1m', 'gr2', 'li1', 'ter1', '2io'], ['ta-ble', 'ex-cep-tion', 'mis-sis-sip-pi'], 2, 3], 'Re-creation'), ('control layout', ['Paragraph', ['s1s', 'io3n.', 'ca1t', 'x1c', 'hen5at', '.un1', '2mp', '4ing.', 'l1l', '1m', '1tio', 'gr2', 'b2l', '3ty.', 't1t', 'a1b', 'e1c', 'c2ce', 'pu2', 'ter1', 'o2n', '1q', 'r1r', '1p', 'm1m', 'n2at'], ['pro-ject'], 3, 3], 'Paragraph')], [('regression: competing digit resolution', ['Recreation', ['2io', 'li1', 'io3n.', 'a2n', 'ment1', 'n1g', 'e1c', 'ter1', '1q', 'x1c', 'he2n', 'p2h', '1tio', '4ing.', 'm1m', '.re1', 'o2n', 'gr2', 'l1l', '1na', 'om1', '.ta4', 'hena4', '.un1', '1ble', 'con1', '1m', 'ex1', 'hen5at', 'pu2', 'n2at', 'hy3ph', '1ca'], ['pro-ject'], 3, 1], 'Recrea-tio-n'), ('regression: competing digit resolution', ['Table', ['ca1t', '2io', '.re1', 'ex1', 'io3n.', '.un1', 'x1c', 'he2n', 'c2ce', 'a1b', '.ta4', 'gr2', 't1t', '1m', '1ble', 'an1d', 'om1', '4ing.', 'o2n', 'a2n', '5nd.', 'pu2', 'n1g', 's1s', 'con1', 'hena4', 'e2x', 'ter1', '2mp', 'hen5at', 'e1c', 'm1m', 'p2h', 'ment1', '1p', '1q', '1na', '3ty.', '1ca', 'at1', 'b2l', 'n2at'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 1, 1], 'Table'), ('regression: competing digit resolution', ['hyphenation', ['e2x', 'he2n', 'ex1', 'hy3ph', 'io3n.', '5nd.', 'con1', 'om1', '.un1', 'm1m', 'pu2', '1ca', 'n1g', 'ca1t', 'n2at', '2io', '1tio', '4ing.', 's1s', '2mp', 'e1c', 'at1', 't1t', 'x1c', 'hena4', 'ter1', 'ment1', 'gr2', '1m', '1p', 'b2l', 'c2ce', '.re1', '1ble', 'r1r', '.ta4', 'hen5at', 'a1b', 'p2h', '1q'], [], 1, 2], 'hy-phen-ation'), ('regression: competing digit resolution', ['computer', ['1tio', 'om1', 'a1b', 't1t', 'he2n', 'e1c', 'ment1', 'io3n.', '1ble', 'b2l', 'an1d', '2mp', 'pu2', 'o2n', '3ty.', 'l1l', '1na', 'hena4', 'hy3ph', '.ta4', 'con1', 'ex1', 'at1', 'r1r', 'ter1', '5nd.', 'li1', 'ca1t', '1p', '1ca', 'gr2', 'n2at', '.re1', '4ing.', '1m', '.un1', 'a2n', 'x1c', 'e2x', 'n1g', '1q', '2io', 's1s', 'c2ce'], [], 1, 1], 'com-puter'), ('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'), ('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', ['category', ['o2n', '2mp', 'ment1', 't1t', 'con1', 'ca1t', '4ing.', 'm1m', '1ca', '1q', '1ble', 'om1', 'r1r', 'hena4', '.re1', 'n1g', 'at1', 'pu2', 'a1b', 'he2n', '1na', 'gr2', '1m', 'ter1', 'x1c', 'li1', '.ta4', 'hy3ph', 'hen5at', 'n2at', 'io3n.', 'a2n', '3ty.', 'b2l', 'ex1', 'l1l', 'e2x', 'p2h', 's1s', '.un1', '2io', 'an1d'], ['pro-ject', 'mis-sis-sip-pi', 'ex-cep-tion'], 3, 3], 'cat-egory'), ('control layout', ['table', ['e2x', '3ty.', '1tio', 'p2h', 'he2n', 'li1', '.un1', 'con1', '1ca', 'hy3ph', 'm1m', 'b2l', 'r1r', 'io3n.', 'c2ce', 'ca1t'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 1], 'table')], [('regression: competing digit resolution', ['Commitment', ['b2l', 'pu2', 'e1c', 'li1', 'e2x', 'r1r', 'ex1', '1ble', 'm1m', '1tio', 'con1', 'he2n', '1q', '1ca', 'p2h', '5nd.', 'o2n', 'ment1', '2io', 'n2at', '3ty.', '.un1', '.re1', 'om1', 'a1b', '1m', 's1s', 'ca1t', 'hy3ph'], ['ta-ble', 'mis-sis-sip-pi'], 3, 2], 'Com-mit-ment'), ('regression: competing digit resolution', ['Table', ['ca1t', '2io', '.re1', 'ex1', 'io3n.', '.un1', 'x1c', 'he2n', 'c2ce', 'a1b', '.ta4', 'gr2', 't1t', '1m', '1ble', 'an1d', 'om1', '4ing.', 'o2n', 'a2n', '5nd.', 'pu2', 'n1g', 's1s', 'con1', 'hena4', 'e2x', 'ter1', '2mp', 'hen5at', 'e1c', 'm1m', 'p2h', 'ment1', '1p', '1q', '1na', '3ty.', '1ca', 'at1', 'b2l', 'n2at'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 1, 1], 'Table'), ('partial-repair probe', ['battle', ['con1', 'e1c', 't1t', 'om1', 'ca1t', 'he2n', 'o2n', 'x1c', '1ca', 'e2x', 'ex1', 'b2l', 'li1', '1m', 'r1r', 'at1', 'a1b'], [], 2, 3], 'bat-tle'), ('regression: competing digit resolution', ['hyphenation', ['ter1', 'b2l', 'o2n', '5nd.', 'e1c', '.ta4', 'n1g', 'om1', 'hena4', 'pu2', 'l1l', 'a2n', 'r1r', 'hy3ph', 't1t', '.re1', '1p', 'e2x', '1q', 'ca1t', '3ty.', '2mp', '1m', 'ment1', '4ing.', 'x1c', '1ble', 'p2h', 'li1', 'c2ce', 'n2at', '2io', 'an1d', 'con1', 'io3n.', 'm1m', 'gr2', 'ex1', '1na'], ['gram-mar'], 2, 2], 'hy-phe-nation'), ('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', ['running', ['.ta4', 'a2n', 'hena4', 's1s', '2io', 'hen5at', 'e1c', '1p', 'e2x', 'n2at', '.un1', 'hy3ph', 'con1', 'a1b', '1m', '.re1', 'b2l'], [], 2, 2], 'running'), ('control layout', ['Paragraph', ['hena4', 's1s', 'p2h', 'hen5at', '1tio', 'con1', '3ty.', 'x1c', 'e2x', 'o2n', '.re1', '2io', 't1t', '4ing.', '.ta4', '5nd.', 'io3n.', '1ca', 'an1d', '1q', 'ex1', 'at1', '1m', 'gr2', 'ment1', 'hy3ph', 'r1r', '1na', 'pu2', 'om1', 'n2at'], ['pro-ject', 'ex-cep-tion', 'mis-sis-sip-pi'], 1, 2], 'Paragraph')], [('regression: competing digit resolution', ['connection', ['om1', '1ca', '.ta4', 'gr2', 'an1d', '3ty.', 's1s', '2mp', 'p2h', 'a1b', 'con1', 'pu2', 'hena4', '4ing.', 'r1r', '5nd.', 'e2x', '1na', 'hy3ph', '.un1', '1tio', 'c2ce', 'li1', 'l1l', 'ter1', 'o2n', 'he2n', 'ex1', 'a2n', '.re1', 'n2at'], ['ta-ble', 'mis-sis-sip-pi'], 1, 2], 'con-nec-tion'), ('regression: competing digit resolution', ['literally', ['hena4', 'li1', '5nd.', 'om1', 'ex1', 'pu2', '1na', 'ca1t', 'hen5at', 'p2h', 'b2l', 'hy3ph', 's1s', 'ter1'], ['mis-sis-sip-pi'], 1, 3], 'li-ter-ally'), ('regression: competing digit resolution', ['hyphenation', ['c2ce', '1ble', '2mp', 'a1b', '1q', 'n1g', 'a2n', '3ty.', 'o2n', 't1t', '1na', '4ing.', 'he2n', 'ment1', 'io3n.', 'e2x', 'hen5at', 'ter1', 'hy3ph', 's1s', 'pu2', 'ca1t', '.re1', '1m', 'con1', 'm1m', 'p2h', '5nd.', 'li1', 'r1r', '1tio', 'b2l', 'l1l', 'at1', 'ex1', 'om1', '.un1', 'e1c', 'gr2', '.ta4', 'an1d', 'x1c', '1p', 'hena4', '2io', '1ca', 'n2at'], ['gram-mar'], 2, 3], 'hy-phen-ation'), ('regression: competing digit resolution', ['hyphenation', ['1ble', '1ca', 'hy3ph', 'gr2', '5nd.', 'at1', '1tio', 'n2at', 'ex1', 'x1c', '1na', 'ter1', 'b2l', 'e1c', 't1t', '1q', 'li1', '.ta4', 'm1m', 's1s', 'e2x', 'con1', '2mp', 'r1r', 'hena4', '.re1', '2io', 'c2ce', 'om1', 'p2h', '1p', 'ca1t', 'l1l', 'o2n', 'pu2', 'n1g', 'a1b', 'io3n.', '1m', 'ment1'], ['mis-sis-sip-pi', 'ta-ble'], 1, 1], 'hy-phe-natio-n'), ('lowercase exception', ['project', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['pro-ject'], 2, 3], 'pro-ject'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['understand', ['io3n.', 'n1g', 'x1c', 'e1c', 'l1l', 'con1', 's1s', 'm1m', 'li1', '.re1', '2mp', 'ter1', '1ca', 'hena4', '5nd.', 'an1d', '3ty.', 'b2l', 't1t', 'ex1', 'c2ce', 'om1', '1tio', '4ing.', 'e2x', 'hy3ph', '1p', 'a1b', 'pu2', 'he2n', 'ment1', '1ble', 'gr2', 'hen5at', '.ta4', 'r1r', '.un1', '1m', 'n2at', 'ca1t', 'p2h', '1na', '2io', '1q'], ['ta-ble', 'gram-mar', 'ex-cep-tion'], 2, 3], 'un-derstand'), ('control layout', ['terminal', ['hen5at', 'con1', 'a2n', 'gr2', '1m', 'at1', '.re1', 'n1g', 'e2x', '4ing.', '.ta4', 'p2h'], [], 3, 2], 'ter-minal')], [('regression: competing digit resolution', ['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: competing digit resolution', ['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'), ('regression: competing digit resolution', ['computer', ['1tio', 'om1', 'a1b', 't1t', 'he2n', 'e1c', 'ment1', 'io3n.', '1ble', 'b2l', 'an1d', '2mp', 'pu2', 'o2n', '3ty.', 'l1l', '1na', 'hena4', 'hy3ph', '.ta4', 'con1', 'ex1', 'at1', 'r1r', 'ter1', '5nd.', 'li1', 'ca1t', '1p', '1ca', 'gr2', 'n2at', '.re1', '4ing.', '1m', '.un1', 'a2n', 'x1c', 'e2x', 'n1g', '1q', '2io', 's1s', 'c2ce'], [], 1, 1], 'com-puter'), ('partial-repair probe', ['Recreation', ['4ing.', 'r1r', '.ta4', 't1t', 'pu2', 'ter1', 'at1', 'c2ce', '2mp', 'li1', 'l1l', '1m', 'a1b', 'n2at', '.un1', 'n1g', 'm1m', 'hy3ph', 'e2x', 'om1', '1ble', 'a2n', 'x1c', 'he2n', '1tio', '.re1', 'ca1t', '1ca', '2io', 'gr2', 's1s', '1q', 'io3n.', 'o2n', 'hen5at', 'p2h', '3ty.', 'ex1', 'e1c', '1na', 'b2l'], ['ta-ble', 'gram-mar', 'pro-ject'], 1, 3], 'Re-crea-tion'), ('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', ['grammar', ['l1l', '5nd.', 'ter1', 'gr2', 't1t', 'ex1', 'b2l', 'om1', 'a2n', 'm1m', 'n1g', 'p2h', '1tio', 'hen5at', '1ca', '.ta4', 'n2at', '1na', 'hena4', '.re1', 'ment1', 'e2x', 'c2ce', '2mp', 'ca1t', '4ing.', 'r1r', 'io3n.', 'x1c'], [], 2, 2], 'gram-mar'), ('control layout', ['Mississippi', ['b2l', 't1t', 'o2n', 'io3n.', 'ment1', 'hen5at', 'hy3ph', 'hena4', 'con1', 's1s', '.re1', 'ca1t', 'li1', '4ing.', 'l1l', '2mp', 'e2x', 'om1'], ['gram-mar', 'pro-ject', 'ta-ble'], 1, 2], 'Mis-sis-sippi')]]
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
right minimum boundaryca-t-egoryca-t-egoryPassed
regression: competing digit resolutionCom-mit-mentCom-mit-mentPassed
partial-repair probeRe-crea-t-ionRe-crea-tionFailed
regression: competing digit resolutionhyphe-n-a-t-ionhyphen-a-tionFailed
lowercase exceptionpro-jectpro-jectPassed
left minimum boundaryex-cel-lentex-cel-lentPassed
control layoutRe-creationRe-creationPassed
control layoutParagraphParagraphPassed

SHA-256 / 2bf273c280d09fcf44ccd20e9ebbf5f12d333f32d2bed5d9b673f9c268f85891

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 = [[('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'), ('regression: competing digit resolution', ['Commitment', ['pu2', '.re1', 'b2l', '2io', 'o2n', 'an1d', 'at1', 'a2n', '1m', 'l1l', 'ca1t', 'con1', 'e2x', 'ter1', 'n2at', 't1t', 'hen5at', '1p', '1q', '3ty.', 'ment1', 'ex1', '1na', 'hy3ph', 's1s'], ['ta-ble', 'pro-ject'], 3, 3], 'Com-mit-ment'), ('partial-repair probe', ['Recreation', ['.re1', '5nd.', 'li1', 'ment1', 'o2n', 'hen5at', 's1s', 'n1g', 'ca1t', 'io3n.', 'e2x', '1na', 'c2ce', '1tio', '1p', '2io', 'l1l', 'hena4', 'm1m', 'a2n', 'hy3ph', 'om1', '1m', 'a1b', '.ta4', 'an1d', '.un1', 't1t', 'x1c', 'pu2', 'he2n', 'b2l', 'at1', 'con1', '1q', 'r1r', 'ter1'], [], 2, 2], 'Re-crea-tion'), ('regression: competing digit resolution', ['hyphenation', ['1m', 'n2at', '3ty.', '1tio', '2io', 't1t', 'a2n', 'ca1t', '1p', 'x1c', '1na', '.un1', 'he2n', 'm1m', 'e1c', 'con1', 's1s', 'ex1', '4ing.', 'c2ce', 'hen5at', '1q', 'an1d', 'p2h', 'gr2', '2mp', 'hy3ph', 'l1l', 'r1r', 'n1g', 'ment1', 'ter1', '.re1', 'io3n.', 'at1', '.ta4', '1ble', 'b2l', 'o2n', 'e2x', 'li1', '1ca'], ['gram-mar'], 3, 2], 'hyphen-a-tion'), ('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'), ('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', ['Recreation', ['o2n', '.re1', 't1t', '4ing.', 'l1l', 'm1m', 'gr2', 'li1', 'ter1', '2io'], ['ta-ble', 'ex-cep-tion', 'mis-sis-sip-pi'], 2, 3], 'Re-creation'), ('control layout', ['Paragraph', ['s1s', 'io3n.', 'ca1t', 'x1c', 'hen5at', '.un1', '2mp', '4ing.', 'l1l', '1m', '1tio', 'gr2', 'b2l', '3ty.', 't1t', 'a1b', 'e1c', 'c2ce', 'pu2', 'ter1', 'o2n', '1q', 'r1r', '1p', 'm1m', 'n2at'], ['pro-ject'], 3, 3], 'Paragraph')], [('regression: competing digit resolution', ['Recreation', ['2io', 'li1', 'io3n.', 'a2n', 'ment1', 'n1g', 'e1c', 'ter1', '1q', 'x1c', 'he2n', 'p2h', '1tio', '4ing.', 'm1m', '.re1', 'o2n', 'gr2', 'l1l', '1na', 'om1', '.ta4', 'hena4', '.un1', '1ble', 'con1', '1m', 'ex1', 'hen5at', 'pu2', 'n2at', 'hy3ph', '1ca'], ['pro-ject'], 3, 1], 'Recrea-tio-n'), ('regression: competing digit resolution', ['Table', ['ca1t', '2io', '.re1', 'ex1', 'io3n.', '.un1', 'x1c', 'he2n', 'c2ce', 'a1b', '.ta4', 'gr2', 't1t', '1m', '1ble', 'an1d', 'om1', '4ing.', 'o2n', 'a2n', '5nd.', 'pu2', 'n1g', 's1s', 'con1', 'hena4', 'e2x', 'ter1', '2mp', 'hen5at', 'e1c', 'm1m', 'p2h', 'ment1', '1p', '1q', '1na', '3ty.', '1ca', 'at1', 'b2l', 'n2at'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 1, 1], 'Table'), ('regression: competing digit resolution', ['hyphenation', ['e2x', 'he2n', 'ex1', 'hy3ph', 'io3n.', '5nd.', 'con1', 'om1', '.un1', 'm1m', 'pu2', '1ca', 'n1g', 'ca1t', 'n2at', '2io', '1tio', '4ing.', 's1s', '2mp', 'e1c', 'at1', 't1t', 'x1c', 'hena4', 'ter1', 'ment1', 'gr2', '1m', '1p', 'b2l', 'c2ce', '.re1', '1ble', 'r1r', '.ta4', 'hen5at', 'a1b', 'p2h', '1q'], [], 1, 2], 'hy-phen-ation'), ('regression: competing digit resolution', ['computer', ['1tio', 'om1', 'a1b', 't1t', 'he2n', 'e1c', 'ment1', 'io3n.', '1ble', 'b2l', 'an1d', '2mp', 'pu2', 'o2n', '3ty.', 'l1l', '1na', 'hena4', 'hy3ph', '.ta4', 'con1', 'ex1', 'at1', 'r1r', 'ter1', '5nd.', 'li1', 'ca1t', '1p', '1ca', 'gr2', 'n2at', '.re1', '4ing.', '1m', '.un1', 'a2n', 'x1c', 'e2x', 'n1g', '1q', '2io', 's1s', 'c2ce'], [], 1, 1], 'com-puter'), ('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'), ('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', ['category', ['o2n', '2mp', 'ment1', 't1t', 'con1', 'ca1t', '4ing.', 'm1m', '1ca', '1q', '1ble', 'om1', 'r1r', 'hena4', '.re1', 'n1g', 'at1', 'pu2', 'a1b', 'he2n', '1na', 'gr2', '1m', 'ter1', 'x1c', 'li1', '.ta4', 'hy3ph', 'hen5at', 'n2at', 'io3n.', 'a2n', '3ty.', 'b2l', 'ex1', 'l1l', 'e2x', 'p2h', 's1s', '.un1', '2io', 'an1d'], ['pro-ject', 'mis-sis-sip-pi', 'ex-cep-tion'], 3, 3], 'cat-egory'), ('control layout', ['table', ['e2x', '3ty.', '1tio', 'p2h', 'he2n', 'li1', '.un1', 'con1', '1ca', 'hy3ph', 'm1m', 'b2l', 'r1r', 'io3n.', 'c2ce', 'ca1t'], ['mis-sis-sip-pi', 'ex-cep-tion'], 2, 1], 'table')], [('regression: competing digit resolution', ['Commitment', ['b2l', 'pu2', 'e1c', 'li1', 'e2x', 'r1r', 'ex1', '1ble', 'm1m', '1tio', 'con1', 'he2n', '1q', '1ca', 'p2h', '5nd.', 'o2n', 'ment1', '2io', 'n2at', '3ty.', '.un1', '.re1', 'om1', 'a1b', '1m', 's1s', 'ca1t', 'hy3ph'], ['ta-ble', 'mis-sis-sip-pi'], 3, 2], 'Com-mit-ment'), ('regression: competing digit resolution', ['Table', ['ca1t', '2io', '.re1', 'ex1', 'io3n.', '.un1', 'x1c', 'he2n', 'c2ce', 'a1b', '.ta4', 'gr2', 't1t', '1m', '1ble', 'an1d', 'om1', '4ing.', 'o2n', 'a2n', '5nd.', 'pu2', 'n1g', 's1s', 'con1', 'hena4', 'e2x', 'ter1', '2mp', 'hen5at', 'e1c', 'm1m', 'p2h', 'ment1', '1p', '1q', '1na', '3ty.', '1ca', 'at1', 'b2l', 'n2at'], ['gram-mar', 'ex-cep-tion', 'pro-ject'], 1, 1], 'Table'), ('partial-repair probe', ['battle', ['con1', 'e1c', 't1t', 'om1', 'ca1t', 'he2n', 'o2n', 'x1c', '1ca', 'e2x', 'ex1', 'b2l', 'li1', '1m', 'r1r', 'at1', 'a1b'], [], 2, 3], 'bat-tle'), ('regression: competing digit resolution', ['hyphenation', ['ter1', 'b2l', 'o2n', '5nd.', 'e1c', '.ta4', 'n1g', 'om1', 'hena4', 'pu2', 'l1l', 'a2n', 'r1r', 'hy3ph', 't1t', '.re1', '1p', 'e2x', '1q', 'ca1t', '3ty.', '2mp', '1m', 'ment1', '4ing.', 'x1c', '1ble', 'p2h', 'li1', 'c2ce', 'n2at', '2io', 'an1d', 'con1', 'io3n.', 'm1m', 'gr2', 'ex1', '1na'], ['gram-mar'], 2, 2], 'hy-phe-nation'), ('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', ['running', ['.ta4', 'a2n', 'hena4', 's1s', '2io', 'hen5at', 'e1c', '1p', 'e2x', 'n2at', '.un1', 'hy3ph', 'con1', 'a1b', '1m', '.re1', 'b2l'], [], 2, 2], 'running'), ('control layout', ['Paragraph', ['hena4', 's1s', 'p2h', 'hen5at', '1tio', 'con1', '3ty.', 'x1c', 'e2x', 'o2n', '.re1', '2io', 't1t', '4ing.', '.ta4', '5nd.', 'io3n.', '1ca', 'an1d', '1q', 'ex1', 'at1', '1m', 'gr2', 'ment1', 'hy3ph', 'r1r', '1na', 'pu2', 'om1', 'n2at'], ['pro-ject', 'ex-cep-tion', 'mis-sis-sip-pi'], 1, 2], 'Paragraph')], [('regression: competing digit resolution', ['connection', ['om1', '1ca', '.ta4', 'gr2', 'an1d', '3ty.', 's1s', '2mp', 'p2h', 'a1b', 'con1', 'pu2', 'hena4', '4ing.', 'r1r', '5nd.', 'e2x', '1na', 'hy3ph', '.un1', '1tio', 'c2ce', 'li1', 'l1l', 'ter1', 'o2n', 'he2n', 'ex1', 'a2n', '.re1', 'n2at'], ['ta-ble', 'mis-sis-sip-pi'], 1, 2], 'con-nec-tion'), ('regression: competing digit resolution', ['literally', ['hena4', 'li1', '5nd.', 'om1', 'ex1', 'pu2', '1na', 'ca1t', 'hen5at', 'p2h', 'b2l', 'hy3ph', 's1s', 'ter1'], ['mis-sis-sip-pi'], 1, 3], 'li-ter-ally'), ('regression: competing digit resolution', ['hyphenation', ['c2ce', '1ble', '2mp', 'a1b', '1q', 'n1g', 'a2n', '3ty.', 'o2n', 't1t', '1na', '4ing.', 'he2n', 'ment1', 'io3n.', 'e2x', 'hen5at', 'ter1', 'hy3ph', 's1s', 'pu2', 'ca1t', '.re1', '1m', 'con1', 'm1m', 'p2h', '5nd.', 'li1', 'r1r', '1tio', 'b2l', 'l1l', 'at1', 'ex1', 'om1', '.un1', 'e1c', 'gr2', '.ta4', 'an1d', 'x1c', '1p', 'hena4', '2io', '1ca', 'n2at'], ['gram-mar'], 2, 3], 'hy-phen-ation'), ('regression: competing digit resolution', ['hyphenation', ['1ble', '1ca', 'hy3ph', 'gr2', '5nd.', 'at1', '1tio', 'n2at', 'ex1', 'x1c', '1na', 'ter1', 'b2l', 'e1c', 't1t', '1q', 'li1', '.ta4', 'm1m', 's1s', 'e2x', 'con1', '2mp', 'r1r', 'hena4', '.re1', '2io', 'c2ce', 'om1', 'p2h', '1p', 'ca1t', 'l1l', 'o2n', 'pu2', 'n1g', 'a1b', 'io3n.', '1m', 'ment1'], ['mis-sis-sip-pi', 'ta-ble'], 1, 1], 'hy-phe-natio-n'), ('lowercase exception', ['project', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['pro-ject'], 2, 3], 'pro-ject'), ('capitalised exception', ['Table', ['.ta4', 'a1b', 'b2l', '1ble', 'hy3ph', 'he2n', 'hena4', 'hen5at', '1na', 'n2at', '1tio', '2io', 'o2n', 'pu2', 'ter1', '1m', 'ex1', 'e1c', 'c2ce', 'con1', 'ment1', '4ing.', 'n1g', '.re1', 'gr2', '3ty.', 'li1', '1ca', 'ca1t', 'at1', 'io3n.', 'r1r', 'm1m', 'l1l', 't1t', 's1s', 'a2n', 'an1d', '5nd.', '1p', 'p2h', '1q', '.un1', 'e2x', 'x1c', '2mp', 'om1'], ['ta-ble'], 1, 1], 'Ta-ble'), ('control layout', ['understand', ['io3n.', 'n1g', 'x1c', 'e1c', 'l1l', 'con1', 's1s', 'm1m', 'li1', '.re1', '2mp', 'ter1', '1ca', 'hena4', '5nd.', 'an1d', '3ty.', 'b2l', 't1t', 'ex1', 'c2ce', 'om1', '1tio', '4ing.', 'e2x', 'hy3ph', '1p', 'a1b', 'pu2', 'he2n', 'ment1', '1ble', 'gr2', 'hen5at', '.ta4', 'r1r', '.un1', '1m', 'n2at', 'ca1t', 'p2h', '1na', '2io', '1q'], ['ta-ble', 'gram-mar', 'ex-cep-tion'], 2, 3], 'un-derstand'), ('control layout', ['terminal', ['hen5at', 'con1', 'a2n', 'gr2', '1m', 'at1', '.re1', 'n1g', 'e2x', '4ing.', '.ta4', 'p2h'], [], 3, 2], 'ter-minal')], [('regression: competing digit resolution', ['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: competing digit resolution', ['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'), ('regression: competing digit resolution', ['computer', ['1tio', 'om1', 'a1b', 't1t', 'he2n', 'e1c', 'ment1', 'io3n.', '1ble', 'b2l', 'an1d', '2mp', 'pu2', 'o2n', '3ty.', 'l1l', '1na', 'hena4', 'hy3ph', '.ta4', 'con1', 'ex1', 'at1', 'r1r', 'ter1', '5nd.', 'li1', 'ca1t', '1p', '1ca', 'gr2', 'n2at', '.re1', '4ing.', '1m', '.un1', 'a2n', 'x1c', 'e2x', 'n1g', '1q', '2io', 's1s', 'c2ce'], [], 1, 1], 'com-puter'), ('partial-repair probe', ['Recreation', ['4ing.', 'r1r', '.ta4', 't1t', 'pu2', 'ter1', 'at1', 'c2ce', '2mp', 'li1', 'l1l', '1m', 'a1b', 'n2at', '.un1', 'n1g', 'm1m', 'hy3ph', 'e2x', 'om1', '1ble', 'a2n', 'x1c', 'he2n', '1tio', '.re1', 'ca1t', '1ca', '2io', 'gr2', 's1s', '1q', 'io3n.', 'o2n', 'hen5at', 'p2h', '3ty.', 'ex1', 'e1c', '1na', 'b2l'], ['ta-ble', 'gram-mar', 'pro-ject'], 1, 3], 'Re-crea-tion'), ('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', ['grammar', ['l1l', '5nd.', 'ter1', 'gr2', 't1t', 'ex1', 'b2l', 'om1', 'a2n', 'm1m', 'n1g', 'p2h', '1tio', 'hen5at', '1ca', '.ta4', 'n2at', '1na', 'hena4', '.re1', 'ment1', 'e2x', 'c2ce', '2mp', 'ca1t', '4ing.', 'r1r', 'io3n.', 'x1c'], [], 2, 2], 'gram-mar'), ('control layout', ['Mississippi', ['b2l', 't1t', 'o2n', 'io3n.', 'ment1', 'hen5at', 'hy3ph', 'hena4', 'con1', 's1s', '.re1', 'ca1t', 'li1', '4ing.', 'l1l', '2mp', 'e2x', 'om1'], ['gram-mar', 'pro-ject', 'ta-ble'], 1, 2], 'Mis-sis-sippi')]]
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
right minimum boundaryca-t-egoryca-t-egoryPassed
regression: competing digit resolutionCom-mit-mentCom-mit-mentPassed
partial-repair probeRe-crea-tionRe-crea-tionPassed
regression: competing digit resolutionhyphen-a-tionhyphen-a-tionPassed
lowercase exceptionpro-jectpro-jectPassed
left minimum boundaryex-cel-lentex-cel-lentPassed
control layoutRe-creationRe-creationPassed
control layoutParagraphParagraphPassed

SHA-256 / 95ff4bcdcea91ccb864d29ae0e72782c5671b9579d3b4cd3fdb953b5a5fa2163

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

Case digest / 26f35109e630c3f98ffef5c37d1663ef55e28e0cdee76a60eae47e628c5932c1