{"abstract":"Unknown digits in doubled positions are recovered incorrectly.","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.","evaluation_group":"w2-check_digit_algorithms-luhn-missing-digit","failed_approach":"Halving only (need // 2) fails whenever the needed contribution is odd.","family":"w2-check_digit_algorithms-luhn-missing-digit-doubling-inverse","id":"FA-72796","implementations":{"attempt":{"sha256":"e5a5550e0fc2b8ea9b39f74fe9bff3d5e630a55b158a918a221d33da5ad6c4ad","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) - 1 - 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\n    return need\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression [\"7?850\"]', ['7?850'], 2], ['regression [\"?929942967\"]', ['?929942967'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"766?9906\"]', ['766?9906'], 2], ['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 [\"033?959838019\"]', ['033?959838019'], 2], ['regression [\"2288?7\"]', ['2288?7'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['control [\"08?8016\"]', ['08?8016'], 8], ['control [\"1507302?557627\"]', ['1507302?557627'], 8], ['control [\"7992739871?\"]', ['7992739871?'], 3], ['control [\"?9927398713\"]', ['?9927398713'], 7]], [['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['regression [\"7?850\"]', ['7?850'], 2], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"??\"]', ['??'], None], ['control [\"1\"]', ['1'], None], ['control [\"12a?\"]', ['12a?'], None], ['control [\"?\"]', ['?'], None], ['control [\"?0\"]', ['?0'], 0]], [['regression [\"6?0334555\"]', ['6?0334555'], 3], ['regression [\"033?959838019\"]', ['033?959838019'], 2], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"0?\"]', ['0?'], 0], ['control [\"766?9906\"]', ['766?9906'], 2], ['control [\"1519774?1518\"]', ['1519774?1518'], 5], ['control [\"049785409775?16\"]', ['049785409775?16'], 5], ['control [\"475646793469?297\"]', ['475646793469?297'], 0]], [['regression [\"79927?98713\"]', ['79927?98713'], 3], ['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"3077312?96877436\"]', ['3077312?96877436'], 1], ['control [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['control [\"08?8016\"]', ['08?8016'], 8], ['control [\"1507302?557627\"]', ['1507302?557627'], 8], ['control [\"7992739871?\"]', ['7992739871?'], 3]]]\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":"a108de9727c92b992729acf3c6ae4cc473fd478cc4fae72d1b8caeeda3d65370","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) - 1 - 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    return need\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression [\"7?850\"]', ['7?850'], 2], ['regression [\"?929942967\"]', ['?929942967'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"766?9906\"]', ['766?9906'], 2], ['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 [\"033?959838019\"]', ['033?959838019'], 2], ['regression [\"2288?7\"]', ['2288?7'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['control [\"08?8016\"]', ['08?8016'], 8], ['control [\"1507302?557627\"]', ['1507302?557627'], 8], ['control [\"7992739871?\"]', ['7992739871?'], 3], ['control [\"?9927398713\"]', ['?9927398713'], 7]], [['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['regression [\"7?850\"]', ['7?850'], 2], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"??\"]', ['??'], None], ['control [\"1\"]', ['1'], None], ['control [\"12a?\"]', ['12a?'], None], ['control [\"?\"]', ['?'], None], ['control [\"?0\"]', ['?0'], 0]], [['regression [\"6?0334555\"]', ['6?0334555'], 3], ['regression [\"033?959838019\"]', ['033?959838019'], 2], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"0?\"]', ['0?'], 0], ['control [\"766?9906\"]', ['766?9906'], 2], ['control [\"1519774?1518\"]', ['1519774?1518'], 5], ['control [\"049785409775?16\"]', ['049785409775?16'], 5], ['control [\"475646793469?297\"]', ['475646793469?297'], 0]], [['regression [\"79927?98713\"]', ['79927?98713'], 3], ['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"3077312?96877436\"]', ['3077312?96877436'], 1], ['control [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['control [\"08?8016\"]', ['08?8016'], 8], ['control [\"1507302?557627\"]', ['1507302?557627'], 8], ['control [\"7992739871?\"]', ['7992739871?'], 3]]]\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"},"fixed":{"sha256":"7c6c7348ecc0a2c58b2396f61bb2012617e53ede07d60cd170626c224a66f5ae","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) - 1 - 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 [\"7?850\"]', ['7?850'], 2], ['regression [\"?929942967\"]', ['?929942967'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"766?9906\"]', ['766?9906'], 2], ['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 [\"033?959838019\"]', ['033?959838019'], 2], ['regression [\"2288?7\"]', ['2288?7'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['control [\"08?8016\"]', ['08?8016'], 8], ['control [\"1507302?557627\"]', ['1507302?557627'], 8], ['control [\"7992739871?\"]', ['7992739871?'], 3], ['control [\"?9927398713\"]', ['?9927398713'], 7]], [['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['regression [\"7?850\"]', ['7?850'], 2], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"??\"]', ['??'], None], ['control [\"1\"]', ['1'], None], ['control [\"12a?\"]', ['12a?'], None], ['control [\"?\"]', ['?'], None], ['control [\"?0\"]', ['?0'], 0]], [['regression [\"6?0334555\"]', ['6?0334555'], 3], ['regression [\"033?959838019\"]', ['033?959838019'], 2], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"0?\"]', ['0?'], 0], ['control [\"766?9906\"]', ['766?9906'], 2], ['control [\"1519774?1518\"]', ['1519774?1518'], 5], ['control [\"049785409775?16\"]', ['049785409775?16'], 5], ['control [\"475646793469?297\"]', ['475646793469?297'], 0]], [['regression [\"79927?98713\"]', ['79927?98713'], 3], ['regression [\"4111111111?11111\"]', ['4111111111?11111'], 1], ['partial-repair [\"405529124?1\"]', ['405529124?1'], 9], ['control [\"3077312?96877436\"]', ['3077312?96877436'], 1], ['control [\"3102377592002?64\"]', ['3102377592002?64'], 6], ['control [\"08?8016\"]', ['08?8016'], 8], ['control [\"1507302?557627\"]', ['1507302?557627'], 8], ['control [\"7992739871?\"]', ['7992739871?'], 3]]]\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-doubling-inverse","generated_at":"2026-09-29T14:48:41.631091+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.","repair":"Invert the doubling map: an even need n comes from n / 2, an odd need from (n + 9) / 2.","root_cause":"The needed contribution is returned directly even when the unknown digit will be doubled.","sha256":"0c80b78f867da4379b8a3ddf12b9b55062e41536e3fcd9129562b99cd5269c98","title":"Missing-digit recovery ignores the doubling at the unknown position · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":39.643,"exit_code":1,"observations":[{"actual":2,"check":"regression [\"7?850\"]","expected":2,"passed":true},{"actual":1,"check":"regression [\"?929942967\"]","expected":1,"passed":true},{"actual":4,"check":"partial-repair [\"405529124?1\"]","expected":9,"passed":false},{"actual":2,"check":"control [\"766?9906\"]","expected":2,"passed":true},{"actual":5,"check":"control [\"1519774?1518\"]","expected":5,"passed":true},{"actual":5,"check":"control [\"049785409775?16\"]","expected":5,"passed":true},{"actual":0,"check":"control [\"475646793469?297\"]","expected":0,"passed":true},{"actual":1,"check":"control [\"3077312?96877436\"]","expected":1,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression [\\\"7?850\\\"]\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"regression [\\\"?929942967\\\"]\", \"actual\": 1, \"expected\": 1, \"passed\": true}, {\"check\": \"partial-repair [\\\"405529124?1\\\"]\", \"actual\": 4, \"expected\": 9, \"passed\": false}, {\"check\": \"control [\\\"766?9906\\\"]\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"control [\\\"1519774?1518\\\"]\", \"actual\": 5, \"expected\": 5, \"passed\": true}, {\"check\": \"control [\\\"049785409775?16\\\"]\", \"actual\": 5, \"expected\": 5, \"passed\": true}, {\"check\": \"control [\\\"475646793469?297\\\"]\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"control [\\\"3077312?96877436\\\"]\", \"actual\": 1, \"expected\": 1, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.413,"exit_code":1,"observations":[{"actual":4,"check":"regression [\"7?850\"]","expected":2,"passed":false},{"actual":2,"check":"regression [\"?929942967\"]","expected":1,"passed":false},{"actual":9,"check":"partial-repair [\"405529124?1\"]","expected":9,"passed":true},{"actual":2,"check":"control [\"766?9906\"]","expected":2,"passed":true},{"actual":5,"check":"control [\"1519774?1518\"]","expected":5,"passed":true},{"actual":5,"check":"control [\"049785409775?16\"]","expected":5,"passed":true},{"actual":0,"check":"control [\"475646793469?297\"]","expected":0,"passed":true},{"actual":1,"check":"control [\"3077312?96877436\"]","expected":1,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression [\\\"7?850\\\"]\", \"actual\": 4, \"expected\": 2, \"passed\": false}, {\"check\": \"regression [\\\"?929942967\\\"]\", \"actual\": 2, \"expected\": 1, \"passed\": false}, {\"check\": \"partial-repair [\\\"405529124?1\\\"]\", \"actual\": 9, \"expected\": 9, \"passed\": true}, {\"check\": \"control [\\\"766?9906\\\"]\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"control [\\\"1519774?1518\\\"]\", \"actual\": 5, \"expected\": 5, \"passed\": true}, {\"check\": \"control [\\\"049785409775?16\\\"]\", \"actual\": 5, \"expected\": 5, \"passed\": true}, {\"check\": \"control [\\\"475646793469?297\\\"]\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"control [\\\"3077312?96877436\\\"]\", \"actual\": 1, \"expected\": 1, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":43.383,"exit_code":0,"observations":[{"actual":2,"check":"regression [\"7?850\"]","expected":2,"passed":true},{"actual":1,"check":"regression [\"?929942967\"]","expected":1,"passed":true},{"actual":9,"check":"partial-repair [\"405529124?1\"]","expected":9,"passed":true},{"actual":2,"check":"control [\"766?9906\"]","expected":2,"passed":true},{"actual":5,"check":"control [\"1519774?1518\"]","expected":5,"passed":true},{"actual":5,"check":"control [\"049785409775?16\"]","expected":5,"passed":true},{"actual":0,"check":"control [\"475646793469?297\"]","expected":0,"passed":true},{"actual":1,"check":"control [\"3077312?96877436\"]","expected":1,"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression [\\\"7?850\\\"]\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"regression [\\\"?929942967\\\"]\", \"actual\": 1, \"expected\": 1, \"passed\": true}, {\"check\": \"partial-repair [\\\"405529124?1\\\"]\", \"actual\": 9, \"expected\": 9, \"passed\": true}, {\"check\": \"control [\\\"766?9906\\\"]\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"control [\\\"1519774?1518\\\"]\", \"actual\": 5, \"expected\": 5, \"passed\": true}, {\"check\": \"control [\\\"049785409775?16\\\"]\", \"actual\": 5, \"expected\": 5, \"passed\": true}, {\"check\": \"control [\\\"475646793469?297\\\"]\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"control [\\\"3077312?96877436\\\"]\", \"actual\": 1, \"expected\": 1, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}