FA-72831 / Check-digit algorithms / Open access
ESR applies the carry table before adding the digit · case 01
Reference check digits disagree with the bank.
ROOT CAUSE
The update is written (T[carry] + digit) % 10, permuting the old carry instead of the sum.
VERIFIED REPAIR
Apply the table to the sum: carry = T[(carry + digit) % 10].
Unsuccessful approach: Permuting the digit and then adding the carry is still the wrong composition.
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 (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 ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["45013905312"]', ['45013905312'], 1]], [['regression ["1620895357382317345"]', ['1620895357382317345'], 4], ['regression ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["53572"]', ['53572'], 8], ['partial-repair ["45013905312"]', ['45013905312'], 1], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0]], [['regression ["80"]', ['80'], 4], ['regression ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["4577034845604675"]', ['4577034845604675'], 7], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0], ['control [""]', [''], None]], [['regression ["06826"]', ['06826'], 2], ['regression ["06830652810379"]', ['06830652810379'], 4], ['partial-repair ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["846437545686321455"]', ['846437545686321455'], 0], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None]], [['regression ["58511"]', ['58511'], 9], ['regression ["4"]', ['4'], 2], ['partial-repair ["79703713605975"]', ['79703713605975'], 0], ['partial-repair ["06826"]', ['06826'], 2], ['control ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0]]]
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"] | 6 | 2 | Failed |
| regression ["53572"] | 5 | 8 | Failed |
| partial-repair ["2077434195614"] | 0 | 0 | Passed |
| control ["0"] | 0 | 0 | Passed |
| control [""] | None | None | Passed |
| control ["12 ab"] | None | None | Passed |
| control ["00000000000000000000000000"] | 0 | 0 | Passed |
| control ["45013905312"] | 9 | 1 | Failed |
SHA-256 / 95e11aec910d650dd1b3f2278b7b88224d8f8e4ca7d313762c2b5a5819ddb8ef
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[int(ch)] + carry) % 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 ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["45013905312"]', ['45013905312'], 1]], [['regression ["1620895357382317345"]', ['1620895357382317345'], 4], ['regression ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["53572"]', ['53572'], 8], ['partial-repair ["45013905312"]', ['45013905312'], 1], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0]], [['regression ["80"]', ['80'], 4], ['regression ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["4577034845604675"]', ['4577034845604675'], 7], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0], ['control [""]', [''], None]], [['regression ["06826"]', ['06826'], 2], ['regression ["06830652810379"]', ['06830652810379'], 4], ['partial-repair ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["846437545686321455"]', ['846437545686321455'], 0], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None]], [['regression ["58511"]', ['58511'], 9], ['regression ["4"]', ['4'], 2], ['partial-repair ["79703713605975"]', ['79703713605975'], 0], ['partial-repair ["06826"]', ['06826'], 2], ['control ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0]]]
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"] | 7 | 2 | Failed |
| regression ["53572"] | 5 | 8 | Failed |
| partial-repair ["2077434195614"] | 2 | 0 | Failed |
| control ["0"] | 0 | 0 | Passed |
| control [""] | None | None | Passed |
| control ["12 ab"] | None | None | Passed |
| control ["00000000000000000000000000"] | 0 | 0 | Passed |
| control ["45013905312"] | 9 | 1 | Failed |
SHA-256 / 3e797af116ec47fd6f1adf3647fa0b011acb6787b653e6cfbaf06335698ca133
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 ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["45013905312"]', ['45013905312'], 1]], [['regression ["1620895357382317345"]', ['1620895357382317345'], 4], ['regression ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["53572"]', ['53572'], 8], ['partial-repair ["45013905312"]', ['45013905312'], 1], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0]], [['regression ["80"]', ['80'], 4], ['regression ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["29066637371762928589407375"]', ['29066637371762928589407375'], 8], ['partial-repair ["4577034845604675"]', ['4577034845604675'], 7], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0], ['control [""]', [''], None]], [['regression ["06826"]', ['06826'], 2], ['regression ["06830652810379"]', ['06830652810379'], 4], ['partial-repair ["795943004839078191062840"]', ['795943004839078191062840'], 4], ['partial-repair ["846437545686321455"]', ['846437545686321455'], 0], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0], ['control ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None]], [['regression ["58511"]', ['58511'], 9], ['regression ["4"]', ['4'], 2], ['partial-repair ["79703713605975"]', ['79703713605975'], 0], ['partial-repair ["06826"]', ['06826'], 2], ['control ["0"]', ['0'], 0], ['control [""]', [''], None], ['control ["12 ab"]', ['12 ab'], None], ['control ["00000000000000000000000000"]', ['00000000000000000000000000'], 0]]]
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 ["0"] | 0 | 0 | Passed |
| control [""] | None | None | Passed |
| control ["12 ab"] | None | None | Passed |
| control ["00000000000000000000000000"] | 0 | 0 | Passed |
| control ["45013905312"] | 1 | 1 | Passed |
SHA-256 / 674cfe25e609c1076466dc7a5bb1f5f154d0ff5c99df411320e12abe0364bc50
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.055614+00:00.
Case digest / 4a5ef1547b7b2f8c04fc4515087109fa0aaf4be9364daf2b0ee0b244b67610c7