FA-5661 / Combinatorics / Open access
Derangement count · case 01
Removing only the identity leaves permutations with other fixed points.
ROOT CAUSE
Removing only the identity leaves permutations with other fixed points.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sum((-1)**k * (math.factorial(n)//math.factorial(k)) for k in range(n+1))
Unsuccessful approach: Subtracting one permutation per fixed point ignores overlaps.
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. Derangement count. Exact operational definition: sum((-1)**k * (math.factorial(n)//math.factorial(k)) for k in range(n+1))
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(n):
return math.factorial(n)-1
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 1)
check('fixture 2: (1,)', solve(*(1,)), 0)
check('fixture 3: (3,)', solve(*(3,)), 2)
check('fixture 4: (4,)', solve(*(4,)), 9)
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: (0,) | 0 | 1 | Failed |
| fixture 2: (1,) | 0 | 0 | Passed |
| fixture 3: (3,) | 5 | 2 | Failed |
| fixture 4: (4,) | 23 | 9 | Failed |
SHA-256 / 1bcf2b7967490ed167007a489a930f4fd9db36219c84795a06ee28e4b7362497
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(n):
return math.factorial(n)-n
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 1)
check('fixture 2: (1,)', solve(*(1,)), 0)
check('fixture 3: (3,)', solve(*(3,)), 2)
check('fixture 4: (4,)', solve(*(4,)), 9)
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: (0,) | 1 | 1 | Passed |
| fixture 2: (1,) | 0 | 0 | Passed |
| fixture 3: (3,) | 3 | 2 | Failed |
| fixture 4: (4,) | 20 | 9 | Failed |
SHA-256 / fb62fbdc34f7e36102fa6a48d3d1587cdb4e36c7f4b1090718298992f54bd333
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(n):
return sum((-1)**k * (math.factorial(n)//math.factorial(k)) for k in range(n+1))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 1)
check('fixture 2: (1,)', solve(*(1,)), 0)
check('fixture 3: (3,)', solve(*(3,)), 2)
check('fixture 4: (4,)', solve(*(4,)), 9)
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: (0,) | 1 | 1 | Passed |
| fixture 2: (1,) | 0 | 0 | Passed |
| fixture 3: (3,) | 2 | 2 | Passed |
| fixture 4: (4,) | 9 | 9 | Passed |
SHA-256 / c27f468846734ba740e46a5d3cab7d8b4814eef0ca2671c6b3b997dc6a0f0a50
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:51.958999+00:00.
Case digest / 0341316210773e01fc3a39f748d766dcace524da7fda59680f368fe3e31719d6