FA-72671 / Check-digit algorithms / Open access
UPC-E admits number systems other than 0 and 1 · case 01
Eight-digit strings starting 2-9 are expanded as if they were UPC-E.
ROOT CAUSE
The number-system restriction to 0 or 1 is missing.
THE FAILURE
The number-system restriction to 0 or 1 is missing.
Unsuccessful approach: Accepting only number system 0 rejects legitimate number-system-1 codes.
Case contract
Expand an 8-digit UPC-E (number system 0 or 1, six compressed digits m1..m6, check digit) to UPC-A. By m6: 0-2 -> m1 m2 m6 0000 m3 m4 m5; 3 -> m1 m2 m3 00000 m4 m5; 4 -> m1 m2 m3 m4 00000 m5; 5-9 -> m1..m5 0000 m6. The UPC-A check (weights 3,1 from the left over the 11 digits) must equal the given check digit; return the 12-digit UPC-A string, or None for malformed or mismatching input.
Why this case matters
Point-of-sale systems normalise zero-suppressed UPC-E labels into UPC-A keys for price lookup.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
if len(s) != 8 or not s.isascii() or not s.isdigit():
return None
ns, m, chk = s[0], s[1:7], s[7]
last = m[5]
if last in '012':
body = m[0:2] + last + '0000' + m[2:5]
elif last == '3':
body = m[0:3] + '00000' + m[3:5]
elif last == '4':
body = m[0:4] + '00000' + m[4]
else:
body = m[0:5] + '0000' + last
a = ns + body
total = sum(int(ch) * (3 if i % 2 == 0 else 1) for i, ch in enumerate(a))
check = (10 - total % 10) % 10
if str(check) != chk:
return None
return a + chk
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["28109420"]', ['28109420'], None], ['regression ["32492194"]', ['32492194'], None], ['partial-repair ["13813703"]', ['13813703'], '138000001373'], ['partial-repair ["10054749"]', ['10054749'], '100540000079'], ['control ["06109613"]', ['06109613'], '061100000963'], ['control ["08548229"]', ['08548229'], '085200004829'], ['control ["03909633"]', ['03909633'], '039000000963'], ['control ["08190253"]', ['08190253'], '081902000053']], [['regression ["97987994"]', ['97987994'], None], ['regression ["28109420"]', ['28109420'], None], ['partial-repair ["14227004"]', ['14227004'], '142000002704'], ['partial-repair ["14586929"]', ['14586929'], '145200008699'], ['control ["00140485"]', ['00140485'], '001404000085'], ['control ["04896098"]', ['04896098'], '048960000098'], ['control ["08639918"]', ['08639918'], '086100003998'], ['control ["04793431"]', ['04793431'], '047900000341']], [['regression ["73497295"]', ['73497295'], None], ['regression ["97987994"]', ['97987994'], None], ['partial-repair ["12345670"]', ['12345670'], '123456000070'], ['partial-repair ["13813703"]', ['13813703'], '138000001373'], ['control ["04252614"]', ['04252614'], '042100005264'], ['control ["01234565"]', ['01234565'], '012345000065'], ['control ["01234531"]', ['01234531'], '012300000451'], ['control ["23456781"]', ['23456781'], None]], [['regression ["32492194"]', ['32492194'], None], ['regression ["73497295"]', ['73497295'], None], ['partial-repair ["15067371"]', ['15067371'], '150673000071'], ['partial-repair ["14227004"]', ['14227004'], '142000002704'], ['control ["0425261a"]', ['0425261a'], None], ['control ["04252615"]', ['04252615'], None], ['control ["00000000"]', ['00000000'], '000000000000'], ['control ["06109613"]', ['06109613'], '061100000963']], [['regression ["28109420"]', ['28109420'], None], ['regression ["32492194"]', ['32492194'], None], ['partial-repair ["16526754"]', ['16526754'], '165267000054'], ['partial-repair ["12345670"]', ['12345670'], '123456000070'], ['control ["03909633"]', ['03909633'], '039000000963'], ['control ["08190253"]', ['08190253'], '081902000053'], ['control ["03793961"]', ['03793961'], '037939000061'], ['control ["00140485"]', ['00140485'], '001404000085']]]
for label, args, expected in fixtures[N - 1]:
check(label, 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 ["28109420"] | 281200000940 | None | Failed |
| regression ["32492194"] | 324921000094 | None | Failed |
| partial-repair ["13813703"] | 138000001373 | 138000001373 | Passed |
| partial-repair ["10054749"] | 100540000079 | 100540000079 | Passed |
| control ["06109613"] | 061100000963 | 061100000963 | Passed |
| control ["08548229"] | 085200004829 | 085200004829 | Passed |
| control ["03909633"] | 039000000963 | 039000000963 | Passed |
| control ["08190253"] | 081902000053 | 081902000053 | Passed |
SHA-256 / 209d0140efc03a4cfc44aeac935276664ec2a707494a58d88e5a62736eb8ae1a
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) != 8 or not s.isascii() or not s.isdigit() or s[0] != '0':
return None
ns, m, chk = s[0], s[1:7], s[7]
last = m[5]
if last in '012':
body = m[0:2] + last + '0000' + m[2:5]
elif last == '3':
body = m[0:3] + '00000' + m[3:5]
elif last == '4':
body = m[0:4] + '00000' + m[4]
else:
body = m[0:5] + '0000' + last
a = ns + body
total = sum(int(ch) * (3 if i % 2 == 0 else 1) for i, ch in enumerate(a))
check = (10 - total % 10) % 10
if str(check) != chk:
return None
return a + chk
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["28109420"]', ['28109420'], None], ['regression ["32492194"]', ['32492194'], None], ['partial-repair ["13813703"]', ['13813703'], '138000001373'], ['partial-repair ["10054749"]', ['10054749'], '100540000079'], ['control ["06109613"]', ['06109613'], '061100000963'], ['control ["08548229"]', ['08548229'], '085200004829'], ['control ["03909633"]', ['03909633'], '039000000963'], ['control ["08190253"]', ['08190253'], '081902000053']], [['regression ["97987994"]', ['97987994'], None], ['regression ["28109420"]', ['28109420'], None], ['partial-repair ["14227004"]', ['14227004'], '142000002704'], ['partial-repair ["14586929"]', ['14586929'], '145200008699'], ['control ["00140485"]', ['00140485'], '001404000085'], ['control ["04896098"]', ['04896098'], '048960000098'], ['control ["08639918"]', ['08639918'], '086100003998'], ['control ["04793431"]', ['04793431'], '047900000341']], [['regression ["73497295"]', ['73497295'], None], ['regression ["97987994"]', ['97987994'], None], ['partial-repair ["12345670"]', ['12345670'], '123456000070'], ['partial-repair ["13813703"]', ['13813703'], '138000001373'], ['control ["04252614"]', ['04252614'], '042100005264'], ['control ["01234565"]', ['01234565'], '012345000065'], ['control ["01234531"]', ['01234531'], '012300000451'], ['control ["23456781"]', ['23456781'], None]], [['regression ["32492194"]', ['32492194'], None], ['regression ["73497295"]', ['73497295'], None], ['partial-repair ["15067371"]', ['15067371'], '150673000071'], ['partial-repair ["14227004"]', ['14227004'], '142000002704'], ['control ["0425261a"]', ['0425261a'], None], ['control ["04252615"]', ['04252615'], None], ['control ["00000000"]', ['00000000'], '000000000000'], ['control ["06109613"]', ['06109613'], '061100000963']], [['regression ["28109420"]', ['28109420'], None], ['regression ["32492194"]', ['32492194'], None], ['partial-repair ["16526754"]', ['16526754'], '165267000054'], ['partial-repair ["12345670"]', ['12345670'], '123456000070'], ['control ["03909633"]', ['03909633'], '039000000963'], ['control ["08190253"]', ['08190253'], '081902000053'], ['control ["03793961"]', ['03793961'], '037939000061'], ['control ["00140485"]', ['00140485'], '001404000085']]]
for label, args, expected in fixtures[N - 1]:
check(label, 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 ["28109420"] | None | None | Passed |
| regression ["32492194"] | None | None | Passed |
| partial-repair ["13813703"] | None | 138000001373 | Failed |
| partial-repair ["10054749"] | None | 100540000079 | Failed |
| control ["06109613"] | 061100000963 | 061100000963 | Passed |
| control ["08548229"] | 085200004829 | 085200004829 | Passed |
| control ["03909633"] | 039000000963 | 039000000963 | Passed |
| control ["08190253"] | 081902000053 | 081902000053 | Passed |
SHA-256 / d1ee52ae5d4b7ae64ed7c1b7cca5be6d5833ec5cb2ae299f14e0b1a7c3e3f763
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic, bounded teaching model of the named scheme under the stated contract; not a certified validator. 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:48:40.560129+00:00.
Case digest / d505ef1d79d3f66d4bb192f2e45c9eb8ddaadbd34ef4c77c9e403108f822824d