{"abstract":"Recovery succeeds only when the number length makes left and right parity agree.","category":"Check-digit algorithms","checks":8,"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.","contract_signature":"s","evaluation_group":"w2-check_digit_algorithms-luhn-missing-digit","failed_approach":"Using len(s) - s.index(\"?\") is off by one and flips the parity.","family":"w2-check_digit_algorithms-luhn-missing-digit-unknown-position-origin","id":"FA-72801","implementations":{"attempt":{"sha256":"8c27f52d524c595be8b1c3e16568fdf57d99994a7a4508088f3252a97f12cd4f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(s):\n    if len(s) < 2 or s.count('?') != 1 or not s.isascii() or not all(c.isdigit() or c == '?' for c in s):\n        return None\n    k = len(s) - s.index('?')\n    total = 0\n    for i, ch in enumerate(reversed(s)):\n        if ch == '?':\n            continue\n        d = int(ch)\n        if i % 2 == 1:\n            d = d * 2 - 9 if d > 4 else d * 2\n        total += d\n    need = (10 - total % 10) % 10\n    if k % 2 == 1:\n        need = need // 2 if need % 2 == 0 else (need + 9) // 2\n    return need\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression [\"766?9906\"]', ['766?9906'], 2], ['regression [\"?929942967\"]', ['?929942967'], 1], ['partial-repair [\"7?850\"]', ['7?850'], 2], ['control [\"475646793469?297\"]', ['475646793469?297'], 0], ['control [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"??\"]', ['??'], None], ['control [\"1\"]', ['1'], None], ['control [\"12a?\"]', ['12a?'], None]], [['regression [\"3077312?96877436\"]', ['3077312?96877436'], 1], ['regression [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['partial-repair [\"1519774?1518\"]', ['1519774?1518'], 5], ['partial-repair [\"049785409775?16\"]', ['049785409775?16'], 5], ['control [\"?\"]', ['?'], None], ['control [\"?0\"]', ['?0'], 0], ['control [\"0?\"]', ['0?'], 0], ['control [\"475646793469?297\"]', ['475646793469?297'], 0]], [['regression [\"1507302?557627\"]', ['1507302?557627'], 8], ['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['partial-repair [\"6?0334555\"]', ['6?0334555'], 3], ['partial-repair [\"033?959838019\"]', ['033?959838019'], 2], ['control [\"??\"]', ['??'], None], ['control [\"1\"]', ['1'], None], ['control [\"12a?\"]', ['12a?'], None], ['control [\"?\"]', ['?'], None]], [['regression [\"?929942967\"]', ['?929942967'], 1], ['regression [\"1519774?1518\"]', ['1519774?1518'], 5], ['partial-repair [\"08?8016\"]', ['08?8016'], 8], ['partial-repair [\"2288?7\"]', ['2288?7'], 1], ['control [\"0?\"]', ['0?'], 0], ['control [\"475646793469?297\"]', ['475646793469?297'], 0], ['control [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"??\"]', ['??'], None]], [['regression [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['regression [\"2288?7\"]', ['2288?7'], 1], ['partial-repair [\"7992739871?\"]', ['7992739871?'], 3], ['partial-repair [\"?9927398713\"]', ['?9927398713'], 7], ['control [\"12a?\"]', ['12a?'], None], ['control [\"?\"]', ['?'], None], ['control [\"?0\"]', ['?0'], 0], ['control [\"0?\"]', ['0?'], 0]]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"ac6706ce557ecaff89753cae29d44e4834325c712a92091dcfb4ca4005c28745","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(s):\n    if len(s) < 2 or s.count('?') != 1 or not s.isascii() or not all(c.isdigit() or c == '?' for c in s):\n        return None\n    k = s.index('?')\n    total = 0\n    for i, ch in enumerate(reversed(s)):\n        if ch == '?':\n            continue\n        d = int(ch)\n        if i % 2 == 1:\n            d = d * 2 - 9 if d > 4 else d * 2\n        total += d\n    need = (10 - total % 10) % 10\n    if k % 2 == 1:\n        need = need // 2 if need % 2 == 0 else (need + 9) // 2\n    return need\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression [\"766?9906\"]', ['766?9906'], 2], ['regression [\"?929942967\"]', ['?929942967'], 1], ['partial-repair [\"7?850\"]', ['7?850'], 2], ['control [\"475646793469?297\"]', ['475646793469?297'], 0], ['control [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"??\"]', ['??'], None], ['control [\"1\"]', ['1'], None], ['control [\"12a?\"]', ['12a?'], None]], [['regression [\"3077312?96877436\"]', ['3077312?96877436'], 1], ['regression [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['partial-repair [\"1519774?1518\"]', ['1519774?1518'], 5], ['partial-repair [\"049785409775?16\"]', ['049785409775?16'], 5], ['control [\"?\"]', ['?'], None], ['control [\"?0\"]', ['?0'], 0], ['control [\"0?\"]', ['0?'], 0], ['control [\"475646793469?297\"]', ['475646793469?297'], 0]], [['regression [\"1507302?557627\"]', ['1507302?557627'], 8], ['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['partial-repair [\"6?0334555\"]', ['6?0334555'], 3], ['partial-repair [\"033?959838019\"]', ['033?959838019'], 2], ['control [\"??\"]', ['??'], None], ['control [\"1\"]', ['1'], None], ['control [\"12a?\"]', ['12a?'], None], ['control [\"?\"]', ['?'], None]], [['regression [\"?929942967\"]', ['?929942967'], 1], ['regression [\"1519774?1518\"]', ['1519774?1518'], 5], ['partial-repair [\"08?8016\"]', ['08?8016'], 8], ['partial-repair [\"2288?7\"]', ['2288?7'], 1], ['control [\"0?\"]', ['0?'], 0], ['control [\"475646793469?297\"]', ['475646793469?297'], 0], ['control [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"??\"]', ['??'], None]], [['regression [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['regression [\"2288?7\"]', ['2288?7'], 1], ['partial-repair [\"7992739871?\"]', ['7992739871?'], 3], ['partial-repair [\"?9927398713\"]', ['?9927398713'], 7], ['control [\"12a?\"]', ['12a?'], None], ['control [\"?\"]', ['?'], None], ['control [\"?0\"]', ['?0'], 0], ['control [\"0?\"]', ['0?'], 0]]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-check_digit_algorithms-luhn-missing-digit-unknown-position-origin","generated_at":"2026-09-29T14:48:41.639904+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Customer-service tools reconstruct a smudged or misheard digit of an account number.","root_cause":"The unknown index k is taken from the left (s.index(\"?\")), but Luhn parity counts from the right.","sha256":"c84a88299a3cdbdf425d168c7972abab7ec975557223f974a0ed4fa41d469c21","title":"Missing-digit recovery measures the unknown from the left · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":40.757,"exit_code":1,"observations":[{"actual":1,"check":"regression [\"766?9906\"]","expected":2,"passed":false},{"actual":2,"check":"regression [\"?929942967\"]","expected":1,"passed":false},{"actual":4,"check":"partial-repair [\"7?850\"]","expected":2,"passed":false},{"actual":0,"check":"control [\"475646793469?297\"]","expected":0,"passed":true},{"actual":9,"check":"control [\"405529124?1\"]","expected":9,"passed":true},{"actual":null,"check":"control [\"??\"]","expected":null,"passed":true},{"actual":null,"check":"control [\"1\"]","expected":null,"passed":true},{"actual":null,"check":"control [\"12a?\"]","expected":null,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression [\\\"766?9906\\\"]\", \"actual\": 1, \"expected\": 2, \"passed\": false}, {\"check\": \"regression [\\\"?929942967\\\"]\", \"actual\": 2, \"expected\": 1, \"passed\": false}, {\"check\": \"partial-repair [\\\"7?850\\\"]\", \"actual\": 4, \"expected\": 2, \"passed\": false}, {\"check\": \"control [\\\"475646793469?297\\\"]\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"control [\\\"405529124?1\\\"]\", \"actual\": 9, \"expected\": 9, \"passed\": true}, {\"check\": \"control [\\\"??\\\"]\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control [\\\"1\\\"]\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control [\\\"12a?\\\"]\", \"actual\": null, \"expected\": null, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.498,"exit_code":1,"observations":[{"actual":1,"check":"regression [\"766?9906\"]","expected":2,"passed":false},{"actual":2,"check":"regression [\"?929942967\"]","expected":1,"passed":false},{"actual":2,"check":"partial-repair [\"7?850\"]","expected":2,"passed":true},{"actual":0,"check":"control [\"475646793469?297\"]","expected":0,"passed":true},{"actual":9,"check":"control [\"405529124?1\"]","expected":9,"passed":true},{"actual":null,"check":"control [\"??\"]","expected":null,"passed":true},{"actual":null,"check":"control [\"1\"]","expected":null,"passed":true},{"actual":null,"check":"control [\"12a?\"]","expected":null,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression [\\\"766?9906\\\"]\", \"actual\": 1, \"expected\": 2, \"passed\": false}, {\"check\": \"regression [\\\"?929942967\\\"]\", \"actual\": 2, \"expected\": 1, \"passed\": false}, {\"check\": \"partial-repair [\\\"7?850\\\"]\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"control [\\\"475646793469?297\\\"]\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"control [\\\"405529124?1\\\"]\", \"actual\": 9, \"expected\": 9, \"passed\": true}, {\"check\": \"control [\\\"??\\\"]\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control [\\\"1\\\"]\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control [\\\"12a?\\\"]\", \"actual\": null, \"expected\": null, \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}