FA-5751 / Combinatorics / Open access
Balanced ternary digit value · case 01
Most-significant-first balanced ternary is evaluated backwards.
ROOT CAUSE
Most-significant-first balanced ternary is evaluated backwards.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sum(d*3**i for i,d in enumerate(reversed(digits)))
Unsuccessful approach: A binary place value is used for a ternary numeral.
Case contract
Nonnegative integer counts. Permutation and combination counts are zero when a requested selection exceeds the available objects. Shape sizes satisfy the preconditions stated below. digits is most-significant-first and each digit is -1, 0, or 1; return its signed integer value. Empty digits have value zero. Exact operational definition: sum(d*3**i for i,d in enumerate(reversed(digits)))
Why this case matters
Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Combinatorics 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(digits):
return sum(d*3**i for i,d in enumerate(digits))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 0, -1],)', solve(*([1, 0, -1],)), 8)
check('fixture 2: ([-1, 1],)', solve(*([-1, 1],)), -2)
check('fixture 3: ([0],)', solve(*([0],)), 0)
check('fixture 4: ([1, 1, 1],)', solve(*([1, 1, 1],)), 13)
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 |
|---|---|---|---|
| fixture 1: ([1, 0, -1],) | -8 | 8 | Failed |
| fixture 2: ([-1, 1],) | 2 | -2 | Failed |
| fixture 3: ([0],) | 0 | 0 | Passed |
| fixture 4: ([1, 1, 1],) | 13 | 13 | Passed |
SHA-256 / 39c668ed9a94215f5e46b0e41d0d27a7eaf54af4f593d1829bd7f4884969613b
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(digits):
return sum(d*2**i for i,d in enumerate(reversed(digits)))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 0, -1],)', solve(*([1, 0, -1],)), 8)
check('fixture 2: ([-1, 1],)', solve(*([-1, 1],)), -2)
check('fixture 3: ([0],)', solve(*([0],)), 0)
check('fixture 4: ([1, 1, 1],)', solve(*([1, 1, 1],)), 13)
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 |
|---|---|---|---|
| fixture 1: ([1, 0, -1],) | 3 | 8 | Failed |
| fixture 2: ([-1, 1],) | -1 | -2 | Failed |
| fixture 3: ([0],) | 0 | 0 | Passed |
| fixture 4: ([1, 1, 1],) | 7 | 13 | Failed |
SHA-256 / ace298e6fb5e69f9abe0c99658e77ebbdd612b0eab86f2fcfb922dbd7016749e
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(digits):
return sum(d*3**i for i,d in enumerate(reversed(digits)))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 0, -1],)', solve(*([1, 0, -1],)), 8)
check('fixture 2: ([-1, 1],)', solve(*([-1, 1],)), -2)
check('fixture 3: ([0],)', solve(*([0],)), 0)
check('fixture 4: ([1, 1, 1],)', solve(*([1, 1, 1],)), 13)
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 |
|---|---|---|---|
| fixture 1: ([1, 0, -1],) | 8 | 8 | Passed |
| fixture 2: ([-1, 1],) | -2 | -2 | Passed |
| fixture 3: ([0],) | 0 | 0 | Passed |
| fixture 4: ([1, 1, 1],) | 13 | 13 | Passed |
SHA-256 / 34e0c475e7a035828182c39fdcd2b5655f4788098f9d15d7d2d7a8828e700b90
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:53.355029+00:00.
Case digest / 6a9d1ff96d9c19745a380503893154a373dbabe588e2315c7a31686fea46249a