FAILURE MAP
← Case archive

FA-72806 / Check-digit algorithms / Open access

Missing-digit recovery answers with two unknowns · case 01

Inputs with several unknown digits get a confident single answer.

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

ROOT CAUSE

The gate only requires that some "?" is present.

VERIFIED REPAIR

Require exactly one "?"; several unknowns have no unique answer.

Unsuccessful approach: Rejecting three or more unknowns still answers ambiguous two-unknown inputs.

Case contract

Recover the single unknown digit (marked "?") in a Luhn-protected number: input must be at least two characters, ASCII digits and exactly one "?" (else None). Return the digit 0-9 that makes the whole number Luhn-valid; when the unknown sits in a doubled position the needed contribution must be mapped back through the doubling map.

Why this case matters

Customer-service tools reconstruct a smudged or misheard digit of an account number.

1 / The failure

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

N = 1
observations = []
def solve(s):
    if len(s) < 2 or '?' not in s or not s.isascii() or not all(c.isdigit() or c == '?' for c in s):
        return None
    k = len(s) - 1 - s.index('?')
    total = 0
    for i, ch in enumerate(reversed(s)):
        if ch == '?':
            continue
        d = int(ch)
        if i % 2 == 1:
            d = d * 2 - 9 if d > 4 else d * 2
        total += d
    need = (10 - total % 10) % 10
    if k % 2 == 1:
        need = need // 2 if need % 2 == 0 else (need + 9) // 2
    return need
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["??"]', ['??'], None], ['control ["7?850"]', ['7?850'], 2], ['control ["766?9906"]', ['766?9906'], 2], ['control ["?929942967"]', ['?929942967'], 1], ['control ["1519774?1518"]', ['1519774?1518'], 5], ['control ["049785409775?16"]', ['049785409775?16'], 5], ['control ["475646793469?297"]', ['475646793469?297'], 0], ['control ["3077312?96877436"]', ['3077312?96877436'], 1]], [['regression ["??"]', ['??'], None], ['control ["475646793469?297"]', ['475646793469?297'], 0], ['control ["3077312?96877436"]', ['3077312?96877436'], 1], ['control ["405529124?1"]', ['405529124?1'], 9], ['control ["6?0334555"]', ['6?0334555'], 3], ['control ["033?959838019"]', ['033?959838019'], 2], ['control ["3102377592002?64"]', ['3102377592002?64'], 6], ['control ["08?8016"]', ['08?8016'], 8]], [['regression ["??"]', ['??'], None], ['control ["3102377592002?64"]', ['3102377592002?64'], 6], ['control ["08?8016"]', ['08?8016'], 8], ['control ["2288?7"]', ['2288?7'], 1], ['control ["1507302?557627"]', ['1507302?557627'], 8], ['control ["7992739871?"]', ['7992739871?'], 3], ['control ["?9927398713"]', ['?9927398713'], 7], ['control ["79927?98713"]', ['79927?98713'], 3]], [['regression ["??"]', ['??'], None], ['control ["?9927398713"]', ['?9927398713'], 7], ['control ["79927?98713"]', ['79927?98713'], 3], ['control ["4111111111?11111"]', ['4111111111?11111'], 1], ['control ["1"]', ['1'], None], ['control ["12a?"]', ['12a?'], None], ['control ["?"]', ['?'], None], ['control ["?0"]', ['?0'], 0]], [['regression ["??"]', ['??'], None], ['control ["?"]', ['?'], None], ['control ["?0"]', ['?0'], 0], ['control ["0?"]', ['0?'], 0], ['control ["7?850"]', ['7?850'], 2], ['control ["766?9906"]', ['766?9906'], 2], ['control ["?929942967"]', ['?929942967'], 1], ['control ["1519774?1518"]', ['1519774?1518'], 5]]]
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 ["??"]0NoneFailed
control ["7?850"]22Passed
control ["766?9906"]22Passed
control ["?929942967"]11Passed
control ["1519774?1518"]55Passed
control ["049785409775?16"]55Passed
control ["475646793469?297"]00Passed
control ["3077312?96877436"]11Passed

