FAILURE MAP
← Case archive

FA-80056 / Typography line breaking / Open access

Box-glue-penalty breakpoints: discardable items at line start · case 01

Penalties left at the start of a line produce empty breaks.

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

ROOT CAUSE

Only glue is discarded after a break; penalties survive at the line start.

VERIFIED REPAIR

Drop every non-box item at the start of a line.

Unsuccessful approach: Dropping penalties but keeping glue leaves leading glue breakpoints.

Case contract

Input [items, width]; items are ["b",w], ["g",w] or ["p",w,cost,flag]. Legal breaks: glue immediately after a box; penalty with cost < 10000 (width counted only if broken there); cost <= -10000 forces a break. Discardable glue/penalties at a line start are dropped. First-fit: when the running width exceeds the measure, break at the last legal breakpoint. Return [[line width, break kind]] with kinds glue/penalty/forced/end.

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):
    items, width = x
    lines = []
    start = 0
    n = len(items)
    while start < n:
        while start < n and items[start][0] == 'g':
            start += 1
        if start >= n:
            break
        total = 0
        last = None
        result = None
        i = start
        while i < n:
            it = items[i]
            if it[0] == 'p':
                if it[2] <= -10000:
                    result = (i, total + it[1], 'forced')
                    break
                if it[2] < 10000:
                    last = (i, total + it[1], 'penalty')
            elif it[0] == 'g':
                if items[i - 1][0] == 'b':
                    last = (i, total, 'glue')
                total += it[1]
            else:
                total += it[1]
            if total > width and last is not None:
                result = last
                break
            i += 1
        if result is None:
            lines.append([total, 'end'])
            break
        lines.append([result[1], result[2]])
        start = result[0] + 1
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discardable items at line start', [[['b', 7], ['g', 1], ['g', 1], ['b', 7], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['g', 1], ['b', 2], ['g', 1], ['b', 7], ['g', 1], ['b', 7], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['g', 1], ['b', 3], ['g', 1], ['g', 1]], 6], [[7, 'glue'], [7, 'forced'], [5, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']]), ('regression: discardable items at line start', [[['b', 7], ['g', 2], ['b', 7], ['g', 1], ['b', 5], ['p', 0, 10000, False], ['g', 1], ['b', 6], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1]], 10], [[7, 'glue'], [7, 'glue'], [13, 'penalty']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 6], ['g', 1], ['g', 1], ['b', 6], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 1]], 6], [[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']]), ('partial-repair probe', [[['b', 6], ['g', 1], ['b', 6], ['g', 2], ['b', 2], ['g', 1], ['b', 3], ['g', 1], ['b', 5], ['g', 1], ['b', 2], ['p', 0, 900, False], ['g', 2], ['b', 6], ['g', 2], ['b', 2], ['g', 2], ['b', 1], ['p', 0, 10000, False], ['g', 1]], 6], [[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 1], ['g', 2], ['b', 3], ['g', 1], ['b', 7], ['g', 2], ['b', 7], ['g', 2], ['b', 4], ['p', 0, 10000, False], ['g', 1], ['g', 1], ['b', 3], ['g', 2], ['b', 6], ['g', 2]], 15], [[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']]), ('control layout', [[['b', 2], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 2], ['b', 4], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 2], ['g', 2], ['b', 7], ['g', 2]], 7], [[7, 'glue'], [7, 'glue'], [7, 'glue']])], [('regression: discardable items at line start', [[['b', 1], ['g', 1], ['b', 7], ['g', 2], ['b', 3], ['g', 1], ['b', 7], ['g', 2], ['b', 2], ['p', 0, -10000, False], ['g', 1], ['b', 4], ['p', 0, 10000, False], ['g', 2], ['b', 1], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 6], ['g', 2], ['b', 5], ['p', 0, 10000, False], ['g', 1]], 6], [[1, 'glue'], [7, 'glue'], [3, 'glue'], [7, 'glue'], [2, 'forced'], [8, 'penalty'], [6, 'glue'], [6, 'end']]), ('regression: discardable items at line start', [[['b', 4], ['g', 1], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 2], ['b', 7], ['g', 1], ['b', 4], ['g', 1], ['b', 1], ['g', 2], ['b', 3], ['g', 1]], 18], [[9, 'forced'], [13, 'penalty'], [14, 'glue'], [4, 'end']]), ('partial-repair probe', [[['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 0, 9999, False], ['g', 2], ['b', 4], ['g', 1], ['g', 1], ['b', 1], ['g', 1], ['b', 3], ['g', 1]], 13], [[13, 'glue'], [6, 'end']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 1], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 0, -10000, False], ['g', 2], ['b', 7], ['p', 1, 50, True], ['g', 1], ['g', 1]], 17], [[9, 'forced'], [9, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 3], ['p', 1, 50, True], ['g', 2], ['b', 5], ['g', 1], ['b', 2], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1], ['b', 7], ['g', 1], ['b', 3], ['g', 1], ['b', 2], ['g', 1], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 2]], 16], [[13, 'glue'], [14, 'glue'], [7, 'end']]), ('control layout', [[['b', 6], ['g', 1], ['b', 7], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['g', 1], ['b', 3], ['g', 2]], 6], [[6, 'glue'], [7, 'glue'], [6, 'glue'], [3, 'glue'], [5, 'end']])], [('regression: discardable items at line start', [[['b', 7], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 2], ['b', 1], ['p', 0, 900, False], ['g', 1], ['b', 1], ['g', 1], ['g', 1], ['b', 7], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1]], 9], [[10, 'penalty'], [3, 'glue'], [7, 'forced'], [6, 'penalty'], [7, 'glue'], [4, 'end']]), ('regression: discardable items at line start', [[['b', 1], ['p', 0, 10000, False], ['g', 1], ['b', 3], ['g', 2], ['b', 7], ['g', 1], ['b', 7], ['g', 2], ['b', 4], ['p', 1, 50, True], ['g', 2], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 3], ['g', 2]], 12], [[5, 'glue'], [7, 'glue'], [7, 'glue'], [10, 'forced'], [5, 'end']]), ('partial-repair probe', [[['b', 4], ['g', 1], ['b', 1], ['g', 1], ['b', 1], ['g', 1], ['b', 1], ['p', 0, -10000, False], ['g', 1], ['g', 1], ['b', 6], ['p', 1, 50, True], ['g', 2]], 16], [[10, 'forced'], [8, 'end']]), ('partial-repair probe', [[['b', 7], ['g', 2], ['b', 3], ['g', 2], ['b', 3], ['g', 1], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['g', 1], ['b', 3], ['g', 2]], 6], [[7, 'glue'], [3, 'glue'], [3, 'glue'], [8, 'penalty'], [7, 'glue'], [5, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 1], ['p', 0, 10000, False], ['g', 1], ['b', 3], ['g', 1], ['b', 2], ['g', 1], ['b', 4], ['g', 2]], 15], [[15, 'end']]), ('control layout', [[['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 5], ['g', 1], ['b', 4], ['p', 1, 50, True], ['g', 2], ['b', 5], ['g', 1], ['g', 1], ['b', 1], ['g', 2], ['b', 4], ['p', 0, 10000, False], ['g', 1]], 17], [[13, 'glue'], [14, 'glue'], [5, 'end']])], [('regression: discardable items at line start', [[['b', 4], ['g', 1], ['g', 1], ['b', 5], ['g', 2], ['b', 6], ['p', 0, 10000, False], ['g', 2], ['b', 3], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['g', 1], ['b', 1], ['g', 2], ['b', 7], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 1], ['b', 5], ['g', 1]], 6], [[4, 'glue'], [5, 'glue'], [12, 'penalty'], [7, 'glue'], [1, 'glue'], [8, 'penalty'], [4, 'glue'], [6, 'end']]), ('regression: discardable items at line start', [[['b', 3], ['g', 2], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 1], ['g', 2], ['b', 3], ['g', 2], ['b', 6], ['g', 2], ['b', 2], ['p', 1, 50, True], ['g', 1]], 8], [[3, 'glue'], [4, 'forced'], [6, 'glue'], [6, 'glue'], [3, 'end']]), ('partial-repair probe', [[['b', 5], ['p', 1, 50, True], ['g', 2], ['b', 3], ['g', 1], ['b', 2], ['g', 2], ['b', 5], ['g', 1], ['b', 2], ['g', 2], ['b', 7], ['g', 1], ['g', 1]], 17], [[13, 'glue'], [17, 'glue']]), ('partial-repair probe', [[['b', 2], ['g', 1], ['b', 4], ['p', 0, 900, False], ['g', 2], ['b', 6], ['g', 2], ['b', 1], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['p', 0, 10000, False], ['g', 1], ['b', 4], ['g', 1], ['g', 1], ['b', 7], ['g', 1]], 8], [[7, 'penalty'], [6, 'glue'], [8, 'glue'], [8, 'glue'], [8, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 5], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1], ['b', 5], ['g', 1], ['b', 3], ['g', 2]], 15], [[14, 'glue'], [5, 'end']]), ('control layout', [[['b', 1], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 2], ['b', 2], ['p', 1, 50, True], ['g', 1]], 15], [[15, 'end']])], [('regression: discardable items at line start', [[['b', 4], ['g', 1], ['g', 1], ['b', 5], ['g', 1], ['b', 3], ['g', 2], ['b', 1], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['p', 1, 50, True], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1]], 14], [[11, 'glue'], [6, 'forced'], [14, 'end']]), ('regression: discardable items at line start', [[['b', 7], ['g', 2], ['b', 7], ['g', 1], ['b', 5], ['p', 0, 10000, False], ['g', 1], ['b', 6], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1]], 10], [[7, 'glue'], [7, 'glue'], [13, 'penalty']]), ('partial-repair probe', [[['b', 1], ['p', 0, -10000, False], ['g', 1], ['b', 6], ['p', 0, 9999, False], ['p', 1, 50, True], ['g', 1], ['b', 2], ['p', 1, 50, True], ['g', 2], ['b', 1], ['g', 1]], 6], [[1, 'forced'], [7, 'penalty'], [6, 'end']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 6], ['p', 0, 10000, False], ['g', 1], ['b', 1], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 4], ['p', 1, 50, True], ['g', 1], ['b', 3], ['g', 1], ['b', 1], ['g', 1], ['b', 4], ['p', 0, 10000, False], ['g', 1], ['b', 5], ['g', 2]], 12], [[13, 'penalty'], [10, 'glue'], [12, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('control layout', [[['b', 4], ['g', 2], ['b', 6], ['g', 1], ['b', 6], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1]], 14], [[12, 'glue'], [10, 'end']]), ('control layout', [[['b', 4], ['g', 2], ['b', 7], ['g', 1], ['b', 3], ['g', 2], ['b', 2], ['g', 2], ['b', 6], ['g', 2], ['b', 4], ['g', 2], ['b', 2], ['g', 1], ['b', 4], ['g', 1]], 10], [[4, 'glue'], [7, 'glue'], [7, 'glue'], [6, 'glue'], [8, 'glue'], [5, 'end']])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: discardable items at line start[[7, 'glue'], [7, 'forced'], [6, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']][[7, 'glue'], [7, 'forced'], [5, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']]Failed
regression: discardable items at line start[[7, 'glue'], [7, 'glue'], [13, 'penalty'], [1, 'end']][[7, 'glue'], [7, 'glue'], [13, 'penalty']]Failed
partial-repair probe[[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']][[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']]Passed
partial-repair probe[[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']][[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']]Passed
hyphen penalty taken[[6, 'penalty'], [4, 'glue'], [3, 'end']][[6, 'penalty'], [4, 'glue'], [3, 'end']]Passed
forced break[[5, 'forced'], [3, 'end']][[5, 'forced'], [3, 'end']]Passed
control layout[[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']][[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']]Passed
control layout[[7, 'glue'], [7, 'glue'], [7, 'glue']][[7, 'glue'], [7, 'glue'], [7, 'glue']]Passed

SHA-256 / b6e211d4d5ee771957154e8054ee121fd19d518cca229c062431ceb7b2d1c2ac

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    items, width = x
    lines = []
    start = 0
    n = len(items)
    while start < n:
        while start < n and items[start][0] == 'p':
            start += 1
        if start >= n:
            break
        total = 0
        last = None
        result = None
        i = start
        while i < n:
            it = items[i]
            if it[0] == 'p':
                if it[2] <= -10000:
                    result = (i, total + it[1], 'forced')
                    break
                if it[2] < 10000:
                    last = (i, total + it[1], 'penalty')
            elif it[0] == 'g':
                if items[i - 1][0] == 'b':
                    last = (i, total, 'glue')
                total += it[1]
            else:
                total += it[1]
            if total > width and last is not None:
                result = last
                break
            i += 1
        if result is None:
            lines.append([total, 'end'])
            break
        lines.append([result[1], result[2]])
        start = result[0] + 1
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discardable items at line start', [[['b', 7], ['g', 1], ['g', 1], ['b', 7], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['g', 1], ['b', 2], ['g', 1], ['b', 7], ['g', 1], ['b', 7], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['g', 1], ['b', 3], ['g', 1], ['g', 1]], 6], [[7, 'glue'], [7, 'forced'], [5, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']]), ('regression: discardable items at line start', [[['b', 7], ['g', 2], ['b', 7], ['g', 1], ['b', 5], ['p', 0, 10000, False], ['g', 1], ['b', 6], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1]], 10], [[7, 'glue'], [7, 'glue'], [13, 'penalty']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 6], ['g', 1], ['g', 1], ['b', 6], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 1]], 6], [[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']]), ('partial-repair probe', [[['b', 6], ['g', 1], ['b', 6], ['g', 2], ['b', 2], ['g', 1], ['b', 3], ['g', 1], ['b', 5], ['g', 1], ['b', 2], ['p', 0, 900, False], ['g', 2], ['b', 6], ['g', 2], ['b', 2], ['g', 2], ['b', 1], ['p', 0, 10000, False], ['g', 1]], 6], [[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 1], ['g', 2], ['b', 3], ['g', 1], ['b', 7], ['g', 2], ['b', 7], ['g', 2], ['b', 4], ['p', 0, 10000, False], ['g', 1], ['g', 1], ['b', 3], ['g', 2], ['b', 6], ['g', 2]], 15], [[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']]), ('control layout', [[['b', 2], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 2], ['b', 4], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 2], ['g', 2], ['b', 7], ['g', 2]], 7], [[7, 'glue'], [7, 'glue'], [7, 'glue']])], [('regression: discardable items at line start', [[['b', 1], ['g', 1], ['b', 7], ['g', 2], ['b', 3], ['g', 1], ['b', 7], ['g', 2], ['b', 2], ['p', 0, -10000, False], ['g', 1], ['b', 4], ['p', 0, 10000, False], ['g', 2], ['b', 1], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 6], ['g', 2], ['b', 5], ['p', 0, 10000, False], ['g', 1]], 6], [[1, 'glue'], [7, 'glue'], [3, 'glue'], [7, 'glue'], [2, 'forced'], [8, 'penalty'], [6, 'glue'], [6, 'end']]), ('regression: discardable items at line start', [[['b', 4], ['g', 1], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 2], ['b', 7], ['g', 1], ['b', 4], ['g', 1], ['b', 1], ['g', 2], ['b', 3], ['g', 1]], 18], [[9, 'forced'], [13, 'penalty'], [14, 'glue'], [4, 'end']]), ('partial-repair probe', [[['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 0, 9999, False], ['g', 2], ['b', 4], ['g', 1], ['g', 1], ['b', 1], ['g', 1], ['b', 3], ['g', 1]], 13], [[13, 'glue'], [6, 'end']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 1], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 0, -10000, False], ['g', 2], ['b', 7], ['p', 1, 50, True], ['g', 1], ['g', 1]], 17], [[9, 'forced'], [9, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 3], ['p', 1, 50, True], ['g', 2], ['b', 5], ['g', 1], ['b', 2], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1], ['b', 7], ['g', 1], ['b', 3], ['g', 1], ['b', 2], ['g', 1], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 2]], 16], [[13, 'glue'], [14, 'glue'], [7, 'end']]), ('control layout', [[['b', 6], ['g', 1], ['b', 7], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['g', 1], ['b', 3], ['g', 2]], 6], [[6, 'glue'], [7, 'glue'], [6, 'glue'], [3, 'glue'], [5, 'end']])], [('regression: discardable items at line start', [[['b', 7], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 2], ['b', 1], ['p', 0, 900, False], ['g', 1], ['b', 1], ['g', 1], ['g', 1], ['b', 7], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1]], 9], [[10, 'penalty'], [3, 'glue'], [7, 'forced'], [6, 'penalty'], [7, 'glue'], [4, 'end']]), ('regression: discardable items at line start', [[['b', 1], ['p', 0, 10000, False], ['g', 1], ['b', 3], ['g', 2], ['b', 7], ['g', 1], ['b', 7], ['g', 2], ['b', 4], ['p', 1, 50, True], ['g', 2], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 3], ['g', 2]], 12], [[5, 'glue'], [7, 'glue'], [7, 'glue'], [10, 'forced'], [5, 'end']]), ('partial-repair probe', [[['b', 4], ['g', 1], ['b', 1], ['g', 1], ['b', 1], ['g', 1], ['b', 1], ['p', 0, -10000, False], ['g', 1], ['g', 1], ['b', 6], ['p', 1, 50, True], ['g', 2]], 16], [[10, 'forced'], [8, 'end']]), ('partial-repair probe', [[['b', 7], ['g', 2], ['b', 3], ['g', 2], ['b', 3], ['g', 1], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['g', 1], ['b', 3], ['g', 2]], 6], [[7, 'glue'], [3, 'glue'], [3, 'glue'], [8, 'penalty'], [7, 'glue'], [5, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 1], ['p', 0, 10000, False], ['g', 1], ['b', 3], ['g', 1], ['b', 2], ['g', 1], ['b', 4], ['g', 2]], 15], [[15, 'end']]), ('control layout', [[['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 5], ['g', 1], ['b', 4], ['p', 1, 50, True], ['g', 2], ['b', 5], ['g', 1], ['g', 1], ['b', 1], ['g', 2], ['b', 4], ['p', 0, 10000, False], ['g', 1]], 17], [[13, 'glue'], [14, 'glue'], [5, 'end']])], [('regression: discardable items at line start', [[['b', 4], ['g', 1], ['g', 1], ['b', 5], ['g', 2], ['b', 6], ['p', 0, 10000, False], ['g', 2], ['b', 3], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['g', 1], ['b', 1], ['g', 2], ['b', 7], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 1], ['b', 5], ['g', 1]], 6], [[4, 'glue'], [5, 'glue'], [12, 'penalty'], [7, 'glue'], [1, 'glue'], [8, 'penalty'], [4, 'glue'], [6, 'end']]), ('regression: discardable items at line start', [[['b', 3], ['g', 2], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 1], ['g', 2], ['b', 3], ['g', 2], ['b', 6], ['g', 2], ['b', 2], ['p', 1, 50, True], ['g', 1]], 8], [[3, 'glue'], [4, 'forced'], [6, 'glue'], [6, 'glue'], [3, 'end']]), ('partial-repair probe', [[['b', 5], ['p', 1, 50, True], ['g', 2], ['b', 3], ['g', 1], ['b', 2], ['g', 2], ['b', 5], ['g', 1], ['b', 2], ['g', 2], ['b', 7], ['g', 1], ['g', 1]], 17], [[13, 'glue'], [17, 'glue']]), ('partial-repair probe', [[['b', 2], ['g', 1], ['b', 4], ['p', 0, 900, False], ['g', 2], ['b', 6], ['g', 2], ['b', 1], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['p', 0, 10000, False], ['g', 1], ['b', 4], ['g', 1], ['g', 1], ['b', 7], ['g', 1]], 8], [[7, 'penalty'], [6, 'glue'], [8, 'glue'], [8, 'glue'], [8, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 5], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1], ['b', 5], ['g', 1], ['b', 3], ['g', 2]], 15], [[14, 'glue'], [5, 'end']]), ('control layout', [[['b', 1], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 2], ['b', 2], ['p', 1, 50, True], ['g', 1]], 15], [[15, 'end']])], [('regression: discardable items at line start', [[['b', 4], ['g', 1], ['g', 1], ['b', 5], ['g', 1], ['b', 3], ['g', 2], ['b', 1], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['p', 1, 50, True], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1]], 14], [[11, 'glue'], [6, 'forced'], [14, 'end']]), ('regression: discardable items at line start', [[['b', 7], ['g', 2], ['b', 7], ['g', 1], ['b', 5], ['p', 0, 10000, False], ['g', 1], ['b', 6], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1]], 10], [[7, 'glue'], [7, 'glue'], [13, 'penalty']]), ('partial-repair probe', [[['b', 1], ['p', 0, -10000, False], ['g', 1], ['b', 6], ['p', 0, 9999, False], ['p', 1, 50, True], ['g', 1], ['b', 2], ['p', 1, 50, True], ['g', 2], ['b', 1], ['g', 1]], 6], [[1, 'forced'], [7, 'penalty'], [6, 'end']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 6], ['p', 0, 10000, False], ['g', 1], ['b', 1], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 4], ['p', 1, 50, True], ['g', 1], ['b', 3], ['g', 1], ['b', 1], ['g', 1], ['b', 4], ['p', 0, 10000, False], ['g', 1], ['b', 5], ['g', 2]], 12], [[13, 'penalty'], [10, 'glue'], [12, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('control layout', [[['b', 4], ['g', 2], ['b', 6], ['g', 1], ['b', 6], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1]], 14], [[12, 'glue'], [10, 'end']]), ('control layout', [[['b', 4], ['g', 2], ['b', 7], ['g', 1], ['b', 3], ['g', 2], ['b', 2], ['g', 2], ['b', 6], ['g', 2], ['b', 4], ['g', 2], ['b', 2], ['g', 1], ['b', 4], ['g', 1]], 10], [[4, 'glue'], [7, 'glue'], [7, 'glue'], [6, 'glue'], [8, 'glue'], [5, 'end']])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: discardable items at line start[[7, 'glue'], [8, 'forced'], [6, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [7, 'glue'], [3, 'glue'], [5, 'end']][[7, 'glue'], [7, 'forced'], [5, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']]Failed
regression: discardable items at line start[[7, 'glue'], [7, 'glue'], [13, 'penalty'], [1, 'end']][[7, 'glue'], [7, 'glue'], [13, 'penalty']]Failed
partial-repair probe[[2, 'glue'], [6, 'glue'], [8, 'penalty'], [5, 'penalty'], [9, 'penalty'], [3, 'end']][[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']]Failed
partial-repair probe[[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [8, 'glue'], [6, 'end']][[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']]Failed
hyphen penalty taken[[6, 'penalty'], [4, 'glue'], [3, 'end']][[6, 'penalty'], [4, 'glue'], [3, 'end']]Passed
forced break[[5, 'forced'], [3, 'end']][[5, 'forced'], [3, 'end']]Passed
control layout[[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']][[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']]Passed
control layout[[7, 'glue'], [7, 'glue'], [7, 'glue']][[7, 'glue'], [7, 'glue'], [7, 'glue']]Passed

SHA-256 / f6f0c4f3db897ae72daedd008a4f16abbbb6eaedaf8740952365438507abf4fa

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    items, width = x
    lines = []
    start = 0
    n = len(items)
    while start < n:
        while start < n and items[start][0] != 'b':
            start += 1
        if start >= n:
            break
        total = 0
        last = None
        result = None
        i = start
        while i < n:
            it = items[i]
            if it[0] == 'p':
                if it[2] <= -10000:
                    result = (i, total + it[1], 'forced')
                    break
                if it[2] < 10000:
                    last = (i, total + it[1], 'penalty')
            elif it[0] == 'g':
                if items[i - 1][0] == 'b':
                    last = (i, total, 'glue')
                total += it[1]
            else:
                total += it[1]
            if total > width and last is not None:
                result = last
                break
            i += 1
        if result is None:
            lines.append([total, 'end'])
            break
        lines.append([result[1], result[2]])
        start = result[0] + 1
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discardable items at line start', [[['b', 7], ['g', 1], ['g', 1], ['b', 7], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['g', 1], ['b', 2], ['g', 1], ['b', 7], ['g', 1], ['b', 7], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['g', 1], ['b', 3], ['g', 1], ['g', 1]], 6], [[7, 'glue'], [7, 'forced'], [5, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']]), ('regression: discardable items at line start', [[['b', 7], ['g', 2], ['b', 7], ['g', 1], ['b', 5], ['p', 0, 10000, False], ['g', 1], ['b', 6], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1]], 10], [[7, 'glue'], [7, 'glue'], [13, 'penalty']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 6], ['g', 1], ['g', 1], ['b', 6], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 1]], 6], [[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']]), ('partial-repair probe', [[['b', 6], ['g', 1], ['b', 6], ['g', 2], ['b', 2], ['g', 1], ['b', 3], ['g', 1], ['b', 5], ['g', 1], ['b', 2], ['p', 0, 900, False], ['g', 2], ['b', 6], ['g', 2], ['b', 2], ['g', 2], ['b', 1], ['p', 0, 10000, False], ['g', 1]], 6], [[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 1], ['g', 2], ['b', 3], ['g', 1], ['b', 7], ['g', 2], ['b', 7], ['g', 2], ['b', 4], ['p', 0, 10000, False], ['g', 1], ['g', 1], ['b', 3], ['g', 2], ['b', 6], ['g', 2]], 15], [[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']]), ('control layout', [[['b', 2], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 2], ['b', 4], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 2], ['g', 2], ['b', 7], ['g', 2]], 7], [[7, 'glue'], [7, 'glue'], [7, 'glue']])], [('regression: discardable items at line start', [[['b', 1], ['g', 1], ['b', 7], ['g', 2], ['b', 3], ['g', 1], ['b', 7], ['g', 2], ['b', 2], ['p', 0, -10000, False], ['g', 1], ['b', 4], ['p', 0, 10000, False], ['g', 2], ['b', 1], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 6], ['g', 2], ['b', 5], ['p', 0, 10000, False], ['g', 1]], 6], [[1, 'glue'], [7, 'glue'], [3, 'glue'], [7, 'glue'], [2, 'forced'], [8, 'penalty'], [6, 'glue'], [6, 'end']]), ('regression: discardable items at line start', [[['b', 4], ['g', 1], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 2], ['b', 7], ['g', 1], ['b', 4], ['g', 1], ['b', 1], ['g', 2], ['b', 3], ['g', 1]], 18], [[9, 'forced'], [13, 'penalty'], [14, 'glue'], [4, 'end']]), ('partial-repair probe', [[['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 0, 9999, False], ['g', 2], ['b', 4], ['g', 1], ['g', 1], ['b', 1], ['g', 1], ['b', 3], ['g', 1]], 13], [[13, 'glue'], [6, 'end']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 1], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 0, -10000, False], ['g', 2], ['b', 7], ['p', 1, 50, True], ['g', 1], ['g', 1]], 17], [[9, 'forced'], [9, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 3], ['p', 1, 50, True], ['g', 2], ['b', 5], ['g', 1], ['b', 2], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1], ['b', 7], ['g', 1], ['b', 3], ['g', 1], ['b', 2], ['g', 1], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 2]], 16], [[13, 'glue'], [14, 'glue'], [7, 'end']]), ('control layout', [[['b', 6], ['g', 1], ['b', 7], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['g', 1], ['b', 3], ['g', 2]], 6], [[6, 'glue'], [7, 'glue'], [6, 'glue'], [3, 'glue'], [5, 'end']])], [('regression: discardable items at line start', [[['b', 7], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 1], ['p', 1, 50, True], ['g', 2], ['b', 1], ['p', 0, 900, False], ['g', 1], ['b', 1], ['g', 1], ['g', 1], ['b', 7], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1]], 9], [[10, 'penalty'], [3, 'glue'], [7, 'forced'], [6, 'penalty'], [7, 'glue'], [4, 'end']]), ('regression: discardable items at line start', [[['b', 1], ['p', 0, 10000, False], ['g', 1], ['b', 3], ['g', 2], ['b', 7], ['g', 1], ['b', 7], ['g', 2], ['b', 4], ['p', 1, 50, True], ['g', 2], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 3], ['g', 2]], 12], [[5, 'glue'], [7, 'glue'], [7, 'glue'], [10, 'forced'], [5, 'end']]), ('partial-repair probe', [[['b', 4], ['g', 1], ['b', 1], ['g', 1], ['b', 1], ['g', 1], ['b', 1], ['p', 0, -10000, False], ['g', 1], ['g', 1], ['b', 6], ['p', 1, 50, True], ['g', 2]], 16], [[10, 'forced'], [8, 'end']]), ('partial-repair probe', [[['b', 7], ['g', 2], ['b', 3], ['g', 2], ['b', 3], ['g', 1], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['g', 1], ['b', 3], ['g', 2]], 6], [[7, 'glue'], [3, 'glue'], [3, 'glue'], [8, 'penalty'], [7, 'glue'], [5, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 1], ['p', 0, 10000, False], ['g', 1], ['b', 3], ['g', 1], ['b', 2], ['g', 1], ['b', 4], ['g', 2]], 15], [[15, 'end']]), ('control layout', [[['b', 7], ['p', 1, 50, True], ['g', 1], ['b', 5], ['g', 1], ['b', 4], ['p', 1, 50, True], ['g', 2], ['b', 5], ['g', 1], ['g', 1], ['b', 1], ['g', 2], ['b', 4], ['p', 0, 10000, False], ['g', 1]], 17], [[13, 'glue'], [14, 'glue'], [5, 'end']])], [('regression: discardable items at line start', [[['b', 4], ['g', 1], ['g', 1], ['b', 5], ['g', 2], ['b', 6], ['p', 0, 10000, False], ['g', 2], ['b', 3], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 7], ['g', 1], ['g', 1], ['b', 1], ['g', 2], ['b', 7], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 1], ['b', 5], ['g', 1]], 6], [[4, 'glue'], [5, 'glue'], [12, 'penalty'], [7, 'glue'], [1, 'glue'], [8, 'penalty'], [4, 'glue'], [6, 'end']]), ('regression: discardable items at line start', [[['b', 3], ['g', 2], ['b', 4], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 1], ['g', 2], ['b', 3], ['g', 2], ['b', 6], ['g', 2], ['b', 2], ['p', 1, 50, True], ['g', 1]], 8], [[3, 'glue'], [4, 'forced'], [6, 'glue'], [6, 'glue'], [3, 'end']]), ('partial-repair probe', [[['b', 5], ['p', 1, 50, True], ['g', 2], ['b', 3], ['g', 1], ['b', 2], ['g', 2], ['b', 5], ['g', 1], ['b', 2], ['g', 2], ['b', 7], ['g', 1], ['g', 1]], 17], [[13, 'glue'], [17, 'glue']]), ('partial-repair probe', [[['b', 2], ['g', 1], ['b', 4], ['p', 0, 900, False], ['g', 2], ['b', 6], ['g', 2], ['b', 1], ['g', 1], ['b', 6], ['g', 2], ['b', 3], ['p', 0, 10000, False], ['g', 1], ['b', 4], ['g', 1], ['g', 1], ['b', 7], ['g', 1]], 8], [[7, 'penalty'], [6, 'glue'], [8, 'glue'], [8, 'glue'], [8, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('forced break', [[['b', 2], ['g', 1], ['b', 2], ['p', 0, -10000, False], ['b', 3]], 20], [[5, 'forced'], [3, 'end']]), ('control layout', [[['b', 5], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1], ['b', 5], ['g', 1], ['b', 3], ['g', 2]], 15], [[14, 'glue'], [5, 'end']]), ('control layout', [[['b', 1], ['p', 1, 50, True], ['g', 1], ['b', 3], ['p', 1, 50, True], ['g', 1], ['b', 4], ['g', 2], ['b', 2], ['p', 1, 50, True], ['g', 1]], 15], [[15, 'end']])], [('regression: discardable items at line start', [[['b', 4], ['g', 1], ['g', 1], ['b', 5], ['g', 1], ['b', 3], ['g', 2], ['b', 1], ['p', 0, -10000, False], ['p', 1, 50, True], ['g', 1], ['b', 5], ['p', 1, 50, True], ['g', 1], ['b', 7], ['p', 1, 50, True], ['g', 1]], 14], [[11, 'glue'], [6, 'forced'], [14, 'end']]), ('regression: discardable items at line start', [[['b', 7], ['g', 2], ['b', 7], ['g', 1], ['b', 5], ['p', 0, 10000, False], ['g', 1], ['b', 6], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1]], 10], [[7, 'glue'], [7, 'glue'], [13, 'penalty']]), ('partial-repair probe', [[['b', 1], ['p', 0, -10000, False], ['g', 1], ['b', 6], ['p', 0, 9999, False], ['p', 1, 50, True], ['g', 1], ['b', 2], ['p', 1, 50, True], ['g', 2], ['b', 1], ['g', 1]], 6], [[1, 'forced'], [7, 'penalty'], [6, 'end']]), ('partial-repair probe', [[['b', 2], ['g', 2], ['b', 6], ['p', 0, 10000, False], ['g', 1], ['b', 1], ['p', 1, 50, True], ['p', 1, 50, True], ['g', 1], ['b', 4], ['p', 1, 50, True], ['g', 1], ['b', 3], ['g', 1], ['b', 1], ['g', 1], ['b', 4], ['p', 0, 10000, False], ['g', 1], ['b', 5], ['g', 2]], 12], [[13, 'penalty'], [10, 'glue'], [12, 'end']]), ('inhibited penalty', [[['b', 5], ['p', 0, 10000, False], ['b', 4], ['g', 1], ['b', 3]], 7], [[9, 'glue'], [3, 'end']]), ('hyphen penalty taken', [[['b', 5], ['p', 1, 50, True], ['b', 4], ['g', 1], ['b', 3]], 7], [[6, 'penalty'], [4, 'glue'], [3, 'end']]), ('control layout', [[['b', 4], ['g', 2], ['b', 6], ['g', 1], ['b', 6], ['g', 1], ['b', 2], ['p', 0, 10000, False], ['g', 1]], 14], [[12, 'glue'], [10, 'end']]), ('control layout', [[['b', 4], ['g', 2], ['b', 7], ['g', 1], ['b', 3], ['g', 2], ['b', 2], ['g', 2], ['b', 6], ['g', 2], ['b', 4], ['g', 2], ['b', 2], ['g', 1], ['b', 4], ['g', 1]], 10], [[4, 'glue'], [7, 'glue'], [7, 'glue'], [6, 'glue'], [8, 'glue'], [5, 'end']])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: discardable items at line start[[7, 'glue'], [7, 'forced'], [5, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']][[7, 'glue'], [7, 'forced'], [5, 'glue'], [2, 'glue'], [7, 'glue'], [7, 'glue'], [8, 'penalty'], [6, 'glue'], [3, 'glue'], [5, 'end']]Passed
regression: discardable items at line start[[7, 'glue'], [7, 'glue'], [13, 'penalty']][[7, 'glue'], [7, 'glue'], [13, 'penalty']]Passed
partial-repair probe[[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']][[2, 'glue'], [6, 'glue'], [7, 'penalty'], [4, 'penalty'], [8, 'penalty'], [2, 'end']]Passed
partial-repair probe[[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']][[6, 'glue'], [6, 'glue'], [6, 'glue'], [5, 'glue'], [2, 'penalty'], [6, 'glue'], [6, 'end']]Passed
hyphen penalty taken[[6, 'penalty'], [4, 'glue'], [3, 'end']][[6, 'penalty'], [4, 'glue'], [3, 'end']]Passed
forced break[[5, 'forced'], [3, 'end']][[5, 'forced'], [3, 'end']]Passed
control layout[[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']][[14, 'glue'], [7, 'glue'], [9, 'glue'], [8, 'end']]Passed
control layout[[7, 'glue'], [7, 'glue'], [7, 'glue']][[7, 'glue'], [7, 'glue'], [7, 'glue']]Passed

SHA-256 / 9744d5cf959122298dde5fe54eaa60de0a14f8bc25e5040bbe4e68275e6b81e4

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

Case digest / 74bb09aaf936aecf65ff71f1da04fe68eea134be5b54f2f7b5e4c88b9082f6d3