FA-72836 / Check-digit algorithms / Open access
ESR returns the carry as the check digit · case 01
Only references with final carry 0 or 5 get the right check digit.
ROOT CAUSE
The final carry is returned without taking its ten-complement.
VERIFIED REPAIR
Return (10 - carry) % 10.
Unsuccessful approach: Returning 9 - carry is the nines complement and is off by one.
Case contract
Swiss ESR/QR reference check digit (modulo 10 recursive): spaces ignored, nonempty ASCII digits required (else None). carry starts at 0 and for each digit becomes T[(carry + digit) mod 10] with T = 0,9,4,6,8,2,7,1,3,5; the check digit is (10 - carry) mod 10.
Why this case matters
Payment slips carry a recursive mod-10 reference that billing systems regenerate for reconciliation.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
T = [0, 9, 4, 6, 8, 2, 7, 1, 3, 5]
t = s.replace(' ', '')
if not t or not t.isascii() or not t.isdigit():
return None
carry = 0
for ch in t:
carry = T[(carry + int(ch)) % 10]
return carry
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["74553352741408306"]', ['74553352741408306'], 2], ['regression ["53572"]', ['53572'], 8], ['partial-repair ["2077434195614"]', ['2077434195614'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["394430878867088735677979"]', ['394430878867088735677979'], 0], ['control ["45013905312"]', ['45013905312'], 1], ['control ["1620895357382317345"]', ['1620895357382317345'], 4]], [['regression ["1620895357382317345"]', ['1620895357382317345'], 4], ['regression ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["53572"]', ['53572'], 8], ['partial-repair ["45013905312"]', ['45013905312'], 1], ['control ["12 ab"]', ['12 ab'], None], ['control [""]', [''], None], ['control ["4577034845604675"]', ['4577034845604675'], 7], ['control ["80"]', ['80'], 4]], [['regression ["80"]', ['80'], 4], ['regression ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["4577034845604675"]', ['4577034845604675'], 7], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["79703713605975"]', ['79703713605975'], 0], ['control ["06826"]', ['06826'], 2]], [['regression ["06826"]', ['06826'], 2], ['regression ["06830652810379"]', ['06830652810379'], 4], ['partial-repair ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["846437545686321455"]', ['846437545686321455'], 0], ['control ["12 ab"]', ['12 ab'], None], ['control [""]', [''], None], ['control ["4"]', ['4'], 2], ['control ["42721685367"]', ['42721685367'], 1]], [['regression ["58511"]', ['58511'], 9], ['regression ["4"]', ['4'], 2], ['partial-repair ["79703713605975"]', ['79703713605975'], 0], ['partial-repair ["06826"]', ['06826'], 2], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["112533096471891526511740"]', ['112533096471891526511740'], 6], ['control ["423566969570148799170"]', ['423566969570148799170'], 9]]]
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 ["74553352741408306"] | 8 | 2 | Failed |
| regression ["53572"] | 2 | 8 | Failed |
| partial-repair ["2077434195614"] | 0 | 0 | Passed |
| control [""] | None | None | Passed |
| control ["12 ab"] | None | None | Passed |
| control ["394430878867088735677979"] | 0 | 0 | Passed |
| control ["45013905312"] | 9 | 1 | Failed |
| control ["1620895357382317345"] | 6 | 4 | Failed |
SHA-256 / ecb3de391b44d7efb3d6b315018c8e757ceec1b63eb8b7c94b4b5cbb854c7a3e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
T = [0, 9, 4, 6, 8, 2, 7, 1, 3, 5]
t = s.replace(' ', '')
if not t or not t.isascii() or not t.isdigit():
return None
carry = 0
for ch in t:
carry = T[(carry + int(ch)) % 10]
return 9 - carry
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["74553352741408306"]', ['74553352741408306'], 2], ['regression ["53572"]', ['53572'], 8], ['partial-repair ["2077434195614"]', ['2077434195614'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["394430878867088735677979"]', ['394430878867088735677979'], 0], ['control ["45013905312"]', ['45013905312'], 1], ['control ["1620895357382317345"]', ['1620895357382317345'], 4]], [['regression ["1620895357382317345"]', ['1620895357382317345'], 4], ['regression ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["53572"]', ['53572'], 8], ['partial-repair ["45013905312"]', ['45013905312'], 1], ['control ["12 ab"]', ['12 ab'], None], ['control [""]', [''], None], ['control ["4577034845604675"]', ['4577034845604675'], 7], ['control ["80"]', ['80'], 4]], [['regression ["80"]', ['80'], 4], ['regression ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["4577034845604675"]', ['4577034845604675'], 7], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["79703713605975"]', ['79703713605975'], 0], ['control ["06826"]', ['06826'], 2]], [['regression ["06826"]', ['06826'], 2], ['regression ["06830652810379"]', ['06830652810379'], 4], ['partial-repair ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["846437545686321455"]', ['846437545686321455'], 0], ['control ["12 ab"]', ['12 ab'], None], ['control [""]', [''], None], ['control ["4"]', ['4'], 2], ['control ["42721685367"]', ['42721685367'], 1]], [['regression ["58511"]', ['58511'], 9], ['regression ["4"]', ['4'], 2], ['partial-repair ["79703713605975"]', ['79703713605975'], 0], ['partial-repair ["06826"]', ['06826'], 2], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["112533096471891526511740"]', ['112533096471891526511740'], 6], ['control ["423566969570148799170"]', ['423566969570148799170'], 9]]]
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 ["74553352741408306"] | 1 | 2 | Failed |
| regression ["53572"] | 7 | 8 | Failed |
| partial-repair ["2077434195614"] | 9 | 0 | Failed |
| control [""] | None | None | Passed |
| control ["12 ab"] | None | None | Passed |
| control ["394430878867088735677979"] | 9 | 0 | Failed |
| control ["45013905312"] | 0 | 1 | Failed |
| control ["1620895357382317345"] | 3 | 4 | Failed |
SHA-256 / a925031b38b25330b3b942185560fca268964c862fc41f22e1856939945aadb6
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
T = [0, 9, 4, 6, 8, 2, 7, 1, 3, 5]
t = s.replace(' ', '')
if not t or not t.isascii() or not t.isdigit():
return None
carry = 0
for ch in t:
carry = T[(carry + int(ch)) % 10]
return (10 - carry) % 10
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["74553352741408306"]', ['74553352741408306'], 2], ['regression ["53572"]', ['53572'], 8], ['partial-repair ["2077434195614"]', ['2077434195614'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["394430878867088735677979"]', ['394430878867088735677979'], 0], ['control ["45013905312"]', ['45013905312'], 1], ['control ["1620895357382317345"]', ['1620895357382317345'], 4]], [['regression ["1620895357382317345"]', ['1620895357382317345'], 4], ['regression ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["53572"]', ['53572'], 8], ['partial-repair ["45013905312"]', ['45013905312'], 1], ['control ["12 ab"]', ['12 ab'], None], ['control [""]', [''], None], ['control ["4577034845604675"]', ['4577034845604675'], 7], ['control ["80"]', ['80'], 4]], [['regression ["80"]', ['80'], 4], ['regression ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["4577034845604675"]', ['4577034845604675'], 7], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["79703713605975"]', ['79703713605975'], 0], ['control ["06826"]', ['06826'], 2]], [['regression ["06826"]', ['06826'], 2], ['regression ["06830652810379"]', ['06830652810379'], 4], ['partial-repair ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["846437545686321455"]', ['846437545686321455'], 0], ['control ["12 ab"]', ['12 ab'], None], ['control [""]', [''], None], ['control ["4"]', ['4'], 2], ['control ["42721685367"]', ['42721685367'], 1]], [['regression ["58511"]', ['58511'], 9], ['regression ["4"]', ['4'], 2], ['partial-repair ["79703713605975"]', ['79703713605975'], 0], ['partial-repair ["06826"]', ['06826'], 2], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["112533096471891526511740"]', ['112533096471891526511740'], 6], ['control ["423566969570148799170"]', ['423566969570148799170'], 9]]]
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 ["74553352741408306"] | 2 | 2 | Passed |
| regression ["53572"] | 8 | 8 | Passed |
| partial-repair ["2077434195614"] | 0 | 0 | Passed |
| control [""] | None | None | Passed |
| control ["12 ab"] | None | None | Passed |
| control ["394430878867088735677979"] | 0 | 0 | Passed |
| control ["45013905312"] | 1 | 1 | Passed |
| control ["1620895357382317345"] | 4 | 4 | Passed |
SHA-256 / 095221a1e3ae857a0a514d24deb8e820f3e68d6743a103235d1a0442d49ce0c4
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:42.083569+00:00.
Case digest / 99b911aa6fe0cde0df78604bd0dc58ab64a5e0cc55c81b7d4f953fd743726d18