{"abstract":"Typing \"1\" shows \"1 \" and the caret jumps.","category":"Phone number formatting","checks":11,"contract":"Input the digits typed so far. A leading 1 becomes the prefix \"1 \". With more than ten remaining digits the raw input is returned. Up to 3 digits are shown bare; 4..6 as \"(AAA) E..\"; 7..10 as \"(AAA) EEE-S...\". The result is stripped of surrounding spaces.","contract_signature":"x","evaluation_group":"w2-phone-number-formatting-as-you-type","failed_approach":"Stripping the prefix itself glues it to the body: \"1555\".","family":"w2-phone-number-formatting-as-you-type-trailing-space","id":"FA-96581","implementations":{"attempt":{"sha256":"e0ab028e1b21d8f43267b4d9a117cf2c54f13a1202c83408bd2a2699ea964fbe","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    d = x\n    prefix = ''\n    if d.startswith('1'):\n        prefix, d = '1 ', d[1:]\n    if len(d) > 10:\n        return x\n    if len(d) <= 3:\n        body = d\n    elif len(d) <= 6:\n        body = '(' + d[:3] + ') ' + d[3:]\n    else:\n        body = '(' + d[:3] + ') ' + d[3:6] + '-' + d[6:]\n    return prefix.strip() + body\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['first digit', '5', '5'], ['three digits stay bare', '555', '555'], ['fourth digit opens the area', '5550', '(555) 0'], ['six digits without hyphen', '555011', '(555) 011'], ['seventh digit adds the hyphen', '5550113', '(555) 011-3'], ['complete number', '5550113456', '(555) 011-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1555', '1 555'], ['national prefix with full number', '15550113456', '1 (555) 011-3456'], ['too many digits after the prefix', '155501134561', '155501134561'], ['too many digits without prefix', '55501134561', '55501134561']], [['first digit', '6', '6'], ['three digits stay bare', '655', '655'], ['fourth digit opens the area', '6550', '(655) 0'], ['six digits without hyphen', '655012', '(655) 012'], ['seventh digit adds the hyphen', '6550123', '(655) 012-3'], ['complete number', '6550123456', '(655) 012-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1655', '1 655'], ['national prefix with full number', '16550123456', '1 (655) 012-3456'], ['too many digits after the prefix', '165501234562', '165501234562'], ['too many digits without prefix', '65501234562', '65501234562']], [['first digit', '7', '7'], ['three digits stay bare', '755', '755'], ['fourth digit opens the area', '7550', '(755) 0'], ['six digits without hyphen', '755013', '(755) 013'], ['seventh digit adds the hyphen', '7550133', '(755) 013-3'], ['complete number', '7550133456', '(755) 013-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1755', '1 755'], ['national prefix with full number', '17550133456', '1 (755) 013-3456'], ['too many digits after the prefix', '175501334563', '175501334563'], ['too many digits without prefix', '75501334563', '75501334563']], [['first digit', '8', '8'], ['three digits stay bare', '855', '855'], ['fourth digit opens the area', '8550', '(855) 0'], ['six digits without hyphen', '855014', '(855) 014'], ['seventh digit adds the hyphen', '8550143', '(855) 014-3'], ['complete number', '8550143456', '(855) 014-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1855', '1 855'], ['national prefix with full number', '18550143456', '1 (855) 014-3456'], ['too many digits after the prefix', '185501434564', '185501434564'], ['too many digits without prefix', '85501434564', '85501434564']], [['first digit', '9', '9'], ['three digits stay bare', '955', '955'], ['fourth digit opens the area', '9550', '(955) 0'], ['six digits without hyphen', '955015', '(955) 015'], ['seventh digit adds the hyphen', '9550153', '(955) 015-3'], ['complete number', '9550153456', '(955) 015-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1955', '1 955'], ['national prefix with full number', '19550153456', '1 (955) 015-3456'], ['too many digits after the prefix', '195501534565', '195501534565'], ['too many digits without prefix', '95501534565', '95501534565']]]\nfor label, arg, expected in fixtures[N - 1]:\n    check(label, solve(arg), 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":"0eb24f19456cf8e9b1286666c639228f1d2569c58b14b9f0acce926d556ffa4e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    d = x\n    prefix = ''\n    if d.startswith('1'):\n        prefix, d = '1 ', d[1:]\n    if len(d) > 10:\n        return x\n    if len(d) <= 3:\n        body = d\n    elif len(d) <= 6:\n        body = '(' + d[:3] + ') ' + d[3:]\n    else:\n        body = '(' + d[:3] + ') ' + d[3:6] + '-' + d[6:]\n    return prefix + body\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['first digit', '5', '5'], ['three digits stay bare', '555', '555'], ['fourth digit opens the area', '5550', '(555) 0'], ['six digits without hyphen', '555011', '(555) 011'], ['seventh digit adds the hyphen', '5550113', '(555) 011-3'], ['complete number', '5550113456', '(555) 011-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1555', '1 555'], ['national prefix with full number', '15550113456', '1 (555) 011-3456'], ['too many digits after the prefix', '155501134561', '155501134561'], ['too many digits without prefix', '55501134561', '55501134561']], [['first digit', '6', '6'], ['three digits stay bare', '655', '655'], ['fourth digit opens the area', '6550', '(655) 0'], ['six digits without hyphen', '655012', '(655) 012'], ['seventh digit adds the hyphen', '6550123', '(655) 012-3'], ['complete number', '6550123456', '(655) 012-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1655', '1 655'], ['national prefix with full number', '16550123456', '1 (655) 012-3456'], ['too many digits after the prefix', '165501234562', '165501234562'], ['too many digits without prefix', '65501234562', '65501234562']], [['first digit', '7', '7'], ['three digits stay bare', '755', '755'], ['fourth digit opens the area', '7550', '(755) 0'], ['six digits without hyphen', '755013', '(755) 013'], ['seventh digit adds the hyphen', '7550133', '(755) 013-3'], ['complete number', '7550133456', '(755) 013-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1755', '1 755'], ['national prefix with full number', '17550133456', '1 (755) 013-3456'], ['too many digits after the prefix', '175501334563', '175501334563'], ['too many digits without prefix', '75501334563', '75501334563']], [['first digit', '8', '8'], ['three digits stay bare', '855', '855'], ['fourth digit opens the area', '8550', '(855) 0'], ['six digits without hyphen', '855014', '(855) 014'], ['seventh digit adds the hyphen', '8550143', '(855) 014-3'], ['complete number', '8550143456', '(855) 014-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1855', '1 855'], ['national prefix with full number', '18550143456', '1 (855) 014-3456'], ['too many digits after the prefix', '185501434564', '185501434564'], ['too many digits without prefix', '85501434564', '85501434564']], [['first digit', '9', '9'], ['three digits stay bare', '955', '955'], ['fourth digit opens the area', '9550', '(955) 0'], ['six digits without hyphen', '955015', '(955) 015'], ['seventh digit adds the hyphen', '9550153', '(955) 015-3'], ['complete number', '9550153456', '(955) 015-3456'], ['lone national prefix', '1', '1'], ['national prefix with three digits', '1955', '1 955'], ['national prefix with full number', '19550153456', '1 (955) 015-3456'], ['too many digits after the prefix', '195501534565', '195501534565'], ['too many digits without prefix', '95501534565', '95501534565']]]\nfor label, arg, expected in fixtures[N - 1]:\n    check(label, solve(arg), 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 toy contract over synthetic, obviously fictitious telephone numbers and toy country tables. The rules are stipulated for this model only and make no claim of conformance with any numbering plan or telecommunications standard. 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-phone-number-formatting-as-you-type-trailing-space","generated_at":"2026-09-29T14:52:24.038614+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Input masks re-render on every keystroke; premature punctuation or a lost prefix makes the caret jump and corrupts what users type.","root_cause":"The combined prefix and body is not stripped.","sha256":"2f49cd844e083d4d5991226895427a9d1c76a56c1abb9a487003c14188a3ac2d","title":"As-you-type ten-digit formatter: a lone prefix keeps its trailing space · 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":39.418,"exit_code":1,"observations":[{"actual":"5","check":"first digit","expected":"5","passed":true},{"actual":"555","check":"three digits stay bare","expected":"555","passed":true},{"actual":"(555) 0","check":"fourth digit opens the area","expected":"(555) 0","passed":true},{"actual":"(555) 011","check":"six digits without hyphen","expected":"(555) 011","passed":true},{"actual":"(555) 011-3","check":"seventh digit adds the hyphen","expected":"(555) 011-3","passed":true},{"actual":"(555) 011-3456","check":"complete number","expected":"(555) 011-3456","passed":true},{"actual":"1","check":"lone national prefix","expected":"1","passed":true},{"actual":"1555","check":"national prefix with three digits","expected":"1 555","passed":false},{"actual":"1(555) 011-3456","check":"national prefix with full number","expected":"1 (555) 011-3456","passed":false},{"actual":"155501134561","check":"too many digits after the prefix","expected":"155501134561","passed":true},{"actual":"55501134561","check":"too many digits without prefix","expected":"55501134561","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"first digit\", \"actual\": \"5\", \"expected\": \"5\", \"passed\": true}, {\"check\": \"three digits stay bare\", \"actual\": \"555\", \"expected\": \"555\", \"passed\": true}, {\"check\": \"fourth digit opens the area\", \"actual\": \"(555) 0\", \"expected\": \"(555) 0\", \"passed\": true}, {\"check\": \"six digits without hyphen\", \"actual\": \"(555) 011\", \"expected\": \"(555) 011\", \"passed\": true}, {\"check\": \"seventh digit adds the hyphen\", \"actual\": \"(555) 011-3\", \"expected\": \"(555) 011-3\", \"passed\": true}, {\"check\": \"complete number\", \"actual\": \"(555) 011-3456\", \"expected\": \"(555) 011-3456\", \"passed\": true}, {\"check\": \"lone national prefix\", \"actual\": \"1\", \"expected\": \"1\", \"passed\": true}, {\"check\": \"national prefix with three digits\", \"actual\": \"1555\", \"expected\": \"1 555\", \"passed\": false}, {\"check\": \"national prefix with full number\", \"actual\": \"1(555) 011-3456\", \"expected\": \"1 (555) 011-3456\", \"passed\": false}, {\"check\": \"too many digits after the prefix\", \"actual\": \"155501134561\", \"expected\": \"155501134561\", \"passed\": true}, {\"check\": \"too many digits without prefix\", \"actual\": \"55501134561\", \"expected\": \"55501134561\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.2,"exit_code":1,"observations":[{"actual":"5","check":"first digit","expected":"5","passed":true},{"actual":"555","check":"three digits stay bare","expected":"555","passed":true},{"actual":"(555) 0","check":"fourth digit opens the area","expected":"(555) 0","passed":true},{"actual":"(555) 011","check":"six digits without hyphen","expected":"(555) 011","passed":true},{"actual":"(555) 011-3","check":"seventh digit adds the hyphen","expected":"(555) 011-3","passed":true},{"actual":"(555) 011-3456","check":"complete number","expected":"(555) 011-3456","passed":true},{"actual":"1 ","check":"lone national prefix","expected":"1","passed":false},{"actual":"1 555","check":"national prefix with three digits","expected":"1 555","passed":true},{"actual":"1 (555) 011-3456","check":"national prefix with full number","expected":"1 (555) 011-3456","passed":true},{"actual":"155501134561","check":"too many digits after the prefix","expected":"155501134561","passed":true},{"actual":"55501134561","check":"too many digits without prefix","expected":"55501134561","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"first digit\", \"actual\": \"5\", \"expected\": \"5\", \"passed\": true}, {\"check\": \"three digits stay bare\", \"actual\": \"555\", \"expected\": \"555\", \"passed\": true}, {\"check\": \"fourth digit opens the area\", \"actual\": \"(555) 0\", \"expected\": \"(555) 0\", \"passed\": true}, {\"check\": \"six digits without hyphen\", \"actual\": \"(555) 011\", \"expected\": \"(555) 011\", \"passed\": true}, {\"check\": \"seventh digit adds the hyphen\", \"actual\": \"(555) 011-3\", \"expected\": \"(555) 011-3\", \"passed\": true}, {\"check\": \"complete number\", \"actual\": \"(555) 011-3456\", \"expected\": \"(555) 011-3456\", \"passed\": true}, {\"check\": \"lone national prefix\", \"actual\": \"1 \", \"expected\": \"1\", \"passed\": false}, {\"check\": \"national prefix with three digits\", \"actual\": \"1 555\", \"expected\": \"1 555\", \"passed\": true}, {\"check\": \"national prefix with full number\", \"actual\": \"1 (555) 011-3456\", \"expected\": \"1 (555) 011-3456\", \"passed\": true}, {\"check\": \"too many digits after the prefix\", \"actual\": \"155501134561\", \"expected\": \"155501134561\", \"passed\": true}, {\"check\": \"too many digits without prefix\", \"actual\": \"55501134561\", \"expected\": \"55501134561\", \"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."}}