FAILURE MAP
← Case archive

FA-3946 / Text processing / Open access

A common prefix routine chooses the shortest whole input · case 01

A common prefix routine chooses the shortest whole input.

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

ROOT CAUSE

The implementation applies an operation whose text or grammar semantics violate this contract: Find the longest character prefix shared by every input string; empty input gives empty string.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Find the longest character prefix shared by every input string; empty input gives empty string.

Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.

Case contract

Find the longest character prefix shared by every input string; empty input gives empty string.

Why this case matters

A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return min(x,key=len) if x else ''
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(['flower', 'flow', 'flight']), 'fl')
check('boundary 2', solve(['abc', 'abd']), 'ab')
check('boundary 3', solve([]), '')
check('boundary 4', solve(['x', 'xyz']), 'x')
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
boundary 1flowflFailed
boundary 2abcabFailed
boundary 3Passed
boundary 4xxPassed

SHA-256 / 2586eb945e98062ec6d743009fd37e82ffb468d35d018323c30c1517d8c1e029

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x[0] if x and all(v.startswith(x[0]) for v in x) else ''
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(['flower', 'flow', 'flight']), 'fl')
check('boundary 2', solve(['abc', 'abd']), 'ab')
check('boundary 3', solve([]), '')
check('boundary 4', solve(['x', 'xyz']), 'x')
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
boundary 1flFailed
boundary 2abFailed
boundary 3Passed
boundary 4xxPassed

SHA-256 / 648fa9b6cbb1d557caad4ed7d586bf10ea8717d30eaf0606a39bd575281850d0

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        if not x: return ''
        a,b=min(x),max(x)
        i=0
        while i<min(len(a),len(b)) and a[i]==b[i]: i+=1
        return a[:i]
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(['flower', 'flow', 'flight']), 'fl')
check('boundary 2', solve(['abc', 'abd']), 'ab')
check('boundary 3', solve([]), '')
check('boundary 4', solve(['x', 'xyz']), 'x')
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
boundary 1flflPassed
boundary 2ababPassed
boundary 3Passed
boundary 4xxPassed

SHA-256 / f35fa18ad9fb9d68fe7ca5f4534fafcab26d420710c96bc123ed4e367713ca26

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

Case digest / 9a732e38580e540320d5759d8ad5c72cecd7a66d4746f7e6be8f33cd7f4d5bda