{"abstract":"Removing only the identity leaves permutations with other fixed points.","category":"Combinatorics","checks":4,"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))","evaluation_group":"model-d7cc59b1c0591837","failed_approach":"Subtracting one permutation per fixed point ignores overlaps.","family":"xn-derangement-count","id":"FA-5661","implementations":{"attempt":{"sha256":"fb62fbdc34f7e36102fa6a48d3d1587cdb4e36c7f4b1090718298992f54bd333","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport calendar\nimport statistics\nimport itertools\nfrom fractions import Fraction\nfrom datetime import date, datetime, timedelta, timezone\nfrom decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR\n\nN = 1\nobservations = []\ndef solve(n):\n    return math.factorial(n)-n\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('fixture 1: (0,)', solve(*(0,)), 1)\ncheck('fixture 2: (1,)', solve(*(1,)), 0)\ncheck('fixture 3: (3,)', solve(*(3,)), 2)\ncheck('fixture 4: (4,)', solve(*(4,)), 9)\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":"1bcf2b7967490ed167007a489a930f4fd9db36219c84795a06ee28e4b7362497","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport calendar\nimport statistics\nimport itertools\nfrom fractions import Fraction\nfrom datetime import date, datetime, timedelta, timezone\nfrom decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR\n\nN = 1\nobservations = []\ndef solve(n):\n    return math.factorial(n)-1\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('fixture 1: (0,)', solve(*(0,)), 1)\ncheck('fixture 2: (1,)', solve(*(1,)), 0)\ncheck('fixture 3: (3,)', solve(*(3,)), 2)\ncheck('fixture 4: (4,)', solve(*(4,)), 9)\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"},"fixed":{"sha256":"c27f468846734ba740e46a5d3cab7d8b4814eef0ca2671c6b3b997dc6a0f0a50","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport calendar\nimport statistics\nimport itertools\nfrom fractions import Fraction\nfrom datetime import date, datetime, timedelta, timezone\nfrom decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR\n\nN = 1\nobservations = []\ndef solve(n):\n    return sum((-1)**k * (math.factorial(n)//math.factorial(k)) for k in range(n+1))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('fixture 1: (0,)', solve(*(0,)), 1)\ncheck('fixture 2: (1,)', solve(*(1,)), 0)\ncheck('fixture 3: (3,)', solve(*(3,)), 2)\ncheck('fixture 4: (4,)', solve(*(4,)), 9)\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":" 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":"xn-derangement-count","generated_at":"2026-09-29T14:37:51.958999+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Combinatorics results depend on the stated convention.","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))","root_cause":"Removing only the identity leaves permutations with other fixed points.","sha256":"0341316210773e01fc3a39f748d766dcace524da7fda59680f368fe3e31719d6","title":"Derangement count · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.004,"exit_code":1,"observations":[{"actual":1,"check":"fixture 1: (0,)","expected":1,"passed":true},{"actual":0,"check":"fixture 2: (1,)","expected":0,"passed":true},{"actual":3,"check":"fixture 3: (3,)","expected":2,"passed":false},{"actual":20,"check":"fixture 4: (4,)","expected":9,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"fixture 1: (0,)\", \"actual\": 1, \"expected\": 1, \"passed\": true}, {\"check\": \"fixture 2: (1,)\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"fixture 3: (3,)\", \"actual\": 3, \"expected\": 2, \"passed\": false}, {\"check\": \"fixture 4: (4,)\", \"actual\": 20, \"expected\": 9, \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":45.011,"exit_code":1,"observations":[{"actual":0,"check":"fixture 1: (0,)","expected":1,"passed":false},{"actual":0,"check":"fixture 2: (1,)","expected":0,"passed":true},{"actual":5,"check":"fixture 3: (3,)","expected":2,"passed":false},{"actual":23,"check":"fixture 4: (4,)","expected":9,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"fixture 1: (0,)\", \"actual\": 0, \"expected\": 1, \"passed\": false}, {\"check\": \"fixture 2: (1,)\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"fixture 3: (3,)\", \"actual\": 5, \"expected\": 2, \"passed\": false}, {\"check\": \"fixture 4: (4,)\", \"actual\": 23, \"expected\": 9, \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":48.537,"exit_code":0,"observations":[{"actual":1,"check":"fixture 1: (0,)","expected":1,"passed":true},{"actual":0,"check":"fixture 2: (1,)","expected":0,"passed":true},{"actual":2,"check":"fixture 3: (3,)","expected":2,"passed":true},{"actual":9,"check":"fixture 4: (4,)","expected":9,"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"fixture 1: (0,)\", \"actual\": 1, \"expected\": 1, \"passed\": true}, {\"check\": \"fixture 2: (1,)\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"fixture 3: (3,)\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"fixture 4: (4,)\", \"actual\": 9, \"expected\": 9, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}