FAILURE MAP
← Case archive

FA-5726 / Combinatorics / Open access

Nonadjacent subset count fixed size · case 01

Selections containing adjacent positions are not excluded.

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

ROOT CAUSE

Selections containing adjacent positions are not excluded.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return math.comb(n-k+1,k) if n-k+1>=k else 0

Unsuccessful approach: The gap compression consumes one unnecessary trailing gap.

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. Choose k positions among n linearly ordered positions with no adjacent selected pair. Exact operational definition: math.comb(n-k+1,k) if n-k+1>=k else 0

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, k):
    return math.comb(n,k)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (5, 2)', solve(*(5, 2)), 6)
check('fixture 2: (3, 2)', solve(*(3, 2)), 1)
check('fixture 3: (4, 3)', solve(*(4, 3)), 0)
check('fixture 4: (6, 0)', solve(*(6, 0)), 1)
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: (5, 2)106Failed
fixture 2: (3, 2)31Failed
fixture 3: (4, 3)40Failed
fixture 4: (6, 0)11Passed

SHA-256 / 3d858e3db838da710c277c8477f9d66628af652b65523c3ab410a0c3ed3fd72b

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, k):
    return math.comb(n-k,k) if n-k>=k else 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (5, 2)', solve(*(5, 2)), 6)
check('fixture 2: (3, 2)', solve(*(3, 2)), 1)
check('fixture 3: (4, 3)', solve(*(4, 3)), 0)
check('fixture 4: (6, 0)', solve(*(6, 0)), 1)
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: (5, 2)36Failed
fixture 2: (3, 2)01Failed
fixture 3: (4, 3)00Passed
fixture 4: (6, 0)11Passed

SHA-256 / 108d7004462be1e78688ad82907e519b7363c18949053096a4b537abb3e9d2ef

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, k):
    return math.comb(n-k+1,k) if n-k+1>=k else 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (5, 2)', solve(*(5, 2)), 6)
check('fixture 2: (3, 2)', solve(*(3, 2)), 1)
check('fixture 3: (4, 3)', solve(*(4, 3)), 0)
check('fixture 4: (6, 0)', solve(*(6, 0)), 1)
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: (5, 2)66Passed
fixture 2: (3, 2)11Passed
fixture 3: (4, 3)00Passed
fixture 4: (6, 0)11Passed

SHA-256 / e70cd8e272d539013a0409067d2721e5fb3c419a93336a65cdaeb83b6a78a7df

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

Case digest / 99b4ad6c94e2aea534f3fe5c060720471b81303d4f722dda165a3515a75f59ed