FA-97656 / Knitting and sewing pattern grading / Open access
Stranded colorwork float checker: float limit · case 01
Floats exactly at the allowed length are flagged.
ROOT CAUSE
The limit is treated as exclusive.
VERIFIED REPAIR
Flag floats strictly longer than max_float.
Unsuccessful approach: Allowing one extra stitch misses real problems.
Case contract
row is a string of color letters. For each color, a float is a maximal run of other colors [start, length]. In the round, a float touching both the end and the start (with at least two runs) wraps and merges into the last run (its start is kept). Report [color, start, length] for floats longer than max_float, sorted by (start, color).
Why this case matters
Stranded knitting charts are checked for long floats that need catching.
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(row, max_float, in_round):
n = len(row)
out = []
for color in sorted(set(row)):
runs = []
i = 0
while i < n:
if row[i] != color:
j = i
while j < n and row[j] != color:
j += 1
runs.append([i, j - i])
i = j
else:
i += 1
if in_round and len(runs) >= 2 and runs[0][0] == 0 and runs[-1][0] + runs[-1][1] == n:
first = runs.pop(0)
runs[-1][1] += first[1]
for start, length in runs:
if length >= max_float:
out.append([color, start, length])
return sorted(out, key=lambda x: (x[1], x[0]))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []],
['regression: float limit', ['AAAAABAABAAAB', 3, True], [['B', 0, 5]]],
['repair check: float limit', ['BAAAAABAAAA', 3, True], [['B', 1, 5], ['B', 7, 4]]],
['generated control 1', ['BAAAAABAAAAA', 5, True], []], ['generated control 2', ['ABBBAAA', 4, False], []],
['generated control 3', ['BAAAAAAABBBAA', 5, False], [['B', 1, 7]]]],
[['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['regression: float limit', ['BAAAAAABBBAAAAA', 3, True], [['B', 1, 6], ['B', 10, 5]]],
['repair check: float limit', ['AAAAABBABAAAAAAB', 5, False], [['B', 9, 6]]],
['generated control 1', ['AAAAAACCAACAABA', 4, False], [['B', 0, 13], ['C', 0, 6]]],
['generated control 2', ['AAAAAAA', 4, True], []],
['generated control 3', ['BBABAAAABAAA', 3, True], [['B', 4, 4]]]],
[['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['regression: float limit', ['BAAAAAAABBBAA', 3, False], [['B', 1, 7]]],
['repair check: float limit', ['BAAABAAAA', 3, False], [['B', 5, 4]]],
['generated control 1', ['ABAAABABBA', 3, False], []],
['generated control 2', ['CBCCCABAACCBBCA', 5, True], []],
['generated control 3', ['BAAAABBAAA', 4, True], []]],
[['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []],
['regression: float limit', ['BAAAAAAABBBAAAAA', 3, True], [['B', 1, 7], ['B', 11, 5]]],
['repair check: float limit', ['BAAAABBBAAA', 3, False], [['B', 1, 4]]],
['generated control 1', ['AAAAABAA', 3, True], [['B', 6, 7]]],
['generated control 2', ['BAAAAABAAA', 3, False], [['B', 1, 5]]],
['generated control 3', ['AAABAAAAABABAAB', 5, False], []]],
[['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['regression: float limit', ['BAAABBAA', 3, True], []],
['repair check: float limit', ['AABAAAABAAAAA', 3, True], [['B', 3, 4], ['B', 8, 7]]],
['generated control 1', ['AAAAAAA', 5, True], []], ['generated control 2', ['AABABAB', 3, False], []],
['generated control 3', ['BAAABAABBAAABAB', 5, True], []]]]
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 |
|---|---|---|---|
| flat long float | [['B', 1, 6]] | [['B', 1, 6]] | Passed |
| wrap in round | [['B', 2, 5], ['A', 7, 5]] | [['B', 2, 5], ['A', 7, 5]] | Passed |
| exact limit | [['B', 1, 4]] | [] | Failed |
| regression: float limit | [['B', 0, 5], ['B', 9, 3]] | [['B', 0, 5]] | Failed |
| repair check: float limit | [['B', 1, 5], ['B', 7, 4]] | [['B', 1, 5], ['B', 7, 4]] | Passed |
| generated control 1 | [['B', 1, 5], ['B', 7, 5]] | [] | Failed |
| generated control 2 | [] | [] | Passed |
| generated control 3 | [['B', 1, 7]] | [['B', 1, 7]] | Passed |
SHA-256 / 80f878b54f34e699c880782d3690367606e7eb19ebdd2a79f1df4e700bd3abfb
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(row, max_float, in_round):
n = len(row)
out = []
for color in sorted(set(row)):
runs = []
i = 0
while i < n:
if row[i] != color:
j = i
while j < n and row[j] != color:
j += 1
runs.append([i, j - i])
i = j
else:
i += 1
if in_round and len(runs) >= 2 and runs[0][0] == 0 and runs[-1][0] + runs[-1][1] == n:
first = runs.pop(0)
runs[-1][1] += first[1]
for start, length in runs:
if length > max_float + 1:
out.append([color, start, length])
return sorted(out, key=lambda x: (x[1], x[0]))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []],
['regression: float limit', ['AAAAABAABAAAB', 3, True], [['B', 0, 5]]],
['repair check: float limit', ['BAAAAABAAAA', 3, True], [['B', 1, 5], ['B', 7, 4]]],
['generated control 1', ['BAAAAABAAAAA', 5, True], []], ['generated control 2', ['ABBBAAA', 4, False], []],
['generated control 3', ['BAAAAAAABBBAA', 5, False], [['B', 1, 7]]]],
[['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['regression: float limit', ['BAAAAAABBBAAAAA', 3, True], [['B', 1, 6], ['B', 10, 5]]],
['repair check: float limit', ['AAAAABBABAAAAAAB', 5, False], [['B', 9, 6]]],
['generated control 1', ['AAAAAACCAACAABA', 4, False], [['B', 0, 13], ['C', 0, 6]]],
['generated control 2', ['AAAAAAA', 4, True], []],
['generated control 3', ['BBABAAAABAAA', 3, True], [['B', 4, 4]]]],
[['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['regression: float limit', ['BAAAAAAABBBAA', 3, False], [['B', 1, 7]]],
['repair check: float limit', ['BAAABAAAA', 3, False], [['B', 5, 4]]],
['generated control 1', ['ABAAABABBA', 3, False], []],
['generated control 2', ['CBCCCABAACCBBCA', 5, True], []],
['generated control 3', ['BAAAABBAAA', 4, True], []]],
[['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []],
['regression: float limit', ['BAAAAAAABBBAAAAA', 3, True], [['B', 1, 7], ['B', 11, 5]]],
['repair check: float limit', ['BAAAABBBAAA', 3, False], [['B', 1, 4]]],
['generated control 1', ['AAAAABAA', 3, True], [['B', 6, 7]]],
['generated control 2', ['BAAAAABAAA', 3, False], [['B', 1, 5]]],
['generated control 3', ['AAABAAAAABABAAB', 5, False], []]],
[['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['regression: float limit', ['BAAABBAA', 3, True], []],
['repair check: float limit', ['AABAAAABAAAAA', 3, True], [['B', 3, 4], ['B', 8, 7]]],
['generated control 1', ['AAAAAAA', 5, True], []], ['generated control 2', ['AABABAB', 3, False], []],
['generated control 3', ['BAAABAABBAAABAB', 5, True], []]]]
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 |
|---|---|---|---|
| flat long float | [] | [['B', 1, 6]] | Failed |
| wrap in round | [] | [['B', 2, 5], ['A', 7, 5]] | Failed |
| exact limit | [] | [] | Passed |
| regression: float limit | [['B', 0, 5]] | [['B', 0, 5]] | Passed |
| repair check: float limit | [['B', 1, 5]] | [['B', 1, 5], ['B', 7, 4]] | Failed |
| generated control 1 | [] | [] | Passed |
| generated control 2 | [] | [] | Passed |
| generated control 3 | [['B', 1, 7]] | [['B', 1, 7]] | Passed |
SHA-256 / b800ff2bca26084ddaa6ae1df6975fbcf59086a5f96f17ec0acb224c202f776f
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(row, max_float, in_round):
n = len(row)
out = []
for color in sorted(set(row)):
runs = []
i = 0
while i < n:
if row[i] != color:
j = i
while j < n and row[j] != color:
j += 1
runs.append([i, j - i])
i = j
else:
i += 1
if in_round and len(runs) >= 2 and runs[0][0] == 0 and runs[-1][0] + runs[-1][1] == n:
first = runs.pop(0)
runs[-1][1] += first[1]
for start, length in runs:
if length > max_float:
out.append([color, start, length])
return sorted(out, key=lambda x: (x[1], x[0]))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []],
['regression: float limit', ['AAAAABAABAAAB', 3, True], [['B', 0, 5]]],
['repair check: float limit', ['BAAAAABAAAA', 3, True], [['B', 1, 5], ['B', 7, 4]]],
['generated control 1', ['BAAAAABAAAAA', 5, True], []], ['generated control 2', ['ABBBAAA', 4, False], []],
['generated control 3', ['BAAAAAAABBBAA', 5, False], [['B', 1, 7]]]],
[['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['regression: float limit', ['BAAAAAABBBAAAAA', 3, True], [['B', 1, 6], ['B', 10, 5]]],
['repair check: float limit', ['AAAAABBABAAAAAAB', 5, False], [['B', 9, 6]]],
['generated control 1', ['AAAAAACCAACAABA', 4, False], [['B', 0, 13], ['C', 0, 6]]],
['generated control 2', ['AAAAAAA', 4, True], []],
['generated control 3', ['BBABAAAABAAA', 3, True], [['B', 4, 4]]]],
[['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['regression: float limit', ['BAAAAAAABBBAA', 3, False], [['B', 1, 7]]],
['repair check: float limit', ['BAAABAAAA', 3, False], [['B', 5, 4]]],
['generated control 1', ['ABAAABABBA', 3, False], []],
['generated control 2', ['CBCCCABAACCBBCA', 5, True], []],
['generated control 3', ['BAAAABBAAA', 4, True], []]],
[['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []],
['regression: float limit', ['BAAAAAAABBBAAAAA', 3, True], [['B', 1, 7], ['B', 11, 5]]],
['repair check: float limit', ['BAAAABBBAAA', 3, False], [['B', 1, 4]]],
['generated control 1', ['AAAAABAA', 3, True], [['B', 6, 7]]],
['generated control 2', ['BAAAAABAAA', 3, False], [['B', 1, 5]]],
['generated control 3', ['AAABAAAAABABAAB', 5, False], []]],
[['wrap in round', ['BBAAAAABBB', 4, True], [['B', 2, 5], ['A', 7, 5]]],
['exact limit', ['BAAAAB', 4, False], []], ['flat long float', ['BAAAAAABBA', 5, False], [['B', 1, 6]]],
['regression: float limit', ['BAAABBAA', 3, True], []],
['repair check: float limit', ['AABAAAABAAAAA', 3, True], [['B', 3, 4], ['B', 8, 7]]],
['generated control 1', ['AAAAAAA', 5, True], []], ['generated control 2', ['AABABAB', 3, False], []],
['generated control 3', ['BAAABAABBAAABAB', 5, True], []]]]
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 |
|---|---|---|---|
| flat long float | [['B', 1, 6]] | [['B', 1, 6]] | Passed |
| wrap in round | [['B', 2, 5], ['A', 7, 5]] | [['B', 2, 5], ['A', 7, 5]] | Passed |
| exact limit | [] | [] | Passed |
| regression: float limit | [['B', 0, 5]] | [['B', 0, 5]] | Passed |
| repair check: float limit | [['B', 1, 5], ['B', 7, 4]] | [['B', 1, 5], ['B', 7, 4]] | Passed |
| generated control 1 | [] | [] | Passed |
| generated control 2 | [] | [] | Passed |
| generated control 3 | [['B', 1, 7]] | [['B', 1, 7]] | Passed |
SHA-256 / b4f205be45ae65e9be1e609848b9f88d5f812c2680e8164b9c1d9db12a24c381
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:34.363796+00:00.
Case digest / b5e23466c2688af5ff1b9ac34a4a0a3aa4ed247bffcb0b51dc5be81ec35f0997