SHA-256 / b3f243be563afc308f384ed9955021683870269e8fb3e1f66522bbcfb06e5c20

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) < 2 or not 1 <= s.count('?') <= 2 or not s.isascii() or not all(c.isdigit() or c == '?' for c in s):
        return None
    k = len(s) - 1 - s.index('?')
    total = 0
    for i, ch in enumerate(reversed(s)):
        if ch == '?':
            continue
        d = int(ch)
        if i % 2 == 1:
            d = d * 2 - 9 if d > 4 else d * 2
        total += d
    need = (10 - total % 10) % 10
    if k % 2 == 1:
        need = need // 2 if need % 2 == 0 else (need + 9) // 2
    return need
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["??"]', ['??'], None], ['control ["7?850"]', ['7?850'], 2], ['control ["766?9906"]', ['766?9906'], 2], ['control ["?929942967"]', ['?929942967'], 1], ['control ["1519774?1518"]', ['1519774?1518'], 5], ['control ["049785409775?16"]', ['049785409775?16'], 5], ['control ["475646793469?297"]', ['475646793469?297'], 0], ['control ["3077312?96877436"]', ['3077312?96877436'], 1]], [['regression ["??"]', ['??'], None], ['control ["475646793469?297"]', ['475646793469?297'], 0], ['control ["3077312?96877436"]', ['3077312?96877436'], 1], ['control ["405529124?1"]', ['405529124?1'], 9], ['control ["6?0334555"]', ['6?0334555'], 3], ['control ["033?959838019"]', ['033?959838019'], 2], ['control ["3102377592002?64"]', ['3102377592002?64'], 6], ['control ["08?8016"]', ['08?8016'], 8]], [['regression ["??"]', ['??'], None], ['control ["3102377592002?64"]', ['3102377592002?64'], 6], ['control ["08?8016"]', ['08?8016'], 8], ['control ["2288?7"]', ['2288?7'], 1], ['control ["1507302?557627"]', ['1507302?557627'], 8], ['control ["7992739871?"]', ['7992739871?'], 3], ['control ["?9927398713"]', ['?9927398713'], 7], ['control ["79927?98713"]', ['79927?98713'], 3]], [['regression ["??"]', ['??'], None], ['control ["?9927398713"]', ['?9927398713'], 7], ['control ["79927?98713"]', ['79927?98713'], 3], ['control ["4111111111?11111"]', ['4111111111?11111'], 1], ['control ["1"]', ['1'], None], ['control ["12a?"]', ['12a?'], None], ['control ["?"]', ['?'], None], ['control ["?0"]', ['?0'], 0]], [['regression ["??"]', ['??'], None], ['control ["?"]', ['?'], None], ['control ["?0"]', ['?0'], 0], ['control ["0?"]', ['0?'], 0], ['control ["7?850"]', ['7?850'], 2], ['control ["766?9906"]', ['766?9906'], 2], ['control ["?929942967"]', ['?929942967'], 1], ['control ["1519774?1518"]', ['1519774?1518'], 5]]]
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 ["??"]0NoneFailed
control ["7?850"]22Passed
control ["766?9906"]22Passed
control ["?929942967"]11Passed
control ["1519774?1518"]55Passed
control ["049785409775?16"]55Passed
control ["475646793469?297"]00Passed
control ["3077312?96877436"]11Passed

SHA-256 / ab030f0b098df64033be3138d9ff610b14cf682d3e4bbb9cd76d1698791fe83b

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) < 2 or s.count('?') != 1 or not s.isascii() or not all(c.isdigit() or c == '?' for c in s):
        return None
    k = len(s) - 1 - s.index('?')
    total = 0
    for i, ch in enumerate(reversed(s)):
        if ch == '?':
            continue
        d = int(ch)
        if i % 2 == 1:
            d = d * 2 - 9 if d > 4 else d * 2
        total += d
    need = (10 - total % 10) % 10
    if k % 2 == 1:
        need = need // 2 if need % 2 == 0 else (need + 9) // 2
    return need
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["??"]', ['??'], None], ['control ["7?850"]', ['7?850'], 2], ['control ["766?9906"]', ['766?9906'], 2], ['control ["?929942967"]', ['?929942967'], 1], ['control ["1519774?1518"]', ['1519774?1518'], 5], ['control ["049785409775?16"]', ['049785409775?16'], 5], ['control ["475646793469?297"]', ['475646793469?297'], 0], ['control ["3077312?96877436"]', ['3077312?96877436'], 1]], [['regression ["??"]', ['??'], None], ['control ["475646793469?297"]', ['475646793469?297'], 0], ['control ["3077312?96877436"]', ['3077312?96877436'], 1], ['control ["405529124?1"]', ['405529124?1'], 9], ['control ["6?0334555"]', ['6?0334555'], 3], ['control ["033?959838019"]', ['033?959838019'], 2], ['control ["3102377592002?64"]', ['3102377592002?64'], 6], ['control ["08?8016"]', ['08?8016'], 8]], [['regression ["??"]', ['??'], None], ['control ["3102377592002?64"]', ['3102377592002?64'], 6], ['control ["08?8016"]', ['08?8016'], 8], ['control ["2288?7"]', ['2288?7'], 1], ['control ["1507302?557627"]', ['1507302?557627'], 8], ['control ["7992739871?"]', ['7992739871?'], 3], ['control ["?9927398713"]', ['?9927398713'], 7], ['control ["79927?98713"]', ['79927?98713'], 3]], [['regression ["??"]', ['??'], None], ['control ["?9927398713"]', ['?9927398713'], 7], ['control ["79927?98713"]', ['79927?98713'], 3], ['control ["4111111111?11111"]', ['4111111111?11111'], 1], ['control ["1"]', ['1'], None], ['control ["12a?"]', ['12a?'], None], ['control ["?"]', ['?'], None], ['control ["?0"]', ['?0'], 0]], [['regression ["??"]', ['??'], None], ['control ["?"]', ['?'], None], ['control ["?0"]', ['?0'], 0], ['control ["0?"]', ['0?'], 0], ['control ["7?850"]', ['7?850'], 2], ['control ["766?9906"]', ['766?9906'], 2], ['control ["?929942967"]', ['?929942967'], 1], ['control ["1519774?1518"]', ['1519774?1518'], 5]]]
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 ["??"]NoneNonePassed
control ["7?850"]22Passed
control ["766?9906"]22Passed
control ["?929942967"]11Passed
control ["1519774?1518"]55Passed
control ["049785409775?16"]55Passed
control ["475646793469?297"]00Passed
control ["3077312?96877436"]11Passed

SHA-256 / 2f02150e7b89a8d33ad5f0455ca02d0aa86364d982eb61cc973246ab8f3bd639

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

Case digest / 5e7e8c8acf47c6dc19de54f9ad14787e1459f5c7d115da097efbb95571460398