FAILURE MAP
← Case archive

FA-79351 / Barcode symbology encoding / Open access

EAN-13 left half encodes the implied leading digit · case 01

The encoded symbol repeats the first digit and drops the seventh.

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

ROOT CAUSE

The left half is indexed from 0, but the first digit is carried by the parity pattern, not by modules.

VERIFIED REPAIR

Encode digits 2 through 7 (indices 1..6) in the left half.

Unsuccessful approach: Special-casing only the first position still encodes the leading digit instead of the second.

Case contract

Encode a 13-character string of ASCII digits (the check digit is taken as given, not verified) as the 95-module EAN-13 pattern: start guard 101, six left digits in L or G sets chosen by the parity row of the leading digit, centre guard 01010, six right digits in the R set, end guard 101. R is the bitwise complement of L and G is R reversed. Anything else returns None.

Why this case matters

Retail, logistics, pharmacy and document workflows depend on encoders that produce exactly the module pattern, code-set switches, separators and quiet zones scanners expect; one misplaced module or separator makes a label unreadable or, worse, scan as different data.

1 / The failure

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

N = 1
observations = []
def solve(code):
    if len(code) != 13 or not all(ch in '0123456789' for ch in code):
        return None
    L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']
    R = [''.join('1' if b == '0' else '0' for b in p) for p in L]
    G = [p[::-1] for p in R]
    parity = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL']
    pat = parity[int(code[0])]
    left = ''.join((L if pat[i] == 'L' else G)[int(code[i])] for i in range(6))
    right = ''.join(R[int(ch)] for ch in code[7:])
    return '101' + left + '01010' + right + '101'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['5569719879594', '10101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101'], ['8708854500750', '10101110110100111011011100010010111001010001101010100111011100101110010100010010011101110010101'], ['3510413208309', '10101100010011001010011100111010110011011110101010110110011100101001000100001011100101110100101'], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['5564657964331', '10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101']], [['0777861705172', '10101110110111011011101101101110101111001100101010100010011100101001110110011010001001101100101'], ['4641860725337', '10101011110011101001100101101110000101010011101010100010011011001001110100001010000101000100101'], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['', None], ['4006381333931', None], ['6141838617595', '10100110010011101011001100010010111101011011101010101000011001101000100100111011101001001110101']], [['3716511088176', '10101110110011001000010101110010110011001100101010111001010010001001000110011010001001010000101'], ['7062168881750', '10100011010000101001001101100110101111000100101010100100010010001100110100010010011101110010101'], ['123456789012', None], ['12345678901234', None], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['6191360813603', '10100110010010111011001101000010101111000110101010100100011001101000010101000011100101000010101']], [['1986892142891', '10100010110110111000010101101110010111001101101010110011010111001101100100100011101001100110101'], ['6274612745694', '10100100110010001001110100001010011001001001101010100010010111001001110101000011101001011100101'], ['12345678901234', None], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['6346382380419', '10101111010011101000010101000010110111001001101010100001010010001110010101110011001101110100101']], [['8746102916553', '10101110110011101010111101100110100111001001101010111010011001101010000100111010011101000010101'], ['5334300159167', '10101111010100001001110101111010001101010011101010110011010011101110100110011010100001000100101'], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['3842111701831', '10101101110100011001101101100110110011001100101010100010011100101100110100100010000101100110101']]]
labels = ["regression: left half digit index", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], 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
regression: left half digit index 01010110001011100100001010001011011101101100110101010010001000100111010010011101110100101110010110101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101Failed
repair trap 11010110111001000100011010001001000100101100010101010011101110010111001010001001001110111001010110101110110100111011011100010010111001010001101010100111011100101110010100010010011101110010101Failed
combined fault 21010111101011000101100110100111001110100110010101011011001110010100100010000101110010111010010110101100010011001010011100111010110011011110101010110110011100101001000100001011100101110100101Failed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6NoneNonePassed
control 71010110001011100100001010100011010111101110010101011101001010000101110010000101000010110011010110101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101Failed

SHA-256 / bcdf8b68ed0ac359ce3afed6c4e7481ae1281db897a465a7a2f896bd4023a002

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(code):
    if len(code) != 13 or not all(ch in '0123456789' for ch in code):
        return None
    L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']
    R = [''.join('1' if b == '0' else '0' for b in p) for p in L]
    G = [p[::-1] for p in R]
    parity = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL']
    pat = parity[int(code[0])]
    left = ''.join((L if pat[i] == 'L' else G)[int(code[1 + i]) if i else int(code[0])] for i in range(6))
    right = ''.join(R[int(ch)] for ch in code[7:])
    return '101' + left + '01010' + right + '101'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['5569719879594', '10101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101'], ['8708854500750', '10101110110100111011011100010010111001010001101010100111011100101110010100010010011101110010101'], ['3510413208309', '10101100010011001010011100111010110011011110101010110110011100101001000100001011100101110100101'], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['5564657964331', '10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101']], [['0777861705172', '10101110110111011011101101101110101111001100101010100010011100101001110110011010001001101100101'], ['4641860725337', '10101011110011101001100101101110000101010011101010100010011011001001110100001010000101000100101'], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['', None], ['4006381333931', None], ['6141838617595', '10100110010011101011001100010010111101011011101010101000011001101000100100111011101001001110101']], [['3716511088176', '10101110110011001000010101110010110011001100101010111001010010001001000110011010001001010000101'], ['7062168881750', '10100011010000101001001101100110101111000100101010100100010010001100110100010010011101110010101'], ['123456789012', None], ['12345678901234', None], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['6191360813603', '10100110010010111011001101000010101111000110101010100100011001101000010101000011100101000010101']], [['1986892142891', '10100010110110111000010101101110010111001101101010110011010111001101100100100011101001100110101'], ['6274612745694', '10100100110010001001110100001010011001001001101010100010010111001001110101000011101001011100101'], ['12345678901234', None], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['6346382380419', '10101111010011101000010101000010110111001001101010100001010010001110010101110011001101110100101']], [['8746102916553', '10101110110011101010111101100110100111001001101010111010011001101010000100111010011101000010101'], ['5334300159167', '10101111010100001001110101111010001101010011101010110011010011101110100110011010100001000100101'], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['3842111701831', '10101101110100011001101101100110110011001100101010100010011100101100110100100010000101100110101']]]
