FAILURE MAP
← Case archive

FA-79726 / Barcode symbology encoding / Open access

EAN-2 parity patterns for remainders 1 and 2 are swapped · case 01

Issue numbers with value mod 4 of 1 or 2 fail the add-on parity check at the till.

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

ROOT CAUSE

The table maps remainder 1 to GL and 2 to LG.

VERIFIED REPAIR

Remainder 1 is LG and remainder 2 is GL.

Unsuccessful approach: Reversing the table swaps all-L and all-G as well.

Case contract

Encode a two-digit EAN-2 add-on (issue number) as modules: start 1011, first character, separator 01, second character. The parity pattern is chosen by the two-digit value modulo 4: 0 LL, 1 LG, 2 GL, 3 GG, using the EAN L and G code sets. Invalid input 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(s):
    if len(s) != 2 or not all(c in '0123456789' for c in s):
        return None
    L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']
    G = ['0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
    par = ['LL', 'GL', 'LG', 'GG'][int(s) % 4]
    a = (L if par[0] == 'L' else G)[int(s[0])]
    b = (L if par[1] == 'L' else G)[int(s[1])]
    return '1011' + a + '01' + b
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['73', '10110111011010100001'], ['55', '10110111001010111001'], ['7', None], ['123', None], ['a1', None], ['42', '10110011101010010011'], ['30', '10110100001010001101'], ['33', '10110111101010100001']], [['98', '10110010111010110111'], ['24', '10110010011010100011'], ['123', None], ['a1', None], ['7', None], ['54', '10110111001010100011'], ['29', '10110010011010010111'], ['37', '10110111101010010001']], [['38', '10110100001010110111'], ['07', '10110100111010010001'], ['a1', None], ['7', None], ['123', None], ['17', '10110011001010010001'], ['01', '10110001101010110011'], ['22', '10110011011010010011']], [['66', '10110000101010101111'], ['76', '10110111011010101111'], ['7', None], ['123', None], ['a1', None], ['13', '10110011001010100001'], ['78', '10110010001010110111'], ['53', '10110110001010100001']], [['86', '10110001001010101111'], ['43', '10110011101010100001'], ['123', None], ['a1', None], ['7', None], ['81', '10110110111010110011'], ['29', '10110010011010010111'], ['30', '10110100001010001101']]]
labels = ["regression: parity table order", "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: parity table order 01011001000101011110110110111011010100001Failed
repair trap 11011011100101011100110110111001010111001Passed
combined fault 2NoneNonePassed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 51011010001101001101110110011101010010011Failed
boundary 61011011110101010011110110100001010001101Failed
control 71011010000101011110110110111101010100001Failed

SHA-256 / 3b7b9ffb04bf3fc91edc6efb34f24943cc0c43b34591d2ebbd8460dec2f4cad9

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(s):
    if len(s) != 2 or not all(c in '0123456789' for c in s):
        return None
    L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']
    G = ['0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
    par = ['GG', 'LG', 'GL', 'LL'][int(s) % 4]
    a = (L if par[0] == 'L' else G)[int(s[0])]
    b = (L if par[1] == 'L' else G)[int(s[1])]
    return '1011' + a + '01' + b
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['73', '10110111011010100001'], ['55', '10110111001010111001'], ['7', None], ['123', None], ['a1', None], ['42', '10110011101010010011'], ['30', '10110100001010001101'], ['33', '10110111101010100001']], [['98', '10110010111010110111'], ['24', '10110010011010100011'], ['123', None], ['a1', None], ['7', None], ['54', '10110111001010100011'], ['29', '10110010011010010111'], ['37', '10110111101010010001']], [['38', '10110100001010110111'], ['07', '10110100111010010001'], ['a1', None], ['7', None], ['123', None], ['17', '10110011001010010001'], ['01', '10110001101010110011'], ['22', '10110011011010010011']], [['66', '10110000101010101111'], ['76', '10110111011010101111'], ['7', None], ['123', None], ['a1', None], ['13', '10110011001010100001'], ['78', '10110010001010110111'], ['53', '10110110001010100001']], [['86', '10110001001010101111'], ['43', '10110011101010100001'], ['123', None], ['a1', None], ['7', None], ['81', '10110110111010110011'], ['29', '10110010011010010111'], ['30', '10110100001010001101']]]
labels = ["regression: parity table order", "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: parity table order 01011011101101010000110110111011010100001Passed
repair trap 11011011000101011000110110111001010111001Failed
combined fault 2NoneNonePassed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 51011001110101001001110110011101010010011Passed
boundary 61011010000101000110110110100001010001101Passed
control 71011011110101010000110110111101010100001Passed

SHA-256 / 1ed12fc7b1ebafe4e69581074531d84432199153d8e52f519cb4136035dedb7d

3 / The verified repair

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

N = 1
observations = []
def solve(s):
    if len(s) != 2 or not all(c in '0123456789' for c in s):
        return None
    L = ['0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011']
    G = ['0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
    par = ['LL', 'LG', 'GL', 'GG'][int(s) % 4]
    a = (L if par[0] == 'L' else G)[int(s[0])]
    b = (L if par[1] == 'L' else G)[int(s[1])]
    return '1011' + a + '01' + b
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['73', '10110111011010100001'], ['55', '10110111001010111001'], ['7', None], ['123', None], ['a1', None], ['42', '10110011101010010011'], ['30', '10110100001010001101'], ['33', '10110111101010100001']], [['98', '10110010111010110111'], ['24', '10110010011010100011'], ['123', None], ['a1', None], ['7', None], ['54', '10110111001010100011'], ['29', '10110010011010010111'], ['37', '10110111101010010001']], [['38', '10110100001010110111'], ['07', '10110100111010010001'], ['a1', None], ['7', None], ['123', None], ['17', '10110011001010010001'], ['01', '10110001101010110011'], ['22', '10110011011010010011']], [['66', '10110000101010101111'], ['76', '10110111011010101111'], ['7', None], ['123', None], ['a1', None], ['13', '10110011001010100001'], ['78', '10110010001010110111'], ['53', '10110110001010100001']], [['86', '10110001001010101111'], ['43', '10110011101010100001'], ['123', None], ['a1', None], ['7', None], ['81', '10110110111010110011'], ['29', '10110010011010010111'], ['30', '10110100001010001101']]]
labels = ["regression: parity table order", "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: parity table order 01011011101101010000110110111011010100001Passed
repair trap 11011011100101011100110110111001010111001Passed
combined fault 2NoneNonePassed
control 3NoneNonePassed
control 4NoneNonePassed
boundary 51011001110101001001110110011101010010011Passed
boundary 61011010000101000110110110100001010001101Passed
control 71011011110101010000110110111101010100001Passed

SHA-256 / e458e2b7c71c645810b518a51229942f4848b7204ffc20cc8af03a4e6185a5e2

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

Case digest / 9ad1b63031a8d0dfd09b680f30211fc7103becffeb393645a9f0d4f3e47ad371