FAILURE MAP
← Case archive

FA-97671 / Knitting and sewing pattern grading / Open access

Stranded colorwork float checker: report order · case 01

Floats are listed grouped by color instead of by position across the row.

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

ROOT CAUSE

The report keeps per-color discovery order.

THE FAILURE

The report keeps per-color discovery order.

Unsuccessful approach: Sorting by length loses the position order.

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 out
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: report order', ['AAAAAACBCCBAACAA', 4, False],
   [['B', 0, 7], ['C', 0, 6], ['A', 6, 5], ['B', 11, 5]]],
  ['repair check: report order', ['BAAAABAABAAAAAAA', 3, True], [['B', 1, 4], ['B', 9, 7]]],
  ['generated control 1', ['ABBBABAAABA', 4, True], []],
  ['generated control 2', ['AABABAAAABAA', 4, False], []],
  ['generated control 3', ['AAAAAA', 4, 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: report order', ['AAAABAAAACABAA', 3, False],
   [['B', 0, 4], ['C', 0, 9], ['B', 5, 6], ['C', 10, 4]]],
  ['repair check: report order', ['AAAAABAAAAAAAA', 4, False], [['B', 0, 5], ['B', 6, 8]]],
  ['generated control 1', ['ABAAAAABAAAABA', 3, False], [['B', 2, 5], ['B', 8, 4]]],
  ['generated control 2', ['BAAAABAA', 5, False], []],
  ['generated control 3', ['BAAAAAABBAAA', 4, False], [['B', 1, 6]]]],
 [['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: report order', ['AAAAAAAACABAAAC', 4, True], [['C', 0, 8], ['C', 9, 5], ['B', 11, 14]]],
  ['repair check: report order', ['BAAAABAAAAA', 3, True], [['B', 1, 4], ['B', 6, 5]]],
  ['generated control 1', ['ABAAAAAAAAA', 5, False], [['B', 2, 9]]],
  ['generated control 2', ['AABBABBABABA', 3, False], []],
  ['generated control 3', ['BAAAAABAAAA', 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: report order', ['AAAAAAAAAAAAACBC', 4, True], [['C', 0, 13], ['B', 15, 15]]],
  ['repair check: report order', ['BAAAABAAAAA', 3, False], [['B', 1, 4], ['B', 6, 5]]],
  ['generated control 1', ['ABABAAAA', 3, True], [['B', 4, 5]]],
  ['generated control 2', ['BAAAABBAAAAA', 5, False], []],
  ['generated control 3', ['BACACCABACAB', 3, True], [['B', 1, 6], ['C', 10, 4]]]],
 [['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: report order', ['CAAAABAAAAA', 4, False], [['B', 0, 5], ['C', 1, 10], ['B', 6, 5]]],
  ['repair check: report order', ['AAAAAAABAC', 4, False], [['B', 0, 7], ['C', 0, 9]]],
  ['generated control 1', ['BAAABAAAAA', 4, True], [['B', 5, 5]]],
  ['generated control 2', ['BAAAAAAABAAA', 5, False], [['B', 1, 7]]],
  ['generated control 3', ['AAAAAA', 3, 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 fixtureActualExpectedOutcome
flat long float[['B', 1, 6]][['B', 1, 6]]Passed
wrap in round[['A', 7, 5], ['B', 2, 5]][['B', 2, 5], ['A', 7, 5]]Failed
exact limit[][]Passed
regression: report order[['A', 6, 5], ['B', 0, 7], ['B', 11, 5], ['C', 0, 6]][['B', 0, 7], ['C', 0, 6], ['A', 6, 5], ['B', 11, 5]]Failed
repair check: report order[['B', 1, 4], ['B', 9, 7]][['B', 1, 4], ['B', 9, 7]]Passed
generated control 1[][]Passed
generated control 2[][]Passed
generated control 3[][]Passed

SHA-256 / a7de8db7779941d8f5f7c4a9cb2e296a3f2920d41d97c0a167d424c03969bf17

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:
                out.append([color, start, length])
    return sorted(out, key=lambda x: -x[2])
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: report order', ['AAAAAACBCCBAACAA', 4, False],
   [['B', 0, 7], ['C', 0, 6], ['A', 6, 5], ['B', 11, 5]]],
  ['repair check: report order', ['BAAAABAABAAAAAAA', 3, True], [['B', 1, 4], ['B', 9, 7]]],
  ['generated control 1', ['ABBBABAAABA', 4, True], []],
  ['generated control 2', ['AABABAAAABAA', 4, False], []],
  ['generated control 3', ['AAAAAA', 4, 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: report order', ['AAAABAAAACABAA', 3, False],
   [['B', 0, 4], ['C', 0, 9], ['B', 5, 6], ['C', 10, 4]]],
  ['repair check: report order', ['AAAAABAAAAAAAA', 4, False], [['B', 0, 5], ['B', 6, 8]]],
  ['generated control 1', ['ABAAAAABAAAABA', 3, False], [['B', 2, 5], ['B', 8, 4]]],
  ['generated control 2', ['BAAAABAA', 5, False], []],
  ['generated control 3', ['BAAAAAABBAAA', 4, False], [['B', 1, 6]]]],
 [['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: report order', ['AAAAAAAACABAAAC', 4, True], [['C', 0, 8], ['C', 9, 5], ['B', 11, 14]]],
  ['repair check: report order', ['BAAAABAAAAA', 3, True], [['B', 1, 4], ['B', 6, 5]]],
  ['generated control 1', ['ABAAAAAAAAA', 5, False], [['B', 2, 9]]],
  ['generated control 2', ['AABBABBABABA', 3, False], []],
  ['generated control 3', ['BAAAAABAAAA', 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: report order', ['AAAAAAAAAAAAACBC', 4, True], [['C', 0, 13], ['B', 15, 15]]],
  ['repair check: report order', ['BAAAABAAAAA', 3, False], [['B', 1, 4], ['B', 6, 5]]],
  ['generated control 1', ['ABABAAAA', 3, True], [['B', 4, 5]]],
  ['generated control 2', ['BAAAABBAAAAA', 5, False], []],
  ['generated control 3', ['BACACCABACAB', 3, True], [['B', 1, 6], ['C', 10, 4]]]],
 [['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: report order', ['CAAAABAAAAA', 4, False], [['B', 0, 5], ['C', 1, 10], ['B', 6, 5]]],
  ['repair check: report order', ['AAAAAAABAC', 4, False], [['B', 0, 7], ['C', 0, 9]]],
  ['generated control 1', ['BAAABAAAAA', 4, True], [['B', 5, 5]]],
  ['generated control 2', ['BAAAAAAABAAA', 5, False], [['B', 1, 7]]],
  ['generated control 3', ['AAAAAA', 3, 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 fixtureActualExpectedOutcome
flat long float[['B', 1, 6]][['B', 1, 6]]Passed
wrap in round[['A', 7, 5], ['B', 2, 5]][['B', 2, 5], ['A', 7, 5]]Failed
exact limit[][]Passed
regression: report order[['B', 0, 7], ['C', 0, 6], ['A', 6, 5], ['B', 11, 5]][['B', 0, 7], ['C', 0, 6], ['A', 6, 5], ['B', 11, 5]]Passed
repair check: report order[['B', 9, 7], ['B', 1, 4]][['B', 1, 4], ['B', 9, 7]]Failed
generated control 1[][]Passed
generated control 2[][]Passed
generated control 3[][]Passed

SHA-256 / 707e375293c67d8e16e5a2903848d402bdee108f4c9578662e4ad0ad1c49ca9e

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

Case digest / d96eb3d7850275193387a45f22c3f18550a53938b19b7b7eb0b07b706ea56b76