FAILURE MAP
← Case archive

FA-72386 / Check-digit algorithms / Open access

Verhoeff generation omits the position offset · case 01

Generated check digits fail validation of the very number they were computed for.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Generation uses offset 0, so each payload digit receives the permutation meant for the position to its right.

THE FAILURE

Generation uses offset 0, so each payload digit receives the permutation meant for the position to its right.

Unsuccessful approach: Always using offset 1 fixes generation but breaks validation of complete numbers.

Case contract

Verhoeff dihedral-group scheme. mode "generate" returns the check digit for a nonempty ASCII digit payload; mode "validate" returns whether a nonempty digit string ending in its check digit is correct. Digits are processed from the right with permutation P[(i + offset) % 8], offset 1 when generating and 0 when validating; the check digit is the dihedral inverse of the final state. Empty or non-digit input returns None.

Why this case matters

National identity and ticketing numbers use Verhoeff to catch all single-digit and adjacent transposition errors.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(s, mode):
    D = [[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]]
    P = [[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,8,7,6,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]]
    INV = [0,4,3,2,1,5,6,7,8,9]
    if not s or not s.isascii() or not s.isdigit():
        return None
    offset = 0
    c = 0
    for i, ch in enumerate(reversed(s)):
        c = D[c][P[(i + offset) % 8][int(ch)]]
    if mode == 'generate':
        return INV[c]
    return c == 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["7", "generate"]', ['7', 'generate'], 0], ['regression ["12", "generate"]', ['12', 'generate'], 1], ['partial-repair ["6001", "validate"]', ['6001', 'validate'], False], ['partial-repair ["076688867", "validate"]', ['076688867', 'validate'], False], ['control ["73", "validate"]', ['73', 'validate'], False], ['control ["123", "validate"]', ['123', 'validate'], False], ['control ["317230", "validate"]', ['317230', 'validate'], False], ['control ["2864257569", "validate"]', ['2864257569', 'validate'], False]], [['regression ["31723", "generate"]', ['31723', 'generate'], 6], ['regression ["07668886", "generate"]', ['07668886', 'generate'], 2], ['partial-repair ["0", "validate"]', ['0', 'validate'], True], ['partial-repair ["1428570", "validate"]', ['1428570', 'validate'], True], ['control ["8115669551647", "validate"]', ['8115669551647', 'validate'], False], ['control ["6516456313406690", "validate"]', ['6516456313406690', 'validate'], False], ['control ["2364", "validate"]', ['2364', 'validate'], False], ['control ["123451", "validate"]', ['123451', 'validate'], True]], [['regression ["42668879332", "generate"]', ['42668879332', 'generate'], 9], ['regression ["811566955164", "generate"]', ['811566955164', 'generate'], 9], ['partial-repair ["076688867", "validate"]', ['076688867', 'validate'], False], ['partial-repair ["2363", "validate"]', ['2363', 'validate'], True], ['control ["", "validate"]', ['', 'validate'], None], ['control ["12a", "generate"]', ['12a', 'generate'], None], ['control ["1428572", "validate"]', ['1428572', 'validate'], False], ['control ["73", "validate"]', ['73', 'validate'], False]], [['regression ["236", "generate"]', ['236', 'generate'], 3], ['regression ["12345", "generate"]', ['12345', 'generate'], 1], ['partial-repair ["1428570", "validate"]', ['1428570', 'validate'], True], ['partial-repair ["6001", "validate"]', ['6001', 'validate'], False], ['control ["317230", "validate"]', ['317230', 'validate'], False], ['control ["2864257569", "validate"]', ['2864257569', 'validate'], False], ['control ["426688793324", "validate"]', ['426688793324', 'validate'], False], ['control ["8115669551647", "validate"]', ['8115669551647', 'validate'], False]], [['regression ["142857", "generate"]', ['142857', 'generate'], 0], ['regression ["84736430954837284567892", "generate"]', ['84736430954837284567892', 'generate'], 2], ['partial-repair ["2363", "validate"]', ['2363', 'validate'], True], ['partial-repair ["0", "validate"]', ['0', 'validate'], True], ['control ["2364", "validate"]', ['2364', 'validate'], False], ['control ["123451", "validate"]', ['123451', 'validate'], True], ['control ["", "generate"]', ['', 'generate'], None], ['control ["", "validate"]', ['', 'validate'], None]]]
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 fixtureActualExpectedOutcome
regression ["7", "generate"]70Failed
regression ["12", "generate"]71Failed
partial-repair ["6001", "validate"]FalseFalsePassed
partial-repair ["076688867", "validate"]FalseFalsePassed
control ["73", "validate"]FalseFalsePassed
control ["123", "validate"]FalseFalsePassed
control ["317230", "validate"]FalseFalsePassed
control ["2864257569", "validate"]FalseFalsePassed

