FA-97666 / Knitting and sewing pattern grading / Open access
Stranded colorwork float checker: merged float start · case 01
A wrapped float is reported starting at stitch 0 instead of where it begins before the round end.
ROOT CAUSE
The merged float keeps the start of the first run.
THE FAILURE
The merged float keeps the start of the first run.
Unsuccessful approach: Taking the longer part instead of the sum under-reports the float.
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:
last = runs.pop()
runs[0][1] += last[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: merged float start', ['AAABAAABAAA', 4, True], [['B', 8, 6]]],
['repair check: merged float start', ['BAAACCABAB', 3, True], [['B', 1, 6], ['C', 6, 8]]],
['generated control 1', ['AAAAAAAAAAAAAA', 5, True], []],
['generated control 2', ['BAAAABAAAAAAAB', 3, False], [['B', 1, 4], ['B', 6, 7]]],
['generated control 3', ['BAAABBBAAAA', 4, True], []]],
[['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: merged float start', ['ABAABABAAA', 3, True], [['B', 7, 4]]],
['repair check: merged float start', ['AABBAA', 3, True], [['B', 4, 4]]],
['generated control 1', ['AAAAAABAA', 3, False], [['B', 0, 6]]],
['generated control 2', ['BAAAAAAABAAAA', 4, False], [['B', 1, 7]]],
['generated control 3', ['BACABAABAAACABA', 4, False], [['C', 3, 8], ['B', 8, 5]]]],
[['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: merged float start', ['AAAAACBA', 3, True], [['C', 6, 7], ['B', 7, 7]]],
['repair check: merged float start', ['ABAAABBAAACCABA', 3, True], [['B', 7, 6], ['C', 12, 13]]],
['generated control 1', ['AABABAAACAABACAA', 4, False], [['C', 0, 8], ['B', 5, 6]]],
['generated control 2', ['AAAAAA', 3, True], []],
['generated control 3', ['BAAAAABBBAAAA', 4, False], [['B', 1, 5]]]],
[['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: merged float start', ['AAACAAAABACAAAA', 3, True], [['C', 4, 6], ['B', 9, 14], ['C', 11, 7]]],
['repair check: merged float start', ['ABAAACCABA', 4, True], [['B', 2, 6], ['C', 7, 8]]],
['generated control 1', ['BAAABBBAAA', 4, False], []],
['generated control 2', ['BAAAAAAABBBAA', 5, False], [['B', 1, 7]]],
['generated control 3', ['BAAAAAAABAAAA', 5, True], [['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: merged float start', ['AAAACCACACA', 3, True], [['C', 10, 5]]],
['repair check: merged float start', ['ABAABAAAAA', 4, True], [['B', 5, 6]]],
['generated control 1', ['BAABBA', 5, True], []], ['generated control 2', ['ABABAA', 4, True], []],
['generated control 3', ['BAAAABBAA', 5, False], []]]]
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 | [['A', 0, 5], ['B', 2, 5]] | [['B', 2, 5], ['A', 7, 5]] | Failed |
| exact limit | [] | [] | Passed |
| regression: merged float start | [['B', 0, 6]] | [['B', 8, 6]] | Failed |
| repair check: merged float start | [['C', 0, 8], ['B', 1, 6]] | [['B', 1, 6], ['C', 6, 8]] | Failed |
| generated control 1 | [] | [] | Passed |
| generated control 2 | [['B', 1, 4], ['B', 6, 7]] | [['B', 1, 4], ['B', 6, 7]] | Passed |
| generated control 3 | [] | [] | Passed |
SHA-256 / 64c5c5f461d4f573ea570d13bed5d8171dface73c7ad2a3ef1e29319d49b5a04
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] = max(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: merged float start', ['AAABAAABAAA', 4, True], [['B', 8, 6]]],
['repair check: merged float start', ['BAAACCABAB', 3, True], [['B', 1, 6], ['C', 6, 8]]],
['generated control 1', ['AAAAAAAAAAAAAA', 5, True], []],
['generated control 2', ['BAAAABAAAAAAAB', 3, False], [['B', 1, 4], ['B', 6, 7]]],
['generated control 3', ['BAAABBBAAAA', 4, True], []]],
[['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: merged float start', ['ABAABABAAA', 3, True], [['B', 7, 4]]],
['repair check: merged float start', ['AABBAA', 3, True], [['B', 4, 4]]],
['generated control 1', ['AAAAAABAA', 3, False], [['B', 0, 6]]],
['generated control 2', ['BAAAAAAABAAAA', 4, False], [['B', 1, 7]]],
['generated control 3', ['BACABAABAAACABA', 4, False], [['C', 3, 8], ['B', 8, 5]]]],
[['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: merged float start', ['AAAAACBA', 3, True], [['C', 6, 7], ['B', 7, 7]]],
['repair check: merged float start', ['ABAAABBAAACCABA', 3, True], [['B', 7, 6], ['C', 12, 13]]],
['generated control 1', ['AABABAAACAABACAA', 4, False], [['C', 0, 8], ['B', 5, 6]]],
['generated control 2', ['AAAAAA', 3, True], []],
['generated control 3', ['BAAAAABBBAAAA', 4, False], [['B', 1, 5]]]],
[['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: merged float start', ['AAACAAAABACAAAA', 3, True], [['C', 4, 6], ['B', 9, 14], ['C', 11, 7]]],
['repair check: merged float start', ['ABAAACCABA', 4, True], [['B', 2, 6], ['C', 7, 8]]],
['generated control 1', ['BAAABBBAAA', 4, False], []],
['generated control 2', ['BAAAAAAABBBAA', 5, False], [['B', 1, 7]]],
['generated control 3', ['BAAAAAAABAAAA', 5, True], [['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: merged float start', ['AAAACCACACA', 3, True], [['C', 10, 5]]],
['repair check: merged float start', ['ABAABAAAAA', 4, True], [['B', 5, 6]]],
['generated control 1', ['BAABBA', 5, True], []], ['generated control 2', ['ABABAA', 4, True], []],
['generated control 3', ['BAAAABBAA', 5, False], []]]]
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]] | [['B', 2, 5], ['A', 7, 5]] | Failed |
| exact limit | [] | [] | Passed |
| regression: merged float start | [] | [['B', 8, 6]] | Failed |
| repair check: merged float start | [['B', 1, 6], ['C', 6, 4]] | [['B', 1, 6], ['C', 6, 8]] | Failed |
| generated control 1 | [] | [] | Passed |
| generated control 2 | [['B', 1, 4], ['B', 6, 7]] | [['B', 1, 4], ['B', 6, 7]] | Passed |
| generated control 3 | [] | [] | Passed |
SHA-256 / 094eb384cb0285efdf090b522c2564e1448eab849c8ccef5a36adb2a68e9755a
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.372844+00:00.
Case digest / 846e8da47f770adc3f093e84fd99b95a52d50fe40ebd801bb684738ac6db3e97