FAILURE MAP
← Case archive

FA-6126 / Polynomial arithmetic / Open access

Polynomial degree trailing zeroes · case 01

Storage length is mistaken for the highest nonzero degree.

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

ROOT CAUSE

Storage length is mistaken for the highest nonzero degree.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return max((i for i,c in enumerate(coeff) if c),default=-1)

Unsuccessful approach: The lowest nonzero degree is selected instead.

Case contract

Integer coefficients in ascending power order and integer evaluation bounds; missing high-degree coefficients are zero. Rational outputs are reduced Fraction strings; the zero-polynomial degree is -1. Polynomial degree trailing zeroes. Exact operational definition: max((i for i,c in enumerate(coeff) if c),default=-1)

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Polynomial arithmetic results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(coeff):
    return len(coeff)-1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 0, 0],)', solve(*([1, 2, 0, 0],)), 1)
check('fixture 2: ([0, 0],)', solve(*([0, 0],)), -1)
check('fixture 3: ([],)', solve(*([],)), -1)
check('fixture 4: ([0, 0, 3],)', solve(*([0, 0, 3],)), 2)
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
fixture 1: ([1, 2, 0, 0],)31Failed
fixture 2: ([0, 0],)1-1Failed
fixture 3: ([],)-1-1Passed
fixture 4: ([0, 0, 3],)22Passed

SHA-256 / fdef1b221457bf2a700ee2e444683b15c550c0e459212fc5f841bcbbc4ca69bd

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(coeff):
    return next((i for i,c in enumerate(coeff) if c),-1)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 0, 0],)', solve(*([1, 2, 0, 0],)), 1)
check('fixture 2: ([0, 0],)', solve(*([0, 0],)), -1)
check('fixture 3: ([],)', solve(*([],)), -1)
check('fixture 4: ([0, 0, 3],)', solve(*([0, 0, 3],)), 2)
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
fixture 1: ([1, 2, 0, 0],)01Failed
fixture 2: ([0, 0],)-1-1Passed
fixture 3: ([],)-1-1Passed
fixture 4: ([0, 0, 3],)22Passed

SHA-256 / e41c0b1cf3c94da911b074af494f6695214a96c6cae2d2f1055816773d2e0df9

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(coeff):
    return max((i for i,c in enumerate(coeff) if c),default=-1)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 0, 0],)', solve(*([1, 2, 0, 0],)), 1)
check('fixture 2: ([0, 0],)', solve(*([0, 0],)), -1)
check('fixture 3: ([],)', solve(*([],)), -1)
check('fixture 4: ([0, 0, 3],)', solve(*([0, 0, 3],)), 2)
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
fixture 1: ([1, 2, 0, 0],)11Passed
fixture 2: ([0, 0],)-1-1Passed
fixture 3: ([],)-1-1Passed
fixture 4: ([0, 0, 3],)22Passed

SHA-256 / ffecc320ffd2e70740b97ebeb270acf3e974e38fb9b340c0692271ab923a6e40

Verification & scope

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

Case digest / e8785acdf5467ede7fd995bb07b7a450c9627c05f749f89d0f66167d764af664