labels = ["regression: left half digit index", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], 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
regression: left half digit index 01010110001000010100101110111011001100100101110101010010001000100111010010011101110100101110010110101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101Passed
repair trap 11010110111010011101101110001001011100101000110101010011101110010111001010001001001110111001010110101110110100111011011100010010111001010001101010100111011100101110010100010010011101110010101Failed
combined fault 21010111101001100101001110011101011001101111010101011011001110010100100010000101110010111010010110101100010011001010011100111010110011011110101010110110011100101001000100001011100101110100101Failed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6NoneNonePassed
control 71010110001000010100111010101111011000100100010101011101001010000101110010000101000010110011010110101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101Passed

SHA-256 / 0f58986fced23f481c2093b53597b0ad98bf6731880bd9d3fe6d1a2ce7a49917

3 / The verified repair

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

N = 1
observations = []
def solve(code):
    if len(code) != 13 or not all(ch in '0123456789' for ch in code):
        return None
    L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']
    R = [''.join('1' if b == '0' else '0' for b in p) for p in L]
    G = [p[::-1] for p in R]
    parity = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL']
    pat = parity[int(code[0])]
    left = ''.join((L if pat[i] == 'L' else G)[int(code[1 + i])] for i in range(6))
    right = ''.join(R[int(ch)] for ch in code[7:])
    return '101' + left + '01010' + right + '101'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['5569719879594', '10101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101'], ['8708854500750', '10101110110100111011011100010010111001010001101010100111011100101110010100010010011101110010101'], ['3510413208309', '10101100010011001010011100111010110011011110101010110110011100101001000100001011100101110100101'], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['5564657964331', '10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101']], [['0777861705172', '10101110110111011011101101101110101111001100101010100010011100101001110110011010001001101100101'], ['4641860725337', '10101011110011101001100101101110000101010011101010100010011011001001110100001010000101000100101'], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['', None], ['4006381333931', None], ['6141838617595', '10100110010011101011001100010010111101011011101010101000011001101000100100111011101001001110101']], [['3716511088176', '10101110110011001000010101110010110011001100101010111001010010001001000110011010001001010000101'], ['7062168881750', '10100011010000101001001101100110101111000100101010100100010010001100110100010010011101110010101'], ['123456789012', None], ['12345678901234', None], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['6191360813603', '10100110010010111011001101000010101111000110101010100100011001101000010101000011100101000010101']], [['1986892142891', '10100010110110111000010101101110010111001101101010110011010111001101100100100011101001100110101'], ['6274612745694', '10100100110010001001110100001010011001001001101010100010010111001001110101000011101001011100101'], ['12345678901234', None], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['6346382380419', '10101111010011101000010101000010110111001001101010100001010010001110010101110011001101110100101']], [['8746102916553', '10101110110011101010111101100110100111001001101010111010011001101010000100111010011101000010101'], ['5334300159167', '10101111010100001001110101111010001101010011101010110011010011101110100110011010100001000100101'], ['', None], ['4006381333931', None], ['12345678901٣2', None], ['123456789012', None], ['12345678901234', None], ['3842111701831', '10101101110100011001101101100110110011001100101010100010011100101100110100100010000101100110101']]]
labels = ["regression: left half digit index", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], 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
regression: left half digit index 01010110001000010100101110111011001100100101110101010010001000100111010010011101110100101110010110101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101Passed
repair trap 11010111011010011101101110001001011100101000110101010011101110010111001010001001001110111001010110101110110100111011011100010010111001010001101010100111011100101110010100010010011101110010101Passed
combined fault 21010110001001100101001110011101011001101111010101011011001110010100100010000101110010111010010110101100010011001010011100111010110011011110101010110110011100101001000100001011100101110100101Passed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6NoneNonePassed
control 71010110001000010100111010101111011000100100010101011101001010000101110010000101000010110011010110101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101Passed

SHA-256 / 2088b5f5dfec49f436ff810986a3a5664770d1bed70b52a41fd86e10e3fbd729

Verification & scope

A deterministic bounded teaching model with a stipulated contract; it makes no claim of conformance to any published specification. 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:49:43.801740+00:00.

Case digest / 6900ea3b1448b2335621f503d430692c00a465acc8a9e7143802fea6431af91f