SHA-256 / d47960311101b79cdb40722becbb7f8480b17cbb55a1c608c82718ad6271fdd7

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(s, mode):
    D = [[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]]
    P = [[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,8,7,6,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]]
    INV = [0,4,3,2,1,5,6,7,8,9]
    if not s or not s.isascii() or not s.isdigit():
        return None
    offset = 1
    c = 0
    for i, ch in enumerate(reversed(s)):
        c = D[c][P[(i + offset) % 8][int(ch)]]
    if mode == 'generate':
        return INV[c]
    return c == 0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["7", "generate"]', ['7', 'generate'], 0], ['regression ["12", "generate"]', ['12', 'generate'], 1], ['partial-repair ["6001", "validate"]', ['6001', 'validate'], False], ['partial-repair ["076688867", "validate"]', ['076688867', 'validate'], False], ['control ["73", "validate"]', ['73', 'validate'], False], ['control ["123", "validate"]', ['123', 'validate'], False], ['control ["317230", "validate"]', ['317230', 'validate'], False], ['control ["2864257569", "validate"]', ['2864257569', 'validate'], False]], [['regression ["31723", "generate"]', ['31723', 'generate'], 6], ['regression ["07668886", "generate"]', ['07668886', 'generate'], 2], ['partial-repair ["0", "validate"]', ['0', 'validate'], True], ['partial-repair ["1428570", "validate"]', ['1428570', 'validate'], True], ['control ["8115669551647", "validate"]', ['8115669551647', 'validate'], False], ['control ["6516456313406690", "validate"]', ['6516456313406690', 'validate'], False], ['control ["2364", "validate"]', ['2364', 'validate'], False], ['control ["123451", "validate"]', ['123451', 'validate'], True]], [['regression ["42668879332", "generate"]', ['42668879332', 'generate'], 9], ['regression ["811566955164", "generate"]', ['811566955164', 'generate'], 9], ['partial-repair ["076688867", "validate"]', ['076688867', 'validate'], False], ['partial-repair ["2363", "validate"]', ['2363', 'validate'], True], ['control ["", "validate"]', ['', 'validate'], None], ['control ["12a", "generate"]', ['12a', 'generate'], None], ['control ["1428572", "validate"]', ['1428572', 'validate'], False], ['control ["73", "validate"]', ['73', 'validate'], False]], [['regression ["236", "generate"]', ['236', 'generate'], 3], ['regression ["12345", "generate"]', ['12345', 'generate'], 1], ['partial-repair ["1428570", "validate"]', ['1428570', 'validate'], True], ['partial-repair ["6001", "validate"]', ['6001', 'validate'], False], ['control ["317230", "validate"]', ['317230', 'validate'], False], ['control ["2864257569", "validate"]', ['2864257569', 'validate'], False], ['control ["426688793324", "validate"]', ['426688793324', 'validate'], False], ['control ["8115669551647", "validate"]', ['8115669551647', 'validate'], False]], [['regression ["142857", "generate"]', ['142857', 'generate'], 0], ['regression ["84736430954837284567892", "generate"]', ['84736430954837284567892', 'generate'], 2], ['partial-repair ["2363", "validate"]', ['2363', 'validate'], True], ['partial-repair ["0", "validate"]', ['0', 'validate'], True], ['control ["2364", "validate"]', ['2364', 'validate'], False], ['control ["123451", "validate"]', ['123451', 'validate'], True], ['control ["", "generate"]', ['', 'generate'], None], ['control ["", "validate"]', ['', 'validate'], None]]]
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 fixtureActualExpectedOutcome
regression ["7", "generate"]00Passed
regression ["12", "generate"]11Passed
partial-repair ["6001", "validate"]TrueFalseFailed
partial-repair ["076688867", "validate"]TrueFalseFailed
control ["73", "validate"]FalseFalsePassed
control ["123", "validate"]FalseFalsePassed
control ["317230", "validate"]FalseFalsePassed
control ["2864257569", "validate"]FalseFalsePassed

SHA-256 / dc60743f239586bbe956fced10bc7e2575818b943fe691c963cc6715c0dd671e

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:38.020566+00:00.

Case digest / ace4ff4c0b2720b66dc1a800054d3f161069fab94149063d8d77bf381c0ccc1d