FAILURE MAP
← Case archive

FA-4101 / Sequence semantics / Open access

Duplicate occurrences exclude first · case 01

The operation returns a result or retained state that violates this contract: Return each repeated occurrence after its first appearance, in occurrence order.

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

ROOT CAUSE

Selecting all members with repeated values incorrectly includes their first occurrence.

VERIFIED REPAIR

Return each repeated occurrence after its first appearance, in occurrence order.

Unsuccessful approach: Distinct-value deduplication loses third and later repeated occurrences.

Case contract

Return each repeated occurrence after its first appearance, in occurrence order. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

Why this case matters

A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x, y=None):
    return [v for v in x if x.count(v)>1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [])
check('two distinct elements', solve(['a', 'b']), [])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), ['b'])
check('third occurrence remains', solve(['a','a','a']), ['a','a'])
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
empty collection[][]Passed
singleton collection[][]Passed
two distinct elements[][]Passed
nonadjacent duplicate and unsorted order['b', 'b']['b']Failed
third occurrence remains['a', 'a', 'a']['a', 'a']Failed

SHA-256 / ea2d5bc26feea7384575c319452b519b0e19548c92961d8a2e528854475b1dfe

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x, y=None):
    return list(dict.fromkeys(v for v in x if x.count(v)>1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [])
check('two distinct elements', solve(['a', 'b']), [])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), ['b'])
check('third occurrence remains', solve(['a','a','a']), ['a','a'])
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
empty collection[][]Passed
singleton collection[][]Passed
two distinct elements[][]Passed
nonadjacent duplicate and unsorted order['b']['b']Passed
third occurrence remains['a']['a', 'a']Failed

SHA-256 / 6472bcf3ff06bd8beea271c274da9ec4b252837217ba8bba2e766eeb29a35457

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x, y=None):
    return [v for i,v in enumerate(x) if v in x[:i]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty collection', solve([]), [])
check('singleton collection', solve(['a']), [])
check('two distinct elements', solve(['a', 'b']), [])
check('nonadjacent duplicate and unsorted order', solve(['b', 'a', 'b', 'c']), ['b'])
check('third occurrence remains', solve(['a','a','a']), ['a','a'])
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
empty collection[][]Passed
singleton collection[][]Passed
two distinct elements[][]Passed
nonadjacent duplicate and unsorted order['b']['b']Passed
third occurrence remains['a', 'a']['a', 'a']Passed

SHA-256 / 88bc1012cfc927816fc499755e72a018d33dab588e99aad10d66950eb95150ea

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

Case digest / 3d8bc81a4ef004360a8c28e4ae681d328d0e906dea2ba60fc63bc7ce660cf6ce