{"abstract":"An exact two-skein need reports a full skein left over.","category":"Knitting and sewing pattern grading","checks":8,"contract":"grams = garment_area / swatch_area * swatch_g; meters = grams * skein_m/skein_g; add margin_pct as a multiplier (meters*(1+margin/100)). skeins = ceiling(meters/skein_m); leftover = skeins*skein_m - meters. Return [meters, skeins, leftover] with meters and leftover half-up integers. Non-positive swatch area or skein weight -> \"error: swatch\".","contract_signature":"swatch_g, swatch_w_cm, swatch_h_cm, garment_area_cm2, skein_g, skein_m, margin_pct","evaluation_group":"w2-knitting_and_sewing_pattern_grading-yardage-estimate","failed_approach":"Using pre-margin metres counts the safety margin as leftover.","family":"w2-knitting_and_sewing_pattern_grading-yardage-estimate-leftover-basis","id":"FA-97431","implementations":{"attempt":{"sha256":"a33e057592205daf522a3551258390361602d3b48382808aaf4e3028d91afed3","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(swatch_g, swatch_w_cm, swatch_h_cm, garment_area_cm2, skein_g, skein_m, margin_pct):\n    sw_area = Fraction(str(swatch_w_cm)) * Fraction(str(swatch_h_cm))\n    if sw_area <= 0 or skein_g <= 0:\n        return 'error: swatch'\n    grams = Fraction(str(garment_area_cm2)) / sw_area * Fraction(str(swatch_g))\n    meters = grams * Fraction(skein_m, skein_g)\n    meters = meters * (1 + Fraction(margin_pct, 100))\n    skeins = math.ceil(meters / skein_m)\n    leftover = skeins * skein_m - grams * Fraction(skein_m, skein_g)\n    return [math.floor(meters + Fraction(1, 2)), skeins, math.floor(leftover + Fraction(1, 2))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['regression: leftover basis', [20, 15, 12, 9000, 50, 400, 10], [8800, 22, 0]],\n  ['repair check: leftover basis', [8, 10, 15, 3000, 100, 100, 10], [176, 2, 24]],\n  ['generated control 1', [8, 15, 10, 2000, 100, 200, 0], [213, 2, 187]],\n  ['generated control 2', [12, 12, 15, 6000, 50, 150, 20], [1440, 10, 60]],\n  ['generated control 3', [8, 15, 12, 1500, 50, 125, 0], [167, 2, 83]]],\n [['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['regression: leftover basis', [15, 15, 12, 2000, 50, 150, 20], [600, 4, 0]],\n  ['repair check: leftover basis', [20, 10, 10, 2400, 50, 125, 15], [1380, 12, 120]],\n  ['generated control 1', [15, 12, 15, 2000, 100, 400, 10], [733, 2, 67]],\n  ['generated control 2', [15, 15, 10, 3000, 100, 125, 15], [431, 4, 69]],\n  ['generated control 3', [8, 15, 15, 6000, 100, 400, 0], [853, 3, 347]]],\n [['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['regression: leftover basis', [20, 10, 12, 3000, 50, 100, 0], [1000, 10, 0]],\n  ['repair check: leftover basis', [15, 15, 10, 2400, 50, 125, 10], [660, 6, 90]],\n  ['generated control 1', [8, 10, 15, 2000, 50, 100, 0], [213, 3, 87]],\n  ['generated control 2', [15, 10, 12, 4800, 100, 200, 0], [1200, 6, 0]],\n  ['generated control 3', [12, 15, 12, 9000, 50, 400, 15], [5520, 14, 80]]],\n [['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['regression: leftover basis', [10, 12, 15, 9000, 100, 100, 20], [600, 6, 0]],\n  ['repair check: leftover basis', [10, 12, 12, 4800, 50, 125, 15], [958, 8, 42]],\n  ['generated control 1', [15, 10, 15, 9000, 100, 125, 10], [1238, 10, 13]],\n  ['generated control 2', [12, 12, 10, 1500, 100, 400, 10], [660, 2, 140]],\n  ['generated control 3', [15, 10, 10, 6000, 100, 400, 15], [4140, 11, 260]]],\n [['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['regression: leftover basis', [12, 12, 12, 3000, 100, 150, 20], [450, 3, 0]],\n  ['repair check: leftover basis', [20, 15, 10, 3000, 100, 100, 10], [440, 5, 60]],\n  ['generated control 1', [8, 10, 12, 2400, 50, 125, 10], [440, 4, 60]],\n  ['generated control 2', [15, 12, 12, 9000, 50, 125, 15], [2695, 22, 55]],\n  ['generated control 3', [20, 12, 15, 2000, 100, 125, 10], [306, 3, 69]]]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"f34df92576450a20141df2413815e9033191ef67f933c13bee3aa20e77da5aeb","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(swatch_g, swatch_w_cm, swatch_h_cm, garment_area_cm2, skein_g, skein_m, margin_pct):\n    sw_area = Fraction(str(swatch_w_cm)) * Fraction(str(swatch_h_cm))\n    if sw_area <= 0 or skein_g <= 0:\n        return 'error: swatch'\n    grams = Fraction(str(garment_area_cm2)) / sw_area * Fraction(str(swatch_g))\n    meters = grams * Fraction(skein_m, skein_g)\n    meters = meters * (1 + Fraction(margin_pct, 100))\n    skeins = math.ceil(meters / skein_m)\n    leftover = skein_m - meters % skein_m\n    return [math.floor(meters + Fraction(1, 2)), skeins, math.floor(leftover + Fraction(1, 2))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['regression: leftover basis', [20, 15, 12, 9000, 50, 400, 10], [8800, 22, 0]],\n  ['repair check: leftover basis', [8, 10, 15, 3000, 100, 100, 10], [176, 2, 24]],\n  ['generated control 1', [8, 15, 10, 2000, 100, 200, 0], [213, 2, 187]],\n  ['generated control 2', [12, 12, 15, 6000, 50, 150, 20], [1440, 10, 60]],\n  ['generated control 3', [8, 15, 12, 1500, 50, 125, 0], [167, 2, 83]]],\n [['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['regression: leftover basis', [15, 15, 12, 2000, 50, 150, 20], [600, 4, 0]],\n  ['repair check: leftover basis', [20, 10, 10, 2400, 50, 125, 15], [1380, 12, 120]],\n  ['generated control 1', [15, 12, 15, 2000, 100, 400, 10], [733, 2, 67]],\n  ['generated control 2', [15, 15, 10, 3000, 100, 125, 15], [431, 4, 69]],\n  ['generated control 3', [8, 15, 15, 6000, 100, 400, 0], [853, 3, 347]]],\n [['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['regression: leftover basis', [20, 10, 12, 3000, 50, 100, 0], [1000, 10, 0]],\n  ['repair check: leftover basis', [15, 15, 10, 2400, 50, 125, 10], [660, 6, 90]],\n  ['generated control 1', [8, 10, 15, 2000, 50, 100, 0], [213, 3, 87]],\n  ['generated control 2', [15, 10, 12, 4800, 100, 200, 0], [1200, 6, 0]],\n  ['generated control 3', [12, 15, 12, 9000, 50, 400, 15], [5520, 14, 80]]],\n [['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['regression: leftover basis', [10, 12, 15, 9000, 100, 100, 20], [600, 6, 0]],\n  ['repair check: leftover basis', [10, 12, 12, 4800, 50, 125, 15], [958, 8, 42]],\n  ['generated control 1', [15, 10, 15, 9000, 100, 125, 10], [1238, 10, 13]],\n  ['generated control 2', [12, 12, 10, 1500, 100, 400, 10], [660, 2, 140]],\n  ['generated control 3', [15, 10, 10, 6000, 100, 400, 15], [4140, 11, 260]]],\n [['with margin', [12, 10, 12, 4800, 50, 125, 10], [1320, 11, 55]],\n  ['zero swatch', [10, 0, 10, 2000, 100, 200, 0], 'error: swatch'],\n  ['exact two skeins', [10, 10, 10, 2000, 100, 200, 0], [400, 2, 0]],\n  ['regression: leftover basis', [12, 12, 12, 3000, 100, 150, 20], [450, 3, 0]],\n  ['repair check: leftover basis', [20, 15, 10, 3000, 100, 100, 10], [440, 5, 60]],\n  ['generated control 1', [8, 10, 12, 2400, 50, 125, 10], [440, 4, 60]],\n  ['generated control 2', [15, 12, 12, 9000, 50, 125, 15], [2695, 22, 55]],\n  ['generated control 3', [20, 12, 15, 2000, 100, 125, 10], [306, 3, 69]]]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-knitting_and_sewing_pattern_grading-yardage-estimate-leftover-basis","generated_at":"2026-09-29T14:52:32.148881+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Designers and knitters estimate how many skeins to buy from a weighed swatch.","root_cause":"Leftover is computed from the remainder in the last skein, which is wrong when the need is exact.","sha256":"255a9ba5f4ee9437025123bb6d31275229c20cbc0ae14a025ae31a138fb8a1b5","title":"Yarn yardage estimator: leftover basis · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":43.247,"exit_code":1,"observations":[{"actual":[400,2,0],"check":"exact two skeins","expected":[400,2,0],"passed":true},{"actual":[1320,11,175],"check":"with margin","expected":[1320,11,55],"passed":false},{"actual":"error: swatch","check":"zero swatch","expected":"error: swatch","passed":true},{"actual":[8800,22,800],"check":"regression: leftover basis","expected":[8800,22,0],"passed":false},{"actual":[176,2,40],"check":"repair check: leftover basis","expected":[176,2,24],"passed":false},{"actual":[213,2,187],"check":"generated control 1","expected":[213,2,187],"passed":true},{"actual":[1440,10,300],"check":"generated control 2","expected":[1440,10,60],"passed":false},{"actual":[167,2,83],"check":"generated control 3","expected":[167,2,83],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"exact two skeins\", \"actual\": [400, 2, 0], \"expected\": [400, 2, 0], \"passed\": true}, {\"check\": \"with margin\", \"actual\": [1320, 11, 175], \"expected\": [1320, 11, 55], \"passed\": false}, {\"check\": \"zero swatch\", \"actual\": \"error: swatch\", \"expected\": \"error: swatch\", \"passed\": true}, {\"check\": \"regression: leftover basis\", \"actual\": [8800, 22, 800], \"expected\": [8800, 22, 0], \"passed\": false}, {\"check\": \"repair check: leftover basis\", \"actual\": [176, 2, 40], \"expected\": [176, 2, 24], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [213, 2, 187], \"expected\": [213, 2, 187], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [1440, 10, 300], \"expected\": [1440, 10, 60], \"passed\": false}, {\"check\": \"generated control 3\", \"actual\": [167, 2, 83], \"expected\": [167, 2, 83], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":43.825,"exit_code":1,"observations":[{"actual":[400,2,200],"check":"exact two skeins","expected":[400,2,0],"passed":false},{"actual":[1320,11,55],"check":"with margin","expected":[1320,11,55],"passed":true},{"actual":"error: swatch","check":"zero swatch","expected":"error: swatch","passed":true},{"actual":[8800,22,400],"check":"regression: leftover basis","expected":[8800,22,0],"passed":false},{"actual":[176,2,24],"check":"repair check: leftover basis","expected":[176,2,24],"passed":true},{"actual":[213,2,187],"check":"generated control 1","expected":[213,2,187],"passed":true},{"actual":[1440,10,60],"check":"generated control 2","expected":[1440,10,60],"passed":true},{"actual":[167,2,83],"check":"generated control 3","expected":[167,2,83],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"exact two skeins\", \"actual\": [400, 2, 200], \"expected\": [400, 2, 0], \"passed\": false}, {\"check\": \"with margin\", \"actual\": [1320, 11, 55], \"expected\": [1320, 11, 55], \"passed\": true}, {\"check\": \"zero swatch\", \"actual\": \"error: swatch\", \"expected\": \"error: swatch\", \"passed\": true}, {\"check\": \"regression: leftover basis\", \"actual\": [8800, 22, 400], \"expected\": [8800, 22, 0], \"passed\": false}, {\"check\": \"repair check: leftover basis\", \"actual\": [176, 2, 24], \"expected\": [176, 2, 24], \"passed\": true}, {\"check\": \"generated control 1\", \"actual\": [213, 2, 187], \"expected\": [213, 2, 187], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [1440, 10, 60], \"expected\": [1440, 10, 60], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [167, 2, 83], \"expected\": [167, 2, 83], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}