FA-79341 / Barcode symbology encoding / Open access
EAN-13 even-parity set is built by reversing the L codes · case 01
Labels whose leading digit is not 0 scan as invalid because every G-coded digit starts with a bar.
ROOT CAUSE
G codes are derived as the reverse of L instead of the reverse of R.
VERIFIED REPAIR
Build G as the reversal of the R set (the complement of L).
Unsuccessful approach: Using the complement alone reproduces R, which has the wrong edge colour on the left half.
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 L]
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'], ['3339552094472', '10101111010111101001011101110010111001001001101010111001011101001011100101110010001001101100101'], ['0589101449043', '10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101'], ['0520764340509', '10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101'], ['0361070698038', '10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101'], ['0631048571283', '10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101'], ['0728341592804', '10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101'], ['5564657964331', '10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101']], [['6141838617595', '10100110010011101011001100010010111101011011101010101000011001101000100100111011101001001110101'], ['4871645512712', '10101101110010001001100101011110011101011100101010100111011001101101100100010011001101101100101'], ['0413161406353', '10101000110011001011110100110010101111001100101010101110011100101010000100001010011101000010101'], ['0996615036371', '10100010110001011010111101011110011001011000101010111001010000101010000100001010001001100110101'], ['0140957899588', '10100110010100011000110100010110110001011101101010100100011101001110100100111010010001001000101'], ['0048824399021', '10100011010100011011011101101110010011010001101010100001011101001110100111001011011001100110101'], ['0855737200852', '10101101110110001011000101110110111101011101101010110110011100101110010100100010011101101100101'], ['8738417160350', '10101110110100001011011100111010110011011101101010110011010100001110010100001010011101110010101']], [['5108124299029', '10100110010100111000100100110010010011001110101010110110011101001110100111001011011001110100101'], ['5042066730924', '10100011010011101001101100011010101111000010101010100010010000101110010111010011011001011100101'], ['0896029493242', '10101101110001011010111100011010010011000101101010101110011101001000010110110010111001101100101'], ['0972213021163', '10100010110111011001001100100110011001011110101010111001011011001100110110011010100001000010101'], ['0520047957234', '10101100010010011000110100011010100011011101101010111010010011101000100110110010000101011100101'], ['0950847569915', '10100010110110001000110101101110100011011101101010100111010100001110100111010011001101001110101'], ['0134625611321', '10100110010111101010001101011110010011011000101010101000011001101100110100001011011001100110101'], ['3716511088176', '10101110110011001000010101110010110011001100101010111001010010001001000110011010001001010000101']], [['1986892142891', '10100010110110111000010101101110010111001101101010110011010111001101100100100011101001100110101'], ['2437732920288', '10101000110111101001000100100010111101001101101010111010011011001110010110110010010001001000101'], ['0153579089144', '10100110010110001011110101100010111011000101101010111001010010001110100110011010111001011100101'], ['0566009533015', '10101100010101111010111100011010001101000101101010100111010000101000010111001011001101001110101'], ['0705470945586', '10101110110001101011000101000110111011000110101010111010010111001001110100111010010001010000101'], ['0198354317235', '10100110010001011011011101111010110001010001101010100001011001101000100110110010000101001110101'], ['0864220800696', '10101101110101111010001100100110010011000110101010100100011100101110010101000011101001010000101'], ['6346382380419', '10101111010011101000010101000010110111001001101010100001010010001110010101110011001101110100101']], [['8746102916553', '10101110110011101010111101100110100111001001101010111010011001101010000100111010011101000010101'], ['4502760148617', '10101100010100111001001101110110000101010011101010110011010111001001000101000011001101000100101'], ['0633594108024', '10101011110111101011110101100010001011010001101010110011011100101001000111001011011001011100101'], ['0997696331503', '10100010110001011011101101011110001011010111101010100001010000101100110100111011100101000010101'], ['0384158562666', '10101111010110111010001100110010110001011011101010100111010100001101100101000010100001010000101'], ['0856254870212', '10101101110110001010111100100110110001010001101010100100010001001110010110110011001101101100101'], ['0408643503514', '10101000110001101011011101011110100011011110101010100111011100101000010100111011001101011100101'], ['3842111701831', '10101101110100011001101101100110110011001100101010100010011100101100110100100010000101100110101']]]
labels = ["regression: G code set derivation", "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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: G code set derivation 0 | 10101100011111010110100001110110011001110100001010100100010001001110100100111011101001011100101 | 10101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101 | Failed |
| repair trap 1 | 10101111010111101110100010001101000110001001101010111001011101001011100101110010001001101100101 | 10101111010111101001011101110010111001001001101010111001011101001011100101110010001001101100101 | Failed |
| combined fault 2 | 10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101 | 10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101 | Passed |
| control 3 | 10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101 | 10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101 | Passed |
| control 4 | 10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101 | 10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101 | Passed |
| boundary 5 | 10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101 | 10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101 | Passed |
| boundary 6 | 10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101 | 10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101 | Passed |
| control 7 | 10101100011111010110001001011110110001110111001010111010010100001011100100001010000101100110101 | 10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101 | Failed |
SHA-256 / c6371cc6557d2a71e73da98c7517a7ebfec52cde46abe76cb79dcfc3f62747ed
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 = [''.join('1' if b == '0' else '0' for b in p) for p in L]
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'], ['3339552094472', '10101111010111101001011101110010111001001001101010111001011101001011100101110010001001101100101'], ['0589101449043', '10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101'], ['0520764340509', '10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101'], ['0361070698038', '10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101'], ['0631048571283', '10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101'], ['0728341592804', '10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101'], ['5564657964331', '10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101']], [['6141838617595', '10100110010011101011001100010010111101011011101010101000011001101000100100111011101001001110101'], ['4871645512712', '10101101110010001001100101011110011101011100101010100111011001101101100100010011001101101100101'], ['0413161406353', '10101000110011001011110100110010101111001100101010101110011100101010000100001010011101000010101'], ['0996615036371', '10100010110001011010111101011110011001011000101010111001010000101010000100001010001001100110101'], ['0140957899588', '10100110010100011000110100010110110001011101101010100100011101001110100100111010010001001000101'], ['0048824399021', '10100011010100011011011101101110010011010001101010100001011101001110100111001011011001100110101'], ['0855737200852', '10101101110110001011000101110110111101011101101010110110011100101110010100100010011101101100101'], ['8738417160350', '10101110110100001011011100111010110011011101101010110011010100001110010100001010011101110010101']], [['5108124299029', '10100110010100111000100100110010010011001110101010110110011101001110100111001011011001110100101'], ['5042066730924', '10100011010011101001101100011010101111000010101010100010010000101110010111010011011001011100101'], ['0896029493242', '10101101110001011010111100011010010011000101101010101110011101001000010110110010111001101100101'], ['0972213021163', '10100010110111011001001100100110011001011110101010111001011011001100110110011010100001000010101'], ['0520047957234', '10101100010010011000110100011010100011011101101010111010010011101000100110110010000101011100101'], ['0950847569915', '10100010110110001000110101101110100011011101101010100111010100001110100111010011001101001110101'], ['0134625611321', '10100110010111101010001101011110010011011000101010101000011001101100110100001011011001100110101'], ['3716511088176', '10101110110011001000010101110010110011001100101010111001010010001001000110011010001001010000101']], [['1986892142891', '10100010110110111000010101101110010111001101101010110011010111001101100100100011101001100110101'], ['2437732920288', '10101000110111101001000100100010111101001101101010111010011011001110010110110010010001001000101'], ['0153579089144', '10100110010110001011110101100010111011000101101010111001010010001110100110011010111001011100101'], ['0566009533015', '10101100010101111010111100011010001101000101101010100111010000101000010111001011001101001110101'], ['0705470945586', '10101110110001101011000101000110111011000110101010111010010111001001110100111010010001010000101'], ['0198354317235', '10100110010001011011011101111010110001010001101010100001011001101000100110110010000101001110101'], ['0864220800696', '10101101110101111010001100100110010011000110101010100100011100101110010101000011101001010000101'], ['6346382380419', '10101111010011101000010101000010110111001001101010100001010010001110010101110011001101110100101']], [['8746102916553', '10101110110011101010111101100110100111001001101010111010011001101010000100111010011101000010101'], ['4502760148617', '10101100010100111001001101110110000101010011101010110011010111001001000101000011001101000100101'], ['0633594108024', '10101011110111101011110101100010001011010001101010110011011100101001000111001011011001011100101'], ['0997696331503', '10100010110001011011101101011110001011010111101010100001010000101100110100111011100101000010101'], ['0384158562666', '10101111010110111010001100110010110001011011101010100111010100001101100101000010100001010000101'], ['0856254870212', '10101101110110001010111100100110110001010001101010100100010001001110010110110011001101101100101'], ['0408643503514', '10101000110001101011011101011110100011011110101010100111011100101000010100111011001101011100101'], ['3842111701831', '10101101110100011001101101100110110011001100101010100010011100101100110100100010000101100110101']]]
labels = ["regression: G code set derivation", "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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: G code set derivation 0 | 10101100011010000111010001110110011001111010001010100100010001001110100100111011101001011100101 | 10101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101 | Failed |
| repair trap 1 | 10101111010111101111010010011101001110001001101010111001011101001011100101110010001001101100101 | 10101111010111101001011101110010111001001001101010111001011101001011100101110010001001101100101 | Failed |
| combined fault 2 | 10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101 | 10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101 | Passed |
| control 3 | 10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101 | 10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101 | Passed |
| control 4 | 10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101 | 10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101 | Passed |
| boundary 5 | 10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101 | 10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101 | Passed |
| boundary 6 | 10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101 | 10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101 | Passed |
| control 7 | 10101100011010000101110001011110110001100010001010111010010100001011100100001010000101100110101 | 10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101 | Failed |
SHA-256 / d1d9ae85ccbedaa563dceae7316ba358ee19e2a0467e6ec5c964e3afe0383c14
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'], ['3339552094472', '10101111010111101001011101110010111001001001101010111001011101001011100101110010001001101100101'], ['0589101449043', '10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101'], ['0520764340509', '10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101'], ['0361070698038', '10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101'], ['0631048571283', '10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101'], ['0728341592804', '10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101'], ['5564657964331', '10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101']], [['6141838617595', '10100110010011101011001100010010111101011011101010101000011001101000100100111011101001001110101'], ['4871645512712', '10101101110010001001100101011110011101011100101010100111011001101101100100010011001101101100101'], ['0413161406353', '10101000110011001011110100110010101111001100101010101110011100101010000100001010011101000010101'], ['0996615036371', '10100010110001011010111101011110011001011000101010111001010000101010000100001010001001100110101'], ['0140957899588', '10100110010100011000110100010110110001011101101010100100011101001110100100111010010001001000101'], ['0048824399021', '10100011010100011011011101101110010011010001101010100001011101001110100111001011011001100110101'], ['0855737200852', '10101101110110001011000101110110111101011101101010110110011100101110010100100010011101101100101'], ['8738417160350', '10101110110100001011011100111010110011011101101010110011010100001110010100001010011101110010101']], [['5108124299029', '10100110010100111000100100110010010011001110101010110110011101001110100111001011011001110100101'], ['5042066730924', '10100011010011101001101100011010101111000010101010100010010000101110010111010011011001011100101'], ['0896029493242', '10101101110001011010111100011010010011000101101010101110011101001000010110110010111001101100101'], ['0972213021163', '10100010110111011001001100100110011001011110101010111001011011001100110110011010100001000010101'], ['0520047957234', '10101100010010011000110100011010100011011101101010111010010011101000100110110010000101011100101'], ['0950847569915', '10100010110110001000110101101110100011011101101010100111010100001110100111010011001101001110101'], ['0134625611321', '10100110010111101010001101011110010011011000101010101000011001101100110100001011011001100110101'], ['3716511088176', '10101110110011001000010101110010110011001100101010111001010010001001000110011010001001010000101']], [['1986892142891', '10100010110110111000010101101110010111001101101010110011010111001101100100100011101001100110101'], ['2437732920288', '10101000110111101001000100100010111101001101101010111010011011001110010110110010010001001000101'], ['0153579089144', '10100110010110001011110101100010111011000101101010111001010010001110100110011010111001011100101'], ['0566009533015', '10101100010101111010111100011010001101000101101010100111010000101000010111001011001101001110101'], ['0705470945586', '10101110110001101011000101000110111011000110101010111010010111001001110100111010010001010000101'], ['0198354317235', '10100110010001011011011101111010110001010001101010100001011001101000100110110010000101001110101'], ['0864220800696', '10101101110101111010001100100110010011000110101010100100011100101110010101000011101001010000101'], ['6346382380419', '10101111010011101000010101000010110111001001101010100001010010001110010101110011001101110100101']], [['8746102916553', '10101110110011101010111101100110100111001001101010111010011001101010000100111010011101000010101'], ['4502760148617', '10101100010100111001001101110110000101010011101010110011010111001001000101000011001101000100101'], ['0633594108024', '10101011110111101011110101100010001011010001101010110011011100101001000111001011011001011100101'], ['0997696331503', '10100010110001011011101101011110001011010111101010100001010000101100110100111011100101000010101'], ['0384158562666', '10101111010110111010001100110010110001011011101010100111010100001101100101000010100001010000101'], ['0856254870212', '10101101110110001010111100100110110001010001101010100100010001001110010110110011001101101100101'], ['0408643503514', '10101000110001101011011101011110100011011110101010100111011100101000010100111011001101011100101'], ['3842111701831', '10101101110100011001101101100110110011001100101010100010011100101100110100100010000101100110101']]]
labels = ["regression: G code set derivation", "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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: G code set derivation 0 | 10101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101 | 10101100010000101001011101110110011001001011101010100100010001001110100100111011101001011100101 | Passed |
| repair trap 1 | 10101111010111101001011101110010111001001001101010111001011101001011100101110010001001101100101 | 10101111010111101001011101110010111001001001101010111001011101001011100101110010001001101100101 | Passed |
| combined fault 2 | 10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101 | 10101100010110111000101100110010001101001100101010101110010111001110100111001010111001000010101 | Passed |
| control 3 | 10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101 | 10101100010010011000110101110110101111010001101010100001010111001110010100111011100101110100101 | Passed |
| control 4 | 10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101 | 10101111010101111001100100011010111011000110101010101000011101001001000111001010000101001000101 | Passed |
| boundary 5 | 10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101 | 10101011110111101001100100011010100011011011101010100111010001001100110110110010010001000010101 | Passed |
| boundary 6 | 10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101 | 10101110110010011011011101111010100011001100101010100111011101001101100100100011100101011100101 | Passed |
| control 7 | 10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101 | 10101100010000101001110101011110110001001000101010111010010100001011100100001010000101100110101 | Passed |
SHA-256 / eca16de89648dc954912384ee079abdd91fc2a0b64638945f9f33acd2abae9d4
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.758141+00:00.
Case digest / 2e103dd5394a76c0e94706d5b8348e989926555172094da32bad15dbdab8dd10