FA-79636 / Barcode symbology encoding / Open access
QR numeric remainder of two digits is sized as 8 bits · case 01
Capacity checks reject payloads that would still fit, forcing a larger symbol version.
ROOT CAUSE
A two-digit numeric remainder is counted as 4 bits per digit instead of 7 bits.
VERIFIED REPAIR
Use 4 bits for one remaining digit and 7 bits for two.
Unsuccessful approach: Three bits cannot represent a single digit 0-9.
Case contract
Compute the length in bits of one QR segment: 4-bit mode indicator, a character count indicator whose width depends on mode and version band (1-9, 10-26, 27-40): numeric 10/12/14, alphanumeric 9/11/13, byte 8/16/16, and the data bits: numeric 10 bits per 3 digits plus 4 or 7 for a remainder of 1 or 2, alphanumeric 11 bits per pair plus 6 for a single, byte 8 bits per UTF-8 byte. Alphanumeric allows 0-9 A-Z space $ % * + - . / :. A count that does not fit the indicator is too-long. Errors: version, charset, mode, too-long.
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(mode, data, version):
if not 1 <= version <= 40:
return {'error': 'version'}
band = 0 if version <= 9 else (1 if version <= 26 else 2)
ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'
if mode == 'numeric':
if not all(c in '0123456789' for c in data):
return {'error': 'charset'}
count = len(data)
bits = 10 * (count // 3) + [0, 4, 8][count % 3]
cci = [10, 12, 14][band]
elif mode == 'alnum':
if not all(c in ALNUM for c in data):
return {'error': 'charset'}
count = len(data)
bits = 11 * (count // 2) + 6 * (count % 2)
cci = [9, 11, 13][band]
elif mode == 'byte':
count = len(data.encode('utf-8'))
bits = 8 * count
cci = [8, 16, 16][band]
else:
return {'error': 'mode'}
if count >= 1 << cci:
return {'error': 'too-long'}
return 4 + cci + bits
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('numeric', '51951717', 40), 45], [('numeric', '1322507885', 27), 52], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('numeric', '97888196275', 27), 55]], [[('numeric', '41605446623', 10), 53], [('numeric', '7840130886', 40), 52], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('numeric', '51', 40), 25]], [[('numeric', '53', 26), 23], [('numeric', '6256737', 1), 38], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '', 26), 20], [('alnum', '%/2*+% $', 0), {'error': 'version'}], [('numeric', '37219', 5), 31]], [[('numeric', '86667136', 5), 41], [('numeric', '9736438869', 15), 50], [('byte', 'abbbaaa', 26), 76], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('numeric', '82758', 27), 35]], [[('numeric', '30390', 26), 33], [('numeric', '5', 1), 18], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('byte', 'a€', 26), 52], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '14974', 9), 31]]]
labels = ["regression: numeric remainder bits", "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: numeric remainder bits 0 | 46 | 45 | Failed |
| repair trap 1 | 52 | 52 | Passed |
| combined fault 2 | {'error': 'version'} | {'error': 'version'} | Passed |
| control 3 | 19 | 19 | Passed |
| control 4 | 19 | 19 | Passed |
| boundary 5 | 108 | 108 | Passed |
| boundary 6 | {'error': 'charset'} | {'error': 'charset'} | Passed |
| control 7 | 56 | 55 | Failed |
SHA-256 / c0464f219e09703cfaa3c5488ddb64cc7936a5aaa5b8646354c29f65663b5dc4
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(mode, data, version):
if not 1 <= version <= 40:
return {'error': 'version'}
band = 0 if version <= 9 else (1 if version <= 26 else 2)
ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'
if mode == 'numeric':
if not all(c in '0123456789' for c in data):
return {'error': 'charset'}
count = len(data)
bits = 10 * (count // 3) + [0, 3, 7][count % 3]
cci = [10, 12, 14][band]
elif mode == 'alnum':
if not all(c in ALNUM for c in data):
return {'error': 'charset'}
count = len(data)
bits = 11 * (count // 2) + 6 * (count % 2)
cci = [9, 11, 13][band]
elif mode == 'byte':
count = len(data.encode('utf-8'))
bits = 8 * count
cci = [8, 16, 16][band]
else:
return {'error': 'mode'}
if count >= 1 << cci:
return {'error': 'too-long'}
return 4 + cci + bits
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('numeric', '51951717', 40), 45], [('numeric', '1322507885', 27), 52], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('numeric', '97888196275', 27), 55]], [[('numeric', '41605446623', 10), 53], [('numeric', '7840130886', 40), 52], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('numeric', '51', 40), 25]], [[('numeric', '53', 26), 23], [('numeric', '6256737', 1), 38], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '', 26), 20], [('alnum', '%/2*+% $', 0), {'error': 'version'}], [('numeric', '37219', 5), 31]], [[('numeric', '86667136', 5), 41], [('numeric', '9736438869', 15), 50], [('byte', 'abbbaaa', 26), 76], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('numeric', '82758', 27), 35]], [[('numeric', '30390', 26), 33], [('numeric', '5', 1), 18], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('byte', 'a€', 26), 52], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '14974', 9), 31]]]
labels = ["regression: numeric remainder bits", "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: numeric remainder bits 0 | 45 | 45 | Passed |
| repair trap 1 | 51 | 52 | Failed |
| combined fault 2 | {'error': 'version'} | {'error': 'version'} | Passed |
| control 3 | 19 | 19 | Passed |
| control 4 | 19 | 19 | Passed |
| boundary 5 | 108 | 108 | Passed |
| boundary 6 | {'error': 'charset'} | {'error': 'charset'} | Passed |
| control 7 | 55 | 55 | Passed |
SHA-256 / bcd70cef8101a3650b43c707ee309fae12aeeef33ee4755dfa90afc2dafa2e6f
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(mode, data, version):
if not 1 <= version <= 40:
return {'error': 'version'}
band = 0 if version <= 9 else (1 if version <= 26 else 2)
ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'
if mode == 'numeric':
if not all(c in '0123456789' for c in data):
return {'error': 'charset'}
count = len(data)
bits = 10 * (count // 3) + [0, 4, 7][count % 3]
cci = [10, 12, 14][band]
elif mode == 'alnum':
if not all(c in ALNUM for c in data):
return {'error': 'charset'}
count = len(data)
bits = 11 * (count // 2) + 6 * (count % 2)
cci = [9, 11, 13][band]
elif mode == 'byte':
count = len(data.encode('utf-8'))
bits = 8 * count
cci = [8, 16, 16][band]
else:
return {'error': 'mode'}
if count >= 1 << cci:
return {'error': 'too-long'}
return 4 + cci + bits
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('numeric', '51951717', 40), 45], [('numeric', '1322507885', 27), 52], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('numeric', '97888196275', 27), 55]], [[('numeric', '41605446623', 10), 53], [('numeric', '7840130886', 40), 52], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('numeric', '51', 40), 25]], [[('numeric', '53', 26), 23], [('numeric', '6256737', 1), 38], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '', 26), 20], [('alnum', '%/2*+% $', 0), {'error': 'version'}], [('numeric', '37219', 5), 31]], [[('numeric', '86667136', 5), 41], [('numeric', '9736438869', 15), 50], [('byte', 'abbbaaa', 26), 76], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('numeric', '82758', 27), 35]], [[('numeric', '30390', 26), 33], [('numeric', '5', 1), 18], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('byte', 'a€', 26), 52], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '14974', 9), 31]]]
labels = ["regression: numeric remainder bits", "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: numeric remainder bits 0 | 45 | 45 | Passed |
| repair trap 1 | 52 | 52 | Passed |
| combined fault 2 | {'error': 'version'} | {'error': 'version'} | Passed |
| control 3 | 19 | 19 | Passed |
| control 4 | 19 | 19 | Passed |
| boundary 5 | 108 | 108 | Passed |
| boundary 6 | {'error': 'charset'} | {'error': 'charset'} | Passed |
| control 7 | 55 | 55 | Passed |
SHA-256 / 3459bf022428adc50b75b65b46c98603eaa2b5999583a3bde3f979bdc19d3c67
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.342213+00:00.
Case digest / ba73557b8f98b0652c386c4ebebc07b6a5c19616086791c78c94e430a6cca995