FA-97596 / Knitting and sewing pattern grading / Open access
Quilt binding strip planner: selvage trim both edges · case 01
Binding comes up short because only one selvage was trimmed in the plan.
ROOT CAUSE
Only one selvage is removed from the strip length.
VERIFIED REPAIR
Trim a selvage from each end.
Unsuccessful approach: An extra centimetre of trim is not in the contract and over-cuts.
Case contract
Usable strip length = fabric_width - 2*selvage. Joining n strips with diagonal seams loses strip_width per join (n-1 joins). Need perimeter + tail. n is the smallest count with n*usable - (n-1)*strip_width >= need. Return [n, fabric cut length n*strip_width, surplus]; usable <= strip_width -> "error: fabric too narrow".
Why this case matters
Quilters cut width-of-fabric strips and join them diagonally to bind the quilt edge.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(perimeter, strip_width, fabric_width, selvage, tail):
usable = fabric_width - selvage
if usable <= strip_width:
return 'error: fabric too narrow'
need = perimeter + tail
def length(n):
return n * usable - (n - 1) * strip_width
n = 1
while length(n) < need:
n += 1
return [n, n * strip_width, length(n) - need]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['regression: selvage trim both edges', [420, 5, 107, 1, 0], [5, 25, 85]],
['repair check: selvage trim both edges', [420, 6, 150, 2, 30], [4, 24, 116]],
['generated control 1', [600, 5, 140, 2, 0], [5, 25, 60]],
['generated control 2', [200, 6.5, 110, 0, 20], [3, 19.5, 97.0]],
['generated control 3', [420, 6, 150, 1, 30], [4, 24, 124]]],
[['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]],
['regression: selvage trim both edges', [420, 5, 107, 2, 20], [5, 25, 55]],
['repair check: selvage trim both edges', [200, 5, 107, 0, 0], [2, 10, 9]],
['generated control 1', [600, 6, 110, 1, 25], [7, 42, 95]],
['generated control 2', [420, 6, 110, 1, 30], [5, 30, 66]],
['generated control 3', [350, 6.5, 150, 2, 20], [3, 19.5, 55.0]]],
[['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['regression: selvage trim both edges', [150, 4, 110, 1, 20], [2, 8, 42]],
['repair check: selvage trim both edges', [200, 4, 150, 1, 25], [2, 8, 67]],
['generated control 1', [150, 6, 110, 1, 25], [2, 12, 35]],
['generated control 2', [600, 5, 107, 0, 25], [7, 35, 94]],
['generated control 3', [150, 6.5, 107, 2, 0], [2, 13.0, 49.5]]],
[['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['regression: selvage trim both edges', [150, 6, 107, 2, 25], [2, 12, 25]],
['repair check: selvage trim both edges', [420, 5, 110, 1, 25], [5, 25, 75]],
['generated control 1', [420, 6.5, 110, 2, 25], [5, 32.5, 59.0]],
['generated control 2', [200, 5, 140, 1, 30], [2, 10, 41]],
['generated control 3', [600, 6.5, 140, 1, 20], [5, 32.5, 44.0]]],
[['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]],
['regression: selvage trim both edges', [150, 6, 150, 1, 25], [2, 12, 115]],
['repair check: selvage trim both edges', [420, 4, 107, 1, 0], [5, 20, 89]],
['generated control 1', [280, 6.5, 150, 0, 30], [3, 19.5, 127.0]],
['generated control 2', [600, 4, 107, 2, 25], [7, 28, 72]],
['generated control 3', [350, 5, 107, 0, 30], [4, 20, 33]]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| baby quilt | [3, 18, 10] | [3, 18, 7] | Failed |
| two strips | [2, 12, 14] | [2, 12, 10] | Failed |
| narrow fabric | error: fabric too narrow | error: fabric too narrow | Passed |
| regression: selvage trim both edges | [5, 25, 90] | [5, 25, 85] | Failed |
| repair check: selvage trim both edges | [4, 24, 124] | [4, 24, 116] | Failed |
| generated control 1 | [5, 25, 70] | [5, 25, 60] | Failed |
| generated control 2 | [3, 19.5, 97.0] | [3, 19.5, 97.0] | Passed |
| generated control 3 | [4, 24, 128] | [4, 24, 124] | Failed |
SHA-256 / 81ecb06c22b095ac38e322a471fa36bc170257d45a41f69d6aef0c44564a0887
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(perimeter, strip_width, fabric_width, selvage, tail):
usable = fabric_width - 2 * selvage - 1
if usable <= strip_width:
return 'error: fabric too narrow'
need = perimeter + tail
def length(n):
return n * usable - (n - 1) * strip_width
n = 1
while length(n) < need:
n += 1
return [n, n * strip_width, length(n) - need]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['regression: selvage trim both edges', [420, 5, 107, 1, 0], [5, 25, 85]],
['repair check: selvage trim both edges', [420, 6, 150, 2, 30], [4, 24, 116]],
['generated control 1', [600, 5, 140, 2, 0], [5, 25, 60]],
['generated control 2', [200, 6.5, 110, 0, 20], [3, 19.5, 97.0]],
['generated control 3', [420, 6, 150, 1, 30], [4, 24, 124]]],
[['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]],
['regression: selvage trim both edges', [420, 5, 107, 2, 20], [5, 25, 55]],
['repair check: selvage trim both edges', [200, 5, 107, 0, 0], [2, 10, 9]],
['generated control 1', [600, 6, 110, 1, 25], [7, 42, 95]],
['generated control 2', [420, 6, 110, 1, 30], [5, 30, 66]],
['generated control 3', [350, 6.5, 150, 2, 20], [3, 19.5, 55.0]]],
[['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['regression: selvage trim both edges', [150, 4, 110, 1, 20], [2, 8, 42]],
['repair check: selvage trim both edges', [200, 4, 150, 1, 25], [2, 8, 67]],
['generated control 1', [150, 6, 110, 1, 25], [2, 12, 35]],
['generated control 2', [600, 5, 107, 0, 25], [7, 35, 94]],
['generated control 3', [150, 6.5, 107, 2, 0], [2, 13.0, 49.5]]],
[['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['regression: selvage trim both edges', [150, 6, 107, 2, 25], [2, 12, 25]],
['repair check: selvage trim both edges', [420, 5, 110, 1, 25], [5, 25, 75]],
['generated control 1', [420, 6.5, 110, 2, 25], [5, 32.5, 59.0]],
['generated control 2', [200, 5, 140, 1, 30], [2, 10, 41]],
['generated control 3', [600, 6.5, 140, 1, 20], [5, 32.5, 44.0]]],
[['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]],
['regression: selvage trim both edges', [150, 6, 150, 1, 25], [2, 12, 115]],
['repair check: selvage trim both edges', [420, 4, 107, 1, 0], [5, 20, 89]],
['generated control 1', [280, 6.5, 150, 0, 30], [3, 19.5, 127.0]],
['generated control 2', [600, 4, 107, 2, 25], [7, 28, 72]],
['generated control 3', [350, 5, 107, 0, 30], [4, 20, 33]]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| baby quilt | [3, 18, 4] | [3, 18, 7] | Failed |
| two strips | [2, 12, 8] | [2, 12, 10] | Failed |
| narrow fabric | error: fabric too narrow | error: fabric too narrow | Passed |
| regression: selvage trim both edges | [5, 25, 80] | [5, 25, 85] | Failed |
| repair check: selvage trim both edges | [4, 24, 112] | [4, 24, 116] | Failed |
| generated control 1 | [5, 25, 55] | [5, 25, 60] | Failed |
| generated control 2 | [3, 19.5, 94.0] | [3, 19.5, 97.0] | Failed |
| generated control 3 | [4, 24, 120] | [4, 24, 124] | Failed |
SHA-256 / 392ecac85b7f339e93457f06f6f0c19f805da8a2698289da89a23391fb91301d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(perimeter, strip_width, fabric_width, selvage, tail):
usable = fabric_width - 2 * selvage
if usable <= strip_width:
return 'error: fabric too narrow'
need = perimeter + tail
def length(n):
return n * usable - (n - 1) * strip_width
n = 1
while length(n) < need:
n += 1
return [n, n * strip_width, length(n) - need]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['regression: selvage trim both edges', [420, 5, 107, 1, 0], [5, 25, 85]],
['repair check: selvage trim both edges', [420, 6, 150, 2, 30], [4, 24, 116]],
['generated control 1', [600, 5, 140, 2, 0], [5, 25, 60]],
['generated control 2', [200, 6.5, 110, 0, 20], [3, 19.5, 97.0]],
['generated control 3', [420, 6, 150, 1, 30], [4, 24, 124]]],
[['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]],
['regression: selvage trim both edges', [420, 5, 107, 2, 20], [5, 25, 55]],
['repair check: selvage trim both edges', [200, 5, 107, 0, 0], [2, 10, 9]],
['generated control 1', [600, 6, 110, 1, 25], [7, 42, 95]],
['generated control 2', [420, 6, 110, 1, 30], [5, 30, 66]],
['generated control 3', [350, 6.5, 150, 2, 20], [3, 19.5, 55.0]]],
[['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['regression: selvage trim both edges', [150, 4, 110, 1, 20], [2, 8, 42]],
['repair check: selvage trim both edges', [200, 4, 150, 1, 25], [2, 8, 67]],
['generated control 1', [150, 6, 110, 1, 25], [2, 12, 35]],
['generated control 2', [600, 5, 107, 0, 25], [7, 35, 94]],
['generated control 3', [150, 6.5, 107, 2, 0], [2, 13.0, 49.5]]],
[['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]], ['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['regression: selvage trim both edges', [150, 6, 107, 2, 25], [2, 12, 25]],
['repair check: selvage trim both edges', [420, 5, 110, 1, 25], [5, 25, 75]],
['generated control 1', [420, 6.5, 110, 2, 25], [5, 32.5, 59.0]],
['generated control 2', [200, 5, 140, 1, 30], [2, 10, 41]],
['generated control 3', [600, 6.5, 140, 1, 20], [5, 32.5, 44.0]]],
[['two strips', [196, 6, 110, 2, 0], [2, 12, 10]],
['narrow fabric', [100, 6, 6, 0, 0], 'error: fabric too narrow'],
['baby quilt', [280, 6, 110, 1, 25], [3, 18, 7]],
['regression: selvage trim both edges', [150, 6, 150, 1, 25], [2, 12, 115]],
['repair check: selvage trim both edges', [420, 4, 107, 1, 0], [5, 20, 89]],
['generated control 1', [280, 6.5, 150, 0, 30], [3, 19.5, 127.0]],
['generated control 2', [600, 4, 107, 2, 25], [7, 28, 72]],
['generated control 3', [350, 5, 107, 0, 30], [4, 20, 33]]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| baby quilt | [3, 18, 7] | [3, 18, 7] | Passed |
| two strips | [2, 12, 10] | [2, 12, 10] | Passed |
| narrow fabric | error: fabric too narrow | error: fabric too narrow | Passed |
| regression: selvage trim both edges | [5, 25, 85] | [5, 25, 85] | Passed |
| repair check: selvage trim both edges | [4, 24, 116] | [4, 24, 116] | Passed |
| generated control 1 | [5, 25, 60] | [5, 25, 60] | Passed |
| generated control 2 | [3, 19.5, 97.0] | [3, 19.5, 97.0] | Passed |
| generated control 3 | [4, 24, 124] | [4, 24, 124] | Passed |
SHA-256 / f3276aea5fb34168a7eba894c0c85724c04babc5d37fc776ee42f854ec34e6bb
Verification & scope
A deterministic toy contract stated in full here; it is a bounded teaching model, not an authoritative reference or standards implementation. 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:52:33.709188+00:00.
Case digest / 819618a09cc9838e2d5b012372a7fac9e14f6d74cf5d45501c7cd32a542d71b0