FAILURE MAP
← Case archive

FA-15291 / Numerics / Open access

Josephus elimination order: ring label origin · case 01

The exact josephus elimination order result violates the stated contract at ring label origin.

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

ROOT CAUSE

The ring label origin step uses list(range(1,n+1)) instead of list(range(n)).

VERIFIED REPAIR

Use list(range(n)) at the ring label origin step.

Unsuccessful approach: The partial repair list(range(n))[::-1] still violates the ring label origin invariant.

Case contract

Input [n,k,start], n>0 k>0 0<=start<n; return removal order counting current position as one.

Why this case matters

Exact discrete arithmetic with observable algorithmic state; no floating point approximation is used.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    n,k,start=x
    ring=list(range(1,n+1));index=start;out=[]
    for _ in range(n):
     if not ring:break
     index=(index+k-1)%len(ring)
     out.append(ring.pop(index))
     index=index
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 1, 0], [0]), ([2, 1, 0], [0, 1]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([1, 2, 0], [0]), ([1, 3, 0], [0]), ([1, 4, 0], [0]), ([1, 5, 0], [0]), ([1, 6, 0], [0])], [([1, 2, 0], [0]), ([2, 2, 1], [0, 1]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([2, 5, 1], [1, 0]), ([2, 6, 0], [1, 0]), ([2, 6, 1], [0, 1]), ([2, 7, 0], [0, 1])], [([1, 3, 0], [0]), ([2, 4, 0], [1, 0]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([3, 4, 1], [1, 0, 2]), ([3, 4, 2], [2, 1, 0]), ([3, 5, 0], [1, 2, 0]), ([3, 5, 1], [2, 0, 1])], [([1, 4, 0], [0]), ([2, 5, 1], [1, 0]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([4, 1, 3], [3, 0, 1, 2]), ([4, 2, 0], [1, 3, 2, 0]), ([4, 2, 1], [2, 0, 3, 1]), ([4, 2, 2], [3, 1, 0, 2])], [([1, 5, 0], [0]), ([2, 7, 0], [0, 1]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([4, 6, 0], [1, 0, 3, 2]), ([4, 6, 1], [2, 1, 0, 3]), ([4, 6, 2], [3, 2, 1, 0]), ([4, 6, 3], [0, 3, 2, 1])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, solve(args), expected)
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
explicit oracle 0[1][0]Failed
explicit oracle 1[1, 2][0, 1]Failed
explicit oracle 2[7, 4, 2, 1, 3, 6, 10, 9, 5, 11, 8][6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]Failed
explicit oracle 3[1][0]Failed
explicit oracle 4[1][0]Failed
explicit oracle 5[1][0]Failed
explicit oracle 6[1][0]Failed
explicit oracle 7[1][0]Failed

SHA-256 / 95f6041e006f430cdb62422fa2475aef75b5b149f5cc15e68a1320fc2bccd432

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    n,k,start=x
    ring=list(range(n))[::-1];index=start;out=[]
    for _ in range(n):
     if not ring:break
     index=(index+k-1)%len(ring)
     out.append(ring.pop(index))
     index=index
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 1, 0], [0]), ([2, 1, 0], [0, 1]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([1, 2, 0], [0]), ([1, 3, 0], [0]), ([1, 4, 0], [0]), ([1, 5, 0], [0]), ([1, 6, 0], [0])], [([1, 2, 0], [0]), ([2, 2, 1], [0, 1]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([2, 5, 1], [1, 0]), ([2, 6, 0], [1, 0]), ([2, 6, 1], [0, 1]), ([2, 7, 0], [0, 1])], [([1, 3, 0], [0]), ([2, 4, 0], [1, 0]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([3, 4, 1], [1, 0, 2]), ([3, 4, 2], [2, 1, 0]), ([3, 5, 0], [1, 2, 0]), ([3, 5, 1], [2, 0, 1])], [([1, 4, 0], [0]), ([2, 5, 1], [1, 0]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([4, 1, 3], [3, 0, 1, 2]), ([4, 2, 0], [1, 3, 2, 0]), ([4, 2, 1], [2, 0, 3, 1]), ([4, 2, 2], [3, 1, 0, 2])], [([1, 5, 0], [0]), ([2, 7, 0], [0, 1]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([4, 6, 0], [1, 0, 3, 2]), ([4, 6, 1], [2, 1, 0, 3]), ([4, 6, 2], [3, 2, 1, 0]), ([4, 6, 3], [0, 3, 2, 1])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, solve(args), expected)
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
explicit oracle 0[0][0]Passed
explicit oracle 1[1, 0][0, 1]Failed
explicit oracle 2[4, 7, 9, 10, 8, 5, 1, 2, 6, 0, 3][6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]Failed
explicit oracle 3[0][0]Passed
explicit oracle 4[0][0]Passed
explicit oracle 5[0][0]Passed
explicit oracle 6[0][0]Passed
explicit oracle 7[0][0]Passed

SHA-256 / 8742184061b61fd14cc4171a15fe6850e2957810186766f599380773744ddfaf

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    n,k,start=x
    ring=list(range(n));index=start;out=[]
    for _ in range(n):
     if not ring:break
     index=(index+k-1)%len(ring)
     out.append(ring.pop(index))
     index=index
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 1, 0], [0]), ([2, 1, 0], [0, 1]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([1, 2, 0], [0]), ([1, 3, 0], [0]), ([1, 4, 0], [0]), ([1, 5, 0], [0]), ([1, 6, 0], [0])], [([1, 2, 0], [0]), ([2, 2, 1], [0, 1]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([2, 5, 1], [1, 0]), ([2, 6, 0], [1, 0]), ([2, 6, 1], [0, 1]), ([2, 7, 0], [0, 1])], [([1, 3, 0], [0]), ([2, 4, 0], [1, 0]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([3, 4, 1], [1, 0, 2]), ([3, 4, 2], [2, 1, 0]), ([3, 5, 0], [1, 2, 0]), ([3, 5, 1], [2, 0, 1])], [([1, 4, 0], [0]), ([2, 5, 1], [1, 0]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([4, 1, 3], [3, 0, 1, 2]), ([4, 2, 0], [1, 3, 2, 0]), ([4, 2, 1], [2, 0, 3, 1]), ([4, 2, 2], [3, 1, 0, 2])], [([1, 5, 0], [0]), ([2, 7, 0], [0, 1]), ([1, 1, 0], [0]), ([11, 8, 10], [6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]), ([4, 6, 0], [1, 0, 3, 2]), ([4, 6, 1], [2, 1, 0, 3]), ([4, 6, 2], [3, 2, 1, 0]), ([4, 6, 3], [0, 3, 2, 1])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, solve(args), expected)
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
explicit oracle 0[0][0]Passed
explicit oracle 1[0, 1][0, 1]Passed
explicit oracle 2[6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7][6, 3, 1, 0, 2, 5, 9, 8, 4, 10, 7]Passed
explicit oracle 3[0][0]Passed
explicit oracle 4[0][0]Passed
explicit oracle 5[0][0]Passed
explicit oracle 6[0][0]Passed
explicit oracle 7[0][0]Passed

SHA-256 / 684f5ec5a9c1710b4633cb8c18515ad09de39ffba736f42d7ff2f1d3eaf6f6c6

Verification & scope

A deterministic bounded teaching model. Inputs are restricted to the explicit contract; this is not a production algebra library. 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:39:25.292033+00:00.

Case digest / e7461fa5751273295fb59de7a7da823cd013e6c8ae7120b7556fcaa9eecff75c