FA-79681 / Barcode symbology encoding / Open access
QR alphanumeric trailing character is written in 5 bits · case 01
Odd-length data ending in a character with value 32 or more corrupts the terminator.
ROOT CAUSE
The single trailing character uses 5 bits, which cannot hold values 32..44.
VERIFIED REPAIR
Write the trailing character in 6 bits.
Unsuccessful approach: Using the 11-bit pair width wastes five bits and desynchronises the count.
Case contract
Encode the data part of a QR alphanumeric segment. Character values: 0-9 -> 0-9, A-Z -> 10-35, space 36, $ 37, % 38, * 39, + 40, - 41, . 42, / 43, : 44. Each pair becomes 45*first + second in 11 bits, a final single character becomes its value in 6 bits. Characters outside the set return 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):
ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'
if any(c not in ALNUM for c in s):
return None
bits = ''
for i in range(0, len(s) - 1, 2):
v = 45 * ALNUM.index(s[i]) + ALNUM.index(s[i + 1])
bits += format(v, '011b')
if len(s) % 2:
bits += format(ALNUM.index(s[-1]), '05b')
return bits
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['R1K', '10011000000010100'], ['IG:', '01100111010101100'], ['YL-V1BV', '110000011111110101010000000111000011111'], ['', ''], ['A8CG', '0011100101001000101100'], ['L1', '01110110010'], ['9A', '00110011111'], ['4', '000100']], [[':HKK4', '1111100110101110011000000100'], ['A2L0$4A', '001110001000111011000111010000101001010'], ['Z6UKSE', '110001011011010101101010011111010'], ['VK5/1S', '101100001110010000110000001001001'], ['I1', '01100101011'], ['', ''], ['0-KJ', '0000010100101110010111'], ['E', '001110']], [['Q', '011010'], ['X', '100001'], ['J$L', '01101111100010101'], ['20Y%', '0000101101011000100000'], ['', ''], ['$K', '11010010101'], ['MN', '01111110101'], ['ZMHUK', '1100011110101100011011010100']], [['TX4', '10100111010000100'], ['CBS', '01000100111011100'], ['OJOU', '1000100101110001010110'], ['', ''], ['2R9L', '0000111010100110101010'], ['*AB1', '1101110010100111110000'], ['M+1GDK', '100000001100000011110101001011101'], ['HE9', '01100001011001001']], [['0 6-C', '0000010010000100110111001100'], ['M2R:*', '0111110000010011101011100111'], ['P', '011001'], ['', ''], ['VS63', '1011000111100100010001'], ['EG$9', '0101000011011010001010'], [':X', '11111011101'], ['%KU', '11011000010011110']]]
labels = ["regression: trailing character bit width", "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: trailing character bit width 0 | 1001100000010100 | 10011000000010100 | Failed |
| repair trap 1 | 01100111010101100 | 01100111010101100 | Passed |
| combined fault 2 | 11000001111111010101000000011100011111 | 110000011111110101010000000111000011111 | Failed |
| control 3 | | | Passed |
| control 4 | 0011100101001000101100 | 0011100101001000101100 | Passed |
| boundary 5 | 01110110010 | 01110110010 | Passed |
| boundary 6 | 00110011111 | 00110011111 | Passed |
| control 7 | 00100 | 000100 | Failed |
SHA-256 / 731dd11d08459866e99f36dbda2b40b1bcaf56856cb96457816bcdff470c8996
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'
if any(c not in ALNUM for c in s):
return None
bits = ''
for i in range(0, len(s) - 1, 2):
v = 45 * ALNUM.index(s[i]) + ALNUM.index(s[i + 1])
bits += format(v, '011b')
if len(s) % 2:
bits += format(ALNUM.index(s[-1]), '011b')
return bits
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['R1K', '10011000000010100'], ['IG:', '01100111010101100'], ['YL-V1BV', '110000011111110101010000000111000011111'], ['', ''], ['A8CG', '0011100101001000101100'], ['L1', '01110110010'], ['9A', '00110011111'], ['4', '000100']], [[':HKK4', '1111100110101110011000000100'], ['A2L0$4A', '001110001000111011000111010000101001010'], ['Z6UKSE', '110001011011010101101010011111010'], ['VK5/1S', '101100001110010000110000001001001'], ['I1', '01100101011'], ['', ''], ['0-KJ', '0000010100101110010111'], ['E', '001110']], [['Q', '011010'], ['X', '100001'], ['J$L', '01101111100010101'], ['20Y%', '0000101101011000100000'], ['', ''], ['$K', '11010010101'], ['MN', '01111110101'], ['ZMHUK', '1100011110101100011011010100']], [['TX4', '10100111010000100'], ['CBS', '01000100111011100'], ['OJOU', '1000100101110001010110'], ['', ''], ['2R9L', '0000111010100110101010'], ['*AB1', '1101110010100111110000'], ['M+1GDK', '100000001100000011110101001011101'], ['HE9', '01100001011001001']], [['0 6-C', '0000010010000100110111001100'], ['M2R:*', '0111110000010011101011100111'], ['P', '011001'], ['', ''], ['VS63', '1011000111100100010001'], ['EG$9', '0101000011011010001010'], [':X', '11111011101'], ['%KU', '11011000010011110']]]
labels = ["regression: trailing character bit width", "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: trailing character bit width 0 | 1001100000000000010100 | 10011000000010100 | Failed |
| repair trap 1 | 0110011101000000101100 | 01100111010101100 | Failed |
| combined fault 2 | 11000001111111010101000000011100000000011111 | 110000011111110101010000000111000011111 | Failed |
| control 3 | | | Passed |
| control 4 | 0011100101001000101100 | 0011100101001000101100 | Passed |
| boundary 5 | 01110110010 | 01110110010 | Passed |
| boundary 6 | 00110011111 | 00110011111 | Passed |
| control 7 | 00000000100 | 000100 | Failed |
SHA-256 / 0afb57f0e4ac2ef0b01c06130b3896089b97060e77bce7f761a9f8cf3dca82e7
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'
if any(c not in ALNUM for c in s):
return None
bits = ''
for i in range(0, len(s) - 1, 2):
v = 45 * ALNUM.index(s[i]) + ALNUM.index(s[i + 1])
bits += format(v, '011b')
if len(s) % 2:
bits += format(ALNUM.index(s[-1]), '06b')
return bits
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['R1K', '10011000000010100'], ['IG:', '01100111010101100'], ['YL-V1BV', '110000011111110101010000000111000011111'], ['', ''], ['A8CG', '0011100101001000101100'], ['L1', '01110110010'], ['9A', '00110011111'], ['4', '000100']], [[':HKK4', '1111100110101110011000000100'], ['A2L0$4A', '001110001000111011000111010000101001010'], ['Z6UKSE', '110001011011010101101010011111010'], ['VK5/1S', '101100001110010000110000001001001'], ['I1', '01100101011'], ['', ''], ['0-KJ', '0000010100101110010111'], ['E', '001110']], [['Q', '011010'], ['X', '100001'], ['J$L', '01101111100010101'], ['20Y%', '0000101101011000100000'], ['', ''], ['$K', '11010010101'], ['MN', '01111110101'], ['ZMHUK', '1100011110101100011011010100']], [['TX4', '10100111010000100'], ['CBS', '01000100111011100'], ['OJOU', '1000100101110001010110'], ['', ''], ['2R9L', '0000111010100110101010'], ['*AB1', '1101110010100111110000'], ['M+1GDK', '100000001100000011110101001011101'], ['HE9', '01100001011001001']], [['0 6-C', '0000010010000100110111001100'], ['M2R:*', '0111110000010011101011100111'], ['P', '011001'], ['', ''], ['VS63', '1011000111100100010001'], ['EG$9', '0101000011011010001010'], [':X', '11111011101'], ['%KU', '11011000010011110']]]
labels = ["regression: trailing character bit width", "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: trailing character bit width 0 | 10011000000010100 | 10011000000010100 | Passed |
| repair trap 1 | 01100111010101100 | 01100111010101100 | Passed |
| combined fault 2 | 110000011111110101010000000111000011111 | 110000011111110101010000000111000011111 | Passed |
| control 3 | | | Passed |
| control 4 | 0011100101001000101100 | 0011100101001000101100 | Passed |
| boundary 5 | 01110110010 | 01110110010 | Passed |
| boundary 6 | 00110011111 | 00110011111 | Passed |
| control 7 | 000100 | 000100 | Passed |
SHA-256 / 98c00a94040e4a79ead0f1bbf2a2a6744c9db4dd91dce10976bd3ffb528b119f
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:46.900356+00:00.
Case digest / e85cbcfb0c545ca44264b918fcec52b70576723c64bbeb3068c07a88bd212064