{"abstract":"\"04012 ...\" is grouped as area 040.","category":"Phone number formatting","checks":8,"contract":"Keep digits and drop one leading trunk 0; nine national digits must remain. Numbers starting 7 are mobile with a four-digit block code; otherwise the area code is the longest match from 2, 30, 31, 40, 4012 (no match -> None). The subscriber part is one group if at most 5 digits, two equal halves if even, else 3 then the rest. Return \"0\" + area + \" \" + groups joined by spaces.","evaluation_group":"w2-phone-number-formatting-area-grouping","failed_approach":"Taking the first match in table order still picks 40 before 4012.","family":"w2-phone-number-formatting-area-grouping-longest-area","id":"FA-96396","implementations":{"attempt":{"sha256":"8ebcb9704a2e14d4dc8689137c6a65b5b4785df2dd86af1bbee5086ad131655f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    AREAS = ['2', '30', '31', '40', '4012']\n    d = ''.join(c for c in x if c.isdigit())\n    if d.startswith('0'):\n        d = d[1:]\n    if len(d) != 9:\n        return None\n    if d[0] == '7':\n        area = d[:4]\n    else:\n        area = next((a for a in AREAS if d.startswith(a)), None)\n        if area is None:\n            return None\n    sub = d[len(area):]\n    if len(sub) <= 5:\n        groups = [sub]\n    elif len(sub) % 2 == 0:\n        h = len(sub) // 2\n        groups = [sub[:h], sub[h:]]\n    else:\n        groups = [sub[:3], sub[3:]]\n    return '0' + area + ' ' + ' '.join(groups)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['one-digit area', '02 55501234', '02 5550 1234'], ['two-digit area', '030 5501234', '030 550 1234'], ['long area code wins over its prefix', '04012 01234', '04012 01234'], ['short area code', '040-3501234', '040 350 1234'], ['mobile block', '07111 01234', '07111 01234'], ['ten digits without trunk', '1255501234', None], ['unknown area prefix', '0955501234', None], ['national number typed without trunk', '255501234', '02 5550 1234']], [['one-digit area', '02 55502345', '02 5550 2345'], ['two-digit area', '030 5502345', '030 550 2345'], ['long area code wins over its prefix', '04012 02345', '04012 02345'], ['short area code', '040-3502345', '040 350 2345'], ['mobile block', '07222 02345', '07222 02345'], ['ten digits without trunk', '1255502345', None], ['unknown area prefix', '0955502345', None], ['national number typed without trunk', '255502345', '02 5550 2345']], [['one-digit area', '02 55503456', '02 5550 3456'], ['two-digit area', '030 5503456', '030 550 3456'], ['long area code wins over its prefix', '04012 03456', '04012 03456'], ['short area code', '040-3503456', '040 350 3456'], ['mobile block', '07333 03456', '07333 03456'], ['ten digits without trunk', '1255503456', None], ['unknown area prefix', '0955503456', None], ['national number typed without trunk', '255503456', '02 5550 3456']], [['one-digit area', '02 55504567', '02 5550 4567'], ['two-digit area', '030 5504567', '030 550 4567'], ['long area code wins over its prefix', '04012 04567', '04012 04567'], ['short area code', '040-3504567', '040 350 4567'], ['mobile block', '07444 04567', '07444 04567'], ['ten digits without trunk', '1255504567', None], ['unknown area prefix', '0955504567', None], ['national number typed without trunk', '255504567', '02 5550 4567']], [['one-digit area', '02 55505678', '02 5550 5678'], ['two-digit area', '030 5505678', '030 550 5678'], ['long area code wins over its prefix', '04012 05678', '04012 05678'], ['short area code', '040-3505678', '040 350 5678'], ['mobile block', '07555 05678', '07555 05678'], ['ten digits without trunk', '1255505678', None], ['unknown area prefix', '0955505678', None], ['national number typed without trunk', '255505678', '02 5550 5678']]]\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":"a51f23973a48bc49efef4798d45c1c4d592d5d439c1a796c58c17059675aa0a8","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    AREAS = ['2', '30', '31', '40', '4012']\n    d = ''.join(c for c in x if c.isdigit())\n    if d.startswith('0'):\n        d = d[1:]\n    if len(d) != 9:\n        return None\n    if d[0] == '7':\n        area = d[:4]\n    else:\n        area = min((a for a in AREAS if d.startswith(a)), key=len, default=None)\n        if area is None:\n            return None\n    sub = d[len(area):]\n    if len(sub) <= 5:\n        groups = [sub]\n    elif len(sub) % 2 == 0:\n        h = len(sub) // 2\n        groups = [sub[:h], sub[h:]]\n    else:\n        groups = [sub[:3], sub[3:]]\n    return '0' + area + ' ' + ' '.join(groups)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['one-digit area', '02 55501234', '02 5550 1234'], ['two-digit area', '030 5501234', '030 550 1234'], ['long area code wins over its prefix', '04012 01234', '04012 01234'], ['short area code', '040-3501234', '040 350 1234'], ['mobile block', '07111 01234', '07111 01234'], ['ten digits without trunk', '1255501234', None], ['unknown area prefix', '0955501234', None], ['national number typed without trunk', '255501234', '02 5550 1234']], [['one-digit area', '02 55502345', '02 5550 2345'], ['two-digit area', '030 5502345', '030 550 2345'], ['long area code wins over its prefix', '04012 02345', '04012 02345'], ['short area code', '040-3502345', '040 350 2345'], ['mobile block', '07222 02345', '07222 02345'], ['ten digits without trunk', '1255502345', None], ['unknown area prefix', '0955502345', None], ['national number typed without trunk', '255502345', '02 5550 2345']], [['one-digit area', '02 55503456', '02 5550 3456'], ['two-digit area', '030 5503456', '030 550 3456'], ['long area code wins over its prefix', '04012 03456', '04012 03456'], ['short area code', '040-3503456', '040 350 3456'], ['mobile block', '07333 03456', '07333 03456'], ['ten digits without trunk', '1255503456', None], ['unknown area prefix', '0955503456', None], ['national number typed without trunk', '255503456', '02 5550 3456']], [['one-digit area', '02 55504567', '02 5550 4567'], ['two-digit area', '030 5504567', '030 550 4567'], ['long area code wins over its prefix', '04012 04567', '04012 04567'], ['short area code', '040-3504567', '040 350 4567'], ['mobile block', '07444 04567', '07444 04567'], ['ten digits without trunk', '1255504567', None], ['unknown area prefix', '0955504567', None], ['national number typed without trunk', '255504567', '02 5550 4567']], [['one-digit area', '02 55505678', '02 5550 5678'], ['two-digit area', '030 5505678', '030 550 5678'], ['long area code wins over its prefix', '04012 05678', '04012 05678'], ['short area code', '040-3505678', '040 350 5678'], ['mobile block', '07555 05678', '07555 05678'], ['ten digits without trunk', '1255505678', None], ['unknown area prefix', '0955505678', None], ['national number typed without trunk', '255505678', '02 5550 5678']]]\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"},"fixed":{"sha256":"830693da487542d60a53ef955bc8d823ef571b2d54e416f514f1b9bbbd5d5009","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    AREAS = ['2', '30', '31', '40', '4012']\n    d = ''.join(c for c in x if c.isdigit())\n    if d.startswith('0'):\n        d = d[1:]\n    if len(d) != 9:\n        return None\n    if d[0] == '7':\n        area = d[:4]\n    else:\n        area = max((a for a in AREAS if d.startswith(a)), key=len, default=None)\n        if area is None:\n            return None\n    sub = d[len(area):]\n    if len(sub) <= 5:\n        groups = [sub]\n    elif len(sub) % 2 == 0:\n        h = len(sub) // 2\n        groups = [sub[:h], sub[h:]]\n    else:\n        groups = [sub[:3], sub[3:]]\n    return '0' + area + ' ' + ' '.join(groups)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['one-digit area', '02 55501234', '02 5550 1234'], ['two-digit area', '030 5501234', '030 550 1234'], ['long area code wins over its prefix', '04012 01234', '04012 01234'], ['short area code', '040-3501234', '040 350 1234'], ['mobile block', '07111 01234', '07111 01234'], ['ten digits without trunk', '1255501234', None], ['unknown area prefix', '0955501234', None], ['national number typed without trunk', '255501234', '02 5550 1234']], [['one-digit area', '02 55502345', '02 5550 2345'], ['two-digit area', '030 5502345', '030 550 2345'], ['long area code wins over its prefix', '04012 02345', '04012 02345'], ['short area code', '040-3502345', '040 350 2345'], ['mobile block', '07222 02345', '07222 02345'], ['ten digits without trunk', '1255502345', None], ['unknown area prefix', '0955502345', None], ['national number typed without trunk', '255502345', '02 5550 2345']], [['one-digit area', '02 55503456', '02 5550 3456'], ['two-digit area', '030 5503456', '030 550 3456'], ['long area code wins over its prefix', '04012 03456', '04012 03456'], ['short area code', '040-3503456', '040 350 3456'], ['mobile block', '07333 03456', '07333 03456'], ['ten digits without trunk', '1255503456', None], ['unknown area prefix', '0955503456', None], ['national number typed without trunk', '255503456', '02 5550 3456']], [['one-digit area', '02 55504567', '02 5550 4567'], ['two-digit area', '030 5504567', '030 550 4567'], ['long area code wins over its prefix', '04012 04567', '04012 04567'], ['short area code', '040-3504567', '040 350 4567'], ['mobile block', '07444 04567', '07444 04567'], ['ten digits without trunk', '1255504567', None], ['unknown area prefix', '0955504567', None], ['national number typed without trunk', '255504567', '02 5550 4567']], [['one-digit area', '02 55505678', '02 5550 5678'], ['two-digit area', '030 5505678', '030 550 5678'], ['long area code wins over its prefix', '04012 05678', '04012 05678'], ['short area code', '040-3505678', '040 350 5678'], ['mobile block', '07555 05678', '07555 05678'], ['ten digits without trunk', '1255505678', None], ['unknown area prefix', '0955505678', None], ['national number typed without trunk', '255505678', '02 5550 5678']]]\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-area-grouping-longest-area","generated_at":"2026-09-29T14:52:22.414319+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Area codes of different lengths share leading digits; choosing the wrong one regroups every digit and prints a number users cannot dial.","repair":"Choose the longest matching area code.","root_cause":"The shortest matching area code is selected.","sha256":"21e84043e72819b0336e4784a7a2d17150717a6c440373915a126a743759871f","title":"Variable-length area code grouping: the shortest matching area code is used · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":38.565,"exit_code":1,"observations":[{"actual":"02 5550 1234","check":"one-digit area","expected":"02 5550 1234","passed":true},{"actual":"030 550 1234","check":"two-digit area","expected":"030 550 1234","passed":true},{"actual":"040 120 1234","check":"long area code wins over its prefix","expected":"04012 01234","passed":false},{"actual":"040 350 1234","check":"short area code","expected":"040 350 1234","passed":true},{"actual":"07111 01234","check":"mobile block","expected":"07111 01234","passed":true},{"actual":null,"check":"ten digits without trunk","expected":null,"passed":true},{"actual":null,"check":"unknown area prefix","expected":null,"passed":true},{"actual":"02 5550 1234","check":"national number typed without trunk","expected":"02 5550 1234","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"one-digit area\", \"actual\": \"02 5550 1234\", \"expected\": \"02 5550 1234\", \"passed\": true}, {\"check\": \"two-digit area\", \"actual\": \"030 550 1234\", \"expected\": \"030 550 1234\", \"passed\": true}, {\"check\": \"long area code wins over its prefix\", \"actual\": \"040 120 1234\", \"expected\": \"04012 01234\", \"passed\": false}, {\"check\": \"short area code\", \"actual\": \"040 350 1234\", \"expected\": \"040 350 1234\", \"passed\": true}, {\"check\": \"mobile block\", \"actual\": \"07111 01234\", \"expected\": \"07111 01234\", \"passed\": true}, {\"check\": \"ten digits without trunk\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"unknown area prefix\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"national number typed without trunk\", \"actual\": \"02 5550 1234\", \"expected\": \"02 5550 1234\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":37.982,"exit_code":1,"observations":[{"actual":"02 5550 1234","check":"one-digit area","expected":"02 5550 1234","passed":true},{"actual":"030 550 1234","check":"two-digit area","expected":"030 550 1234","passed":true},{"actual":"040 120 1234","check":"long area code wins over its prefix","expected":"04012 01234","passed":false},{"actual":"040 350 1234","check":"short area code","expected":"040 350 1234","passed":true},{"actual":"07111 01234","check":"mobile block","expected":"07111 01234","passed":true},{"actual":null,"check":"ten digits without trunk","expected":null,"passed":true},{"actual":null,"check":"unknown area prefix","expected":null,"passed":true},{"actual":"02 5550 1234","check":"national number typed without trunk","expected":"02 5550 1234","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"one-digit area\", \"actual\": \"02 5550 1234\", \"expected\": \"02 5550 1234\", \"passed\": true}, {\"check\": \"two-digit area\", \"actual\": \"030 550 1234\", \"expected\": \"030 550 1234\", \"passed\": true}, {\"check\": \"long area code wins over its prefix\", \"actual\": \"040 120 1234\", \"expected\": \"04012 01234\", \"passed\": false}, {\"check\": \"short area code\", \"actual\": \"040 350 1234\", \"expected\": \"040 350 1234\", \"passed\": true}, {\"check\": \"mobile block\", \"actual\": \"07111 01234\", \"expected\": \"07111 01234\", \"passed\": true}, {\"check\": \"ten digits without trunk\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"unknown area prefix\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"national number typed without trunk\", \"actual\": \"02 5550 1234\", \"expected\": \"02 5550 1234\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.648,"exit_code":0,"observations":[{"actual":"02 5550 1234","check":"one-digit area","expected":"02 5550 1234","passed":true},{"actual":"030 550 1234","check":"two-digit area","expected":"030 550 1234","passed":true},{"actual":"04012 01234","check":"long area code wins over its prefix","expected":"04012 01234","passed":true},{"actual":"040 350 1234","check":"short area code","expected":"040 350 1234","passed":true},{"actual":"07111 01234","check":"mobile block","expected":"07111 01234","passed":true},{"actual":null,"check":"ten digits without trunk","expected":null,"passed":true},{"actual":null,"check":"unknown area prefix","expected":null,"passed":true},{"actual":"02 5550 1234","check":"national number typed without trunk","expected":"02 5550 1234","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"one-digit area\", \"actual\": \"02 5550 1234\", \"expected\": \"02 5550 1234\", \"passed\": true}, {\"check\": \"two-digit area\", \"actual\": \"030 550 1234\", \"expected\": \"030 550 1234\", \"passed\": true}, {\"check\": \"long area code wins over its prefix\", \"actual\": \"04012 01234\", \"expected\": \"04012 01234\", \"passed\": true}, {\"check\": \"short area code\", \"actual\": \"040 350 1234\", \"expected\": \"040 350 1234\", \"passed\": true}, {\"check\": \"mobile block\", \"actual\": \"07111 01234\", \"expected\": \"07111 01234\", \"passed\": true}, {\"check\": \"ten digits without trunk\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"unknown area prefix\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"national number typed without trunk\", \"actual\": \"02 5550 1234\", \"expected\": \"02 5550 1234\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}