FAILURE MAP
← Case archive

FA-72581 / Check-digit algorithms / Open access

Resident ID weights use one power of two too few · case 01

Nearly every identity number is rejected.

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

ROOT CAUSE

Weights are computed as 2^(16-i) mod 11, shifting the exponent by one.

VERIFIED REPAIR

Use weight 2^(17-i) mod 11 so the first digit gets 7 and the seventeenth gets 2.

Unsuccessful approach: Reversing the exponent (2^i) assigns the heaviest weights to the wrong end.

Case contract

Check character of an 18-character resident identity number: seventeen ASCII digits followed by a digit or X (lowercase x accepted). Weights are 2^(17-i) mod 11 for 0-based i; the check character is "10X98765432"[sum % 11]. Return [check character, whether the 18th character matches case-insensitively].

Why this case matters

Account opening flows validate national identity numbers before identity verification.

1 / The failure

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

N = 1
observations = []
def solve(s):
    if len(s) != 18 or not s.isascii() or not s[:17].isdigit():
        return 'malformed'
    total = sum(int(ch) * pow(2, 16 - i, 11) for i, ch in enumerate(s[:17]))
    check = '10X98765432'[total % 11]
    return [check, check == s[17].upper()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["268310199103143528"]', ['268310199103143528'], ['9', False]], ['regression ["297547197007199229"]', ['297547197007199229'], ['2', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["518849198106269933"]', ['518849198106269933'], ['6', False]], ['control ["405799197903155930"]', ['405799197903155930'], ['7', False]], ['control ["445793197510028320"]', ['445793197510028320'], ['X', False]], ['control ["309071197409120443"]', ['309071197409120443'], ['3', True]]], [['regression ["405799197903155930"]', ['405799197903155930'], ['7', False]], ['regression ["445793197510028320"]', ['445793197510028320'], ['X', False]], ['partial-repair ["309071197409120443"]', ['309071197409120443'], ['3', True]], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["458825200412201114"]', ['458825200412201114'], ['5', False]], ['control ["373498196811139070"]', ['373498196811139070'], ['5', False]], ['control ["18951819720314318X"]', ['18951819720314318X'], ['3', False]]], [['regression ["594570196107138355"]', ['594570196107138355'], ['2', False]], ['regression ["458825200412201114"]', ['458825200412201114'], ['5', False]], ['partial-repair ["373498196811139070"]', ['373498196811139070'], ['5', False]], ['partial-repair ["18951819720314318X"]', ['18951819720314318X'], ['3', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['control ["37858219960314414X"]', ['37858219960314414X'], ['7', False]]], [['regression ["18951819720314318X"]', ['18951819720314318X'], ['3', False]], ['regression ["50937819800315206x"]', ['50937819800315206x'], ['9', False]], ['partial-repair ["600025197711283200"]', ['600025197711283200'], ['5', False]], ['partial-repair ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["261917197009053555"]', ['261917197009053555'], ['3', False]], ['control ["607248198301138071"]', ['607248198301138071'], ['9', False]]], [['regression ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['regression ["37858219960314414X"]', ['37858219960314414X'], ['7', False]], ['partial-repair ["22100419730209591X"]', ['22100419730209591X'], ['4', False]], ['partial-repair ["653847197508233493"]', ['653847197508233493'], ['2', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002X"]', ['11010519491231002X'], ['X', True]], ['control ["11010519491231002x"]', ['11010519491231002x'], ['X', True]]]]
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 ["268310199103143528"]['5', False]['9', False]Failed
regression ["297547197007199229"]['7', False]['2', False]Failed
control ["11010519491231002"]malformedmalformedPassed
control ["1101051949123100XX"]malformedmalformedPassed
control ["518849198106269933"]['9', False]['6', False]Failed
control ["405799197903155930"]['4', False]['7', False]Failed
control ["445793197510028320"]['0', True]['X', False]Failed
control ["309071197409120443"]['2', False]['3', True]Failed

SHA-256 / b03b7f2ee38a80849096c8e018480ca23c268407870f63362523ea1c561895dc

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) != 18 or not s.isascii() or not s[:17].isdigit():
        return 'malformed'
    total = sum(int(ch) * pow(2, i, 11) for i, ch in enumerate(s[:17]))
    check = '10X98765432'[total % 11]
    return [check, check == s[17].upper()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["268310199103143528"]', ['268310199103143528'], ['9', False]], ['regression ["297547197007199229"]', ['297547197007199229'], ['2', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["518849198106269933"]', ['518849198106269933'], ['6', False]], ['control ["405799197903155930"]', ['405799197903155930'], ['7', False]], ['control ["445793197510028320"]', ['445793197510028320'], ['X', False]], ['control ["309071197409120443"]', ['309071197409120443'], ['3', True]]], [['regression ["405799197903155930"]', ['405799197903155930'], ['7', False]], ['regression ["445793197510028320"]', ['445793197510028320'], ['X', False]], ['partial-repair ["309071197409120443"]', ['309071197409120443'], ['3', True]], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["458825200412201114"]', ['458825200412201114'], ['5', False]], ['control ["373498196811139070"]', ['373498196811139070'], ['5', False]], ['control ["18951819720314318X"]', ['18951819720314318X'], ['3', False]]], [['regression ["594570196107138355"]', ['594570196107138355'], ['2', False]], ['regression ["458825200412201114"]', ['458825200412201114'], ['5', False]], ['partial-repair ["373498196811139070"]', ['373498196811139070'], ['5', False]], ['partial-repair ["18951819720314318X"]', ['18951819720314318X'], ['3', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['control ["37858219960314414X"]', ['37858219960314414X'], ['7', False]]], [['regression ["18951819720314318X"]', ['18951819720314318X'], ['3', False]], ['regression ["50937819800315206x"]', ['50937819800315206x'], ['9', False]], ['partial-repair ["600025197711283200"]', ['600025197711283200'], ['5', False]], ['partial-repair ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["261917197009053555"]', ['261917197009053555'], ['3', False]], ['control ["607248198301138071"]', ['607248198301138071'], ['9', False]]], [['regression ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['regression ["37858219960314414X"]', ['37858219960314414X'], ['7', False]], ['partial-repair ["22100419730209591X"]', ['22100419730209591X'], ['4', False]], ['partial-repair ["653847197508233493"]', ['653847197508233493'], ['2', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002X"]', ['11010519491231002X'], ['X', True]], ['control ["11010519491231002x"]', ['11010519491231002x'], ['X', True]]]]
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 ["268310199103143528"]['4', False]['9', False]Failed
regression ["297547197007199229"]['8', False]['2', False]Failed
control ["11010519491231002"]malformedmalformedPassed
control ["1101051949123100XX"]malformedmalformedPassed
control ["518849198106269933"]['6', False]['6', False]Passed
control ["405799197903155930"]['8', False]['7', False]Failed
control ["445793197510028320"]['6', False]['X', False]Failed
control ["309071197409120443"]['5', False]['3', True]Failed

SHA-256 / 66f38f0b6a819b39f90e5f4f41cf2984d5da27e01ace48b610c0205c48b8c294

3 / The verified repair

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

N = 1
observations = []
def solve(s):
    if len(s) != 18 or not s.isascii() or not s[:17].isdigit():
        return 'malformed'
    total = sum(int(ch) * pow(2, 17 - i, 11) for i, ch in enumerate(s[:17]))
    check = '10X98765432'[total % 11]
    return [check, check == s[17].upper()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["268310199103143528"]', ['268310199103143528'], ['9', False]], ['regression ["297547197007199229"]', ['297547197007199229'], ['2', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["518849198106269933"]', ['518849198106269933'], ['6', False]], ['control ["405799197903155930"]', ['405799197903155930'], ['7', False]], ['control ["445793197510028320"]', ['445793197510028320'], ['X', False]], ['control ["309071197409120443"]', ['309071197409120443'], ['3', True]]], [['regression ["405799197903155930"]', ['405799197903155930'], ['7', False]], ['regression ["445793197510028320"]', ['445793197510028320'], ['X', False]], ['partial-repair ["309071197409120443"]', ['309071197409120443'], ['3', True]], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["458825200412201114"]', ['458825200412201114'], ['5', False]], ['control ["373498196811139070"]', ['373498196811139070'], ['5', False]], ['control ["18951819720314318X"]', ['18951819720314318X'], ['3', False]]], [['regression ["594570196107138355"]', ['594570196107138355'], ['2', False]], ['regression ["458825200412201114"]', ['458825200412201114'], ['5', False]], ['partial-repair ["373498196811139070"]', ['373498196811139070'], ['5', False]], ['partial-repair ["18951819720314318X"]', ['18951819720314318X'], ['3', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['control ["37858219960314414X"]', ['37858219960314414X'], ['7', False]]], [['regression ["18951819720314318X"]', ['18951819720314318X'], ['3', False]], ['regression ["50937819800315206x"]', ['50937819800315206x'], ['9', False]], ['partial-repair ["600025197711283200"]', ['600025197711283200'], ['5', False]], ['partial-repair ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["261917197009053555"]', ['261917197009053555'], ['3', False]], ['control ["607248198301138071"]', ['607248198301138071'], ['9', False]]], [['regression ["197110195609245785"]', ['197110195609245785'], ['6', False]], ['regression ["37858219960314414X"]', ['37858219960314414X'], ['7', False]], ['partial-repair ["22100419730209591X"]', ['22100419730209591X'], ['4', False]], ['partial-repair ["653847197508233493"]', ['653847197508233493'], ['2', False]], ['control ["11010519491231002"]', ['11010519491231002'], 'malformed'], ['control ["1101051949123100XX"]', ['1101051949123100XX'], 'malformed'], ['control ["11010519491231002X"]', ['11010519491231002X'], ['X', True]], ['control ["11010519491231002x"]', ['11010519491231002x'], ['X', True]]]]
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 ["268310199103143528"]['9', False]['9', False]Passed
regression ["297547197007199229"]['2', False]['2', False]Passed
control ["11010519491231002"]malformedmalformedPassed
control ["1101051949123100XX"]malformedmalformedPassed
control ["518849198106269933"]['6', False]['6', False]Passed
control ["405799197903155930"]['7', False]['7', False]Passed
control ["445793197510028320"]['X', False]['X', False]Passed
control ["309071197409120443"]['3', True]['3', True]Passed

SHA-256 / 1b007ade85e0f71b61f59790bbeacf28fe1640f0c1d1986ff0603996bb4309b7

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

Case digest / 6a582bef0f5d0b797088ea8ab928b660a32da574c94b0bb98d496f0326eabff2