FA-97611 / Knitting and sewing pattern grading / Open access
Quilt binding strip planner: strip count loop · case 01
An exact fit plans one more strip than needed.
ROOT CAUSE
The loop continues on equality.
VERIFIED REPAIR
Stop as soon as the length meets the need.
Unsuccessful approach: Looking one strip ahead stops one strip early.
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 - 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: strip count loop', [280, 6.5, 110, 2, 25], [3, 19.5, 0.0]],
['repair check: strip count loop', [200, 6.5, 110, 1, 0], [2, 13.0, 9.5]],
['generated control 1', [150, 4, 150, 2, 20], [2, 8, 118]],
['generated control 2', [200, 6.5, 150, 2, 20], [2, 13.0, 65.5]],
['generated control 3', [350, 6.5, 140, 1, 20], [3, 19.5, 31.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: strip count loop', [420, 5, 150, 0, 20], [3, 15, 0]],
['repair check: strip count loop', [280, 6.5, 110, 1, 20], [3, 19.5, 11.0]],
['generated control 1', [280, 5, 110, 2, 25], [3, 15, 3]],
['generated control 2', [420, 6.5, 140, 1, 30], [4, 26.0, 82.5]],
['generated control 3', [420, 5, 110, 1, 30], [5, 25, 70]]],
[['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: strip count loop', [420, 5, 150, 0, 20], [3, 15, 0]],
['repair check: strip count loop', [350, 5, 110, 2, 20], [4, 20, 39]],
['generated control 1', [350, 5, 150, 0, 20], [3, 15, 70]],
['generated control 2', [200, 6.5, 107, 2, 0], [3, 19.5, 96.0]],
['generated control 3', [420, 6, 150, 0, 20], [4, 24, 142]]],
[['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: strip count loop', [280, 5, 107, 1, 25], [3, 15, 0]],
['repair check: strip count loop', [150, 6, 150, 0, 20], [2, 12, 124]],
['generated control 1', [200, 6.5, 110, 0, 20], [3, 19.5, 97.0]],
['generated control 2', [150, 4, 107, 2, 25], [2, 8, 27]],
['generated control 3', [600, 4, 150, 0, 0], [5, 20, 134]]],
[['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: strip count loop', [420, 4, 110, 1, 0], [4, 16, 0]],
['repair check: strip count loop', [600, 5, 110, 1, 0], [6, 30, 23]],
['generated control 1', [200, 6, 140, 1, 25], [2, 12, 45]],
['generated control 2', [200, 6, 150, 1, 25], [2, 12, 65]],
['generated control 3', [420, 5, 110, 2, 30], [5, 25, 60]]]]
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: strip count loop | [4, 26.0, 99.5] | [3, 19.5, 0.0] | Failed |
| repair check: strip count loop | [2, 13.0, 9.5] | [2, 13.0, 9.5] | Passed |
| generated control 1 | [2, 8, 118] | [2, 8, 118] | Passed |
| generated control 2 | [2, 13.0, 65.5] | [2, 13.0, 65.5] | Passed |
| generated control 3 | [3, 19.5, 31.0] | [3, 19.5, 31.0] | Passed |
SHA-256 / cd352e53bde2484f9bd893bfdb43266527a4646319f52639ca6bfb04726c881c
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
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 + 1) < 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: strip count loop', [280, 6.5, 110, 2, 25], [3, 19.5, 0.0]],
['repair check: strip count loop', [200, 6.5, 110, 1, 0], [2, 13.0, 9.5]],
['generated control 1', [150, 4, 150, 2, 20], [2, 8, 118]],
['generated control 2', [200, 6.5, 150, 2, 20], [2, 13.0, 65.5]],
['generated control 3', [350, 6.5, 140, 1, 20], [3, 19.5, 31.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: strip count loop', [420, 5, 150, 0, 20], [3, 15, 0]],
['repair check: strip count loop', [280, 6.5, 110, 1, 20], [3, 19.5, 11.0]],
['generated control 1', [280, 5, 110, 2, 25], [3, 15, 3]],
['generated control 2', [420, 6.5, 140, 1, 30], [4, 26.0, 82.5]],
['generated control 3', [420, 5, 110, 1, 30], [5, 25, 70]]],
[['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: strip count loop', [420, 5, 150, 0, 20], [3, 15, 0]],
['repair check: strip count loop', [350, 5, 110, 2, 20], [4, 20, 39]],
['generated control 1', [350, 5, 150, 0, 20], [3, 15, 70]],
['generated control 2', [200, 6.5, 107, 2, 0], [3, 19.5, 96.0]],
['generated control 3', [420, 6, 150, 0, 20], [4, 24, 142]]],
[['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: strip count loop', [280, 5, 107, 1, 25], [3, 15, 0]],
['repair check: strip count loop', [150, 6, 150, 0, 20], [2, 12, 124]],
['generated control 1', [200, 6.5, 110, 0, 20], [3, 19.5, 97.0]],
['generated control 2', [150, 4, 107, 2, 25], [2, 8, 27]],
['generated control 3', [600, 4, 150, 0, 0], [5, 20, 134]]],
[['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: strip count loop', [420, 4, 110, 1, 0], [4, 16, 0]],
['repair check: strip count loop', [600, 5, 110, 1, 0], [6, 30, 23]],
['generated control 1', [200, 6, 140, 1, 25], [2, 12, 45]],
['generated control 2', [200, 6, 150, 1, 25], [2, 12, 65]],
['generated control 3', [420, 5, 110, 2, 30], [5, 25, 60]]]]
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 | [2, 12, -95] | [3, 18, 7] | Failed |
| two strips | [1, 6, -90] | [2, 12, 10] | Failed |
| narrow fabric | error: fabric too narrow | error: fabric too narrow | Passed |
| regression: strip count loop | [2, 13.0, -99.5] | [3, 19.5, 0.0] | Failed |
| repair check: strip count loop | [1, 6.5, -92.0] | [2, 13.0, 9.5] | Failed |
| generated control 1 | [1, 4, -24] | [2, 8, 118] | Failed |
| generated control 2 | [1, 6.5, -74.0] | [2, 13.0, 65.5] | Failed |
| generated control 3 | [2, 13.0, -100.5] | [3, 19.5, 31.0] | Failed |
SHA-256 / ce20016f683336fd795a80209c29bee454eb333ec8674ecac84b1eb6794706c8
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: strip count loop', [280, 6.5, 110, 2, 25], [3, 19.5, 0.0]],
['repair check: strip count loop', [200, 6.5, 110, 1, 0], [2, 13.0, 9.5]],
['generated control 1', [150, 4, 150, 2, 20], [2, 8, 118]],
['generated control 2', [200, 6.5, 150, 2, 20], [2, 13.0, 65.5]],
['generated control 3', [350, 6.5, 140, 1, 20], [3, 19.5, 31.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: strip count loop', [420, 5, 150, 0, 20], [3, 15, 0]],
['repair check: strip count loop', [280, 6.5, 110, 1, 20], [3, 19.5, 11.0]],
['generated control 1', [280, 5, 110, 2, 25], [3, 15, 3]],
['generated control 2', [420, 6.5, 140, 1, 30], [4, 26.0, 82.5]],
['generated control 3', [420, 5, 110, 1, 30], [5, 25, 70]]],
[['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: strip count loop', [420, 5, 150, 0, 20], [3, 15, 0]],
['repair check: strip count loop', [350, 5, 110, 2, 20], [4, 20, 39]],
['generated control 1', [350, 5, 150, 0, 20], [3, 15, 70]],
['generated control 2', [200, 6.5, 107, 2, 0], [3, 19.5, 96.0]],
['generated control 3', [420, 6, 150, 0, 20], [4, 24, 142]]],
[['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: strip count loop', [280, 5, 107, 1, 25], [3, 15, 0]],
['repair check: strip count loop', [150, 6, 150, 0, 20], [2, 12, 124]],
['generated control 1', [200, 6.5, 110, 0, 20], [3, 19.5, 97.0]],
['generated control 2', [150, 4, 107, 2, 25], [2, 8, 27]],
['generated control 3', [600, 4, 150, 0, 0], [5, 20, 134]]],
[['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: strip count loop', [420, 4, 110, 1, 0], [4, 16, 0]],
['repair check: strip count loop', [600, 5, 110, 1, 0], [6, 30, 23]],
['generated control 1', [200, 6, 140, 1, 25], [2, 12, 45]],
['generated control 2', [200, 6, 150, 1, 25], [2, 12, 65]],
['generated control 3', [420, 5, 110, 2, 30], [5, 25, 60]]]]
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: strip count loop | [3, 19.5, 0.0] | [3, 19.5, 0.0] | Passed |
| repair check: strip count loop | [2, 13.0, 9.5] | [2, 13.0, 9.5] | Passed |
| generated control 1 | [2, 8, 118] | [2, 8, 118] | Passed |
| generated control 2 | [2, 13.0, 65.5] | [2, 13.0, 65.5] | Passed |
| generated control 3 | [3, 19.5, 31.0] | [3, 19.5, 31.0] | Passed |
SHA-256 / 627e3fb67df22414b8504d6e98d3ce6b81a9b2c797bb0d260b380445f8e55068
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.867297+00:00.
Case digest / 4e5c902c4ea8870ccf37998cf6f5c7d1841752c0ee5e459e6b36794c626bd618