{"abstract":"Codes are mirrored, so asymmetric patterns scan as other values.","category":"Barcode symbology encoding","checks":8,"contract":"Encode an integer 3..131070 as a one-track Pharmacode: repeatedly, an even value adds a wide bar and becomes (n - 2) / 2, an odd value adds a narrow bar and becomes (n - 1) / 2, until zero; bars are read in the reverse order of generation (left to right). Width: narrow 1, wide 3, spaces 2 between bars. Return [pattern, width] or None outside the range.","evaluation_group":"w2-barcode-symbology-encoding-pharmacode-bars","failed_approach":"Rotating one bar to the front is not a reversal.","family":"w2-barcode-symbology-encoding-pharmacode-bars-bar-order","id":"FA-79831","implementations":{"attempt":{"sha256":"92dcdc96e17cbb514f121f97e8e0f6590837a0a410daa2bd5d8cd257fbe6a777","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(n):\n    if not isinstance(n, int) or n < 3 or n > 131070:\n        return None\n    bars = []\n    while n > 0:\n        if n % 2 == 0:\n            bars.append('w')\n            n = (n - 2) // 2\n        else:\n            bars.append('n')\n            n = (n - 1) // 2\n    bars.insert(0, bars.pop())\n    width = sum(3 if b == 'w' else 1 for b in bars) + 2 * (len(bars) - 1)\n    return [''.join(bars), width]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[34, ['nnnww', 17]], [120, ['wwwnnw', 24]], [7, ['nnn', 7]], [30, ['wwww', 18]], [127, ['nnnnnnn', 19]], [1, None], [2, None], [306, ['nnwwnnww', 30]]], [[85, ['nwnwwn', 22]], [353, ['nwwnnnwn', 28]], [31, ['nnnnn', 13]], [126, ['wwwwww', 28]], [127, ['nnnnnnn', 19]], [1022, ['wwwwwwwww', 43]], [1, None], [306, ['nnwwnnww', 30]]], [[142, ['nnnwwww', 27]], [274, ['nnnwnnww', 28]], [15, ['nnnn', 10]], [63, ['nnnnnn', 16]], [255, ['nnnnnnnn', 22]], [14, ['www', 13]], [1, None], [396, ['wnnnwwnw', 30]]], [[157, ['nnwwwwn', 27]], [19, ['nwnn', 12]], [240, ['wwwnnnw', 27]], [3, ['nn', 4]], [254, ['wwwwwww', 33]], [127, ['nnnnnnn', 19]], [1, None], [143, ['nnwnnnn', 21]]], [[157, ['nnwwwwn', 27]], [228, ['wwnnwnw', 27]], [158, ['nnwwwww', 29]], [30, ['wwww', 18]], [6, ['ww', 8]], [1, None], [2, None], [225, ['wwnnnwn', 25]]]]\nlabels = [\"regression: reading order of bars\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), 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":"89fec83ae13f90b8d4ccb3a43b5bab8e68874edcdc61c8247ef45a29b3f2f727","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(n):\n    if not isinstance(n, int) or n < 3 or n > 131070:\n        return None\n    bars = []\n    while n > 0:\n        if n % 2 == 0:\n            bars.append('w')\n            n = (n - 2) // 2\n        else:\n            bars.append('n')\n            n = (n - 1) // 2\n    pass\n    width = sum(3 if b == 'w' else 1 for b in bars) + 2 * (len(bars) - 1)\n    return [''.join(bars), width]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[34, ['nnnww', 17]], [120, ['wwwnnw', 24]], [7, ['nnn', 7]], [30, ['wwww', 18]], [127, ['nnnnnnn', 19]], [1, None], [2, None], [306, ['nnwwnnww', 30]]], [[85, ['nwnwwn', 22]], [353, ['nwwnnnwn', 28]], [31, ['nnnnn', 13]], [126, ['wwwwww', 28]], [127, ['nnnnnnn', 19]], [1022, ['wwwwwwwww', 43]], [1, None], [306, ['nnwwnnww', 30]]], [[142, ['nnnwwww', 27]], [274, ['nnnwnnww', 28]], [15, ['nnnn', 10]], [63, ['nnnnnn', 16]], [255, ['nnnnnnnn', 22]], [14, ['www', 13]], [1, None], [396, ['wnnnwwnw', 30]]], [[157, ['nnwwwwn', 27]], [19, ['nwnn', 12]], [240, ['wwwnnnw', 27]], [3, ['nn', 4]], [254, ['wwwwwww', 33]], [127, ['nnnnnnn', 19]], [1, None], [143, ['nnwnnnn', 21]]], [[157, ['nnwwwwn', 27]], [228, ['wwnnwnw', 27]], [158, ['nnwwwww', 29]], [30, ['wwww', 18]], [6, ['ww', 8]], [1, None], [2, None], [225, ['wwnnnwn', 25]]]]\nlabels = [\"regression: reading order of bars\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), 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":"1618f7da0c8df944f3ba406720708313a37cf96e5ca619e314406f5f97c7dfc0","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(n):\n    if not isinstance(n, int) or n < 3 or n > 131070:\n        return None\n    bars = []\n    while n > 0:\n        if n % 2 == 0:\n            bars.append('w')\n            n = (n - 2) // 2\n        else:\n            bars.append('n')\n            n = (n - 1) // 2\n    bars.reverse()\n    width = sum(3 if b == 'w' else 1 for b in bars) + 2 * (len(bars) - 1)\n    return [''.join(bars), width]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[34, ['nnnww', 17]], [120, ['wwwnnw', 24]], [7, ['nnn', 7]], [30, ['wwww', 18]], [127, ['nnnnnnn', 19]], [1, None], [2, None], [306, ['nnwwnnww', 30]]], [[85, ['nwnwwn', 22]], [353, ['nwwnnnwn', 28]], [31, ['nnnnn', 13]], [126, ['wwwwww', 28]], [127, ['nnnnnnn', 19]], [1022, ['wwwwwwwww', 43]], [1, None], [306, ['nnwwnnww', 30]]], [[142, ['nnnwwww', 27]], [274, ['nnnwnnww', 28]], [15, ['nnnn', 10]], [63, ['nnnnnn', 16]], [255, ['nnnnnnnn', 22]], [14, ['www', 13]], [1, None], [396, ['wnnnwwnw', 30]]], [[157, ['nnwwwwn', 27]], [19, ['nwnn', 12]], [240, ['wwwnnnw', 27]], [3, ['nn', 4]], [254, ['wwwwwww', 33]], [127, ['nnnnnnn', 19]], [1, None], [143, ['nnwnnnn', 21]]], [[157, ['nnwwwwn', 27]], [228, ['wwnnwnw', 27]], [158, ['nnwwwww', 29]], [30, ['wwww', 18]], [6, ['ww', 8]], [1, None], [2, None], [225, ['wwnnnwn', 25]]]]\nlabels = [\"regression: reading order of bars\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), 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 with a stipulated contract; it makes no claim of conformance to any published specification. 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-barcode-symbology-encoding-pharmacode-bars-bar-order","generated_at":"2026-09-29T14:49:48.212374+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Retail, logistics, pharmacy and document workflows depend on encoders that produce exactly the module pattern, code-set switches, separators and quiet zones scanners expect; one misplaced module or separator makes a label unreadable or, worse, scan as different data.","repair":"Reverse the generated bars so the most significant bar comes first.","root_cause":"Bars are emitted least significant first instead of reversed.","sha256":"cc497b3a3dd30cfab52f07ebbeb1170976b55a3b3c98689786d1a4568cc01f3e","title":"Pharmacode bars are printed in generation order · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.382,"exit_code":1,"observations":[{"actual":["nwwnn",17],"check":"regression: reading order of bars 0","expected":["nnnww",17],"passed":false},{"actual":["wwnnww",24],"check":"repair trap 1","expected":["wwwnnw",24],"passed":false},{"actual":["nnn",7],"check":"combined fault 2","expected":["nnn",7],"passed":true},{"actual":["wwww",18],"check":"control 3","expected":["wwww",18],"passed":true},{"actual":["nnnnnnn",19],"check":"control 4","expected":["nnnnnnn",19],"passed":true},{"actual":null,"check":"boundary 5","expected":null,"passed":true},{"actual":null,"check":"boundary 6","expected":null,"passed":true},{"actual":["nwwnnwwn",30],"check":"control 7","expected":["nnwwnnww",30],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: reading order of bars 0\", \"actual\": [\"nwwnn\", 17], \"expected\": [\"nnnww\", 17], \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": [\"wwnnww\", 24], \"expected\": [\"wwwnnw\", 24], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [\"nnn\", 7], \"expected\": [\"nnn\", 7], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [\"wwww\", 18], \"expected\": [\"wwww\", 18], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [\"nnnnnnn\", 19], \"expected\": [\"nnnnnnn\", 19], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [\"nwwnnwwn\", 30], \"expected\": [\"nnwwnnww\", 30], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.708,"exit_code":1,"observations":[{"actual":["wwnnn",17],"check":"regression: reading order of bars 0","expected":["nnnww",17],"passed":false},{"actual":["wnnwww",24],"check":"repair trap 1","expected":["wwwnnw",24],"passed":false},{"actual":["nnn",7],"check":"combined fault 2","expected":["nnn",7],"passed":true},{"actual":["wwww",18],"check":"control 3","expected":["wwww",18],"passed":true},{"actual":["nnnnnnn",19],"check":"control 4","expected":["nnnnnnn",19],"passed":true},{"actual":null,"check":"boundary 5","expected":null,"passed":true},{"actual":null,"check":"boundary 6","expected":null,"passed":true},{"actual":["wwnnwwnn",30],"check":"control 7","expected":["nnwwnnww",30],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: reading order of bars 0\", \"actual\": [\"wwnnn\", 17], \"expected\": [\"nnnww\", 17], \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": [\"wnnwww\", 24], \"expected\": [\"wwwnnw\", 24], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [\"nnn\", 7], \"expected\": [\"nnn\", 7], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [\"wwww\", 18], \"expected\": [\"wwww\", 18], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [\"nnnnnnn\", 19], \"expected\": [\"nnnnnnn\", 19], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [\"wwnnwwnn\", 30], \"expected\": [\"nnwwnnww\", 30], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.856,"exit_code":0,"observations":[{"actual":["nnnww",17],"check":"regression: reading order of bars 0","expected":["nnnww",17],"passed":true},{"actual":["wwwnnw",24],"check":"repair trap 1","expected":["wwwnnw",24],"passed":true},{"actual":["nnn",7],"check":"combined fault 2","expected":["nnn",7],"passed":true},{"actual":["wwww",18],"check":"control 3","expected":["wwww",18],"passed":true},{"actual":["nnnnnnn",19],"check":"control 4","expected":["nnnnnnn",19],"passed":true},{"actual":null,"check":"boundary 5","expected":null,"passed":true},{"actual":null,"check":"boundary 6","expected":null,"passed":true},{"actual":["nnwwnnww",30],"check":"control 7","expected":["nnwwnnww",30],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: reading order of bars 0\", \"actual\": [\"nnnww\", 17], \"expected\": [\"nnnww\", 17], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [\"wwwnnw\", 24], \"expected\": [\"wwwnnw\", 24], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [\"nnn\", 7], \"expected\": [\"nnn\", 7], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [\"wwww\", 18], \"expected\": [\"wwww\", 18], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [\"nnnnnnn\", 19], \"expected\": [\"nnnnnnn\", 19], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [\"nnwwnnww\", 30], \"expected\": [\"nnwwnnww\", 30], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}