broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    half_width = p["w"]//2
    half_height = p["h"]//2
    tap = (2 if p["y"]>=half_height else 0)+(1 if p["x"]>=half_width else 0)
    local_x = p["x"] if tap%2==0 else p["w"]-1-p["x"]
    local_y = p["y"] if tap<2 else p["h"]-1-p["y"]
    storage_slot = [1,3,0,2][tap]
    packet_pitch = half_width*half_height*p["b"]+3
    packet_origin = p["base"]+tap*packet_pitch
    address = packet_origin+3+(local_y*half_width+local_x)*p["b"]
    allocation_end = p["base"]+4*packet_pitch
    return {'half_width': half_width, 'half_height': half_height, 'tap': tap, 'local_x': local_x, 'local_y': local_y, 'storage_slot': storage_slot, 'packet_pitch': packet_pitch, 'packet_origin': packet_origin, 'address': address, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'h': 8, 'x': 0, 'y': 0, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 35, 'packet_origin': 42, 'address': 45, 'allocation_end': 147}), ({'w': 8, 'h': 10, 'x': 5, 'y': 1, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 5, 'tap': 1, 'local_x': 2, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 43, 'packet_origin': 136, 'address': 151, 'allocation_end': 179}), ({'w': 8, 'h': 12, 'x': 1, 'y': 6, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 51, 'packet_origin': 7, 'address': 52, 'allocation_end': 211}), ({'w': 8, 'h': 14, 'x': 6, 'y': 7, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 7, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 59, 'packet_origin': 125, 'address': 178, 'allocation_end': 243}), ({'w': 8, 'h': 16, 'x': 1, 'y': 2, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 8, 'tap': 0, 'local_x': 1, 'local_y': 2, 'storage_slot': 1, 'packet_pitch': 67, 'packet_origin': 74, 'address': 95, 'allocation_end': 275}), ({'w': 8, 'h': 18, 'x': 2, 'y': 11, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 9, 'tap': 2, 'local_x': 2, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 75, 'packet_origin': 7, 'address': 62, 'allocation_end': 307})], 2: [({'w': 10, 'h': 8, 'x': 0, 'y': 0, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 63, 'packet_origin': 77, 'address': 80, 'allocation_end': 266}), ({'w': 10, 'h': 10, 'x': 5, 'y': 1, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 5, 'tap': 1, 'local_x': 4, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 78, 'packet_origin': 248, 'address': 278, 'allocation_end': 326}), ({'w': 10, 'h': 12, 'x': 1, 'y': 6, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 93, 'packet_origin': 14, 'address': 95, 'allocation_end': 386}), ({'w': 10, 'h': 14, 'x': 6, 'y': 7, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 7, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 108, 'packet_origin': 230, 'address': 332, 'allocation_end': 446}), ({'w': 10, 'h': 16, 'x': 9, 'y': 2, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 8, 'tap': 1, 'local_x': 0, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 123, 'packet_origin': 383, 'address': 416, 'allocation_end': 506}), ({'w': 10, 'h': 18, 'x': 0, 'y': 11, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 9, 'tap': 2, 'local_x': 0, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 138, 'packet_origin': 14, 'address': 107, 'allocation_end': 566})], 3: [({'w': 12, 'h': 8, 'x': 0, 'y': 0, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 99, 'packet_origin': 120, 'address': 123, 'allocation_end': 417}), ({'w': 12, 'h': 10, 'x': 5, 'y': 1, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 123, 'packet_origin': 144, 'address': 191, 'allocation_end': 513}), ({'w': 12, 'h': 12, 'x': 1, 'y': 6, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 147, 'packet_origin': 21, 'address': 148, 'allocation_end': 609}), ({'w': 12, 'h': 14, 'x': 6, 'y': 7, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 7, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 171, 'packet_origin': 363, 'address': 530, 'allocation_end': 705}), ({'w': 12, 'h': 16, 'x': 9, 'y': 2, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 8, 'tap': 1, 'local_x': 2, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 195, 'packet_origin': 606, 'address': 665, 'allocation_end': 801}), ({'w': 12, 'h': 18, 'x': 10, 'y': 11, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 9, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 219, 'packet_origin': 459, 'address': 610, 'allocation_end': 897})], 4: [({'w': 14, 'h': 8, 'x': 0, 'y': 0, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 143, 'packet_origin': 171, 'address': 174, 'allocation_end': 600}), ({'w': 14, 'h': 10, 'x': 5, 'y': 1, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 178, 'packet_origin': 206, 'address': 269, 'allocation_end': 740}), ({'w': 14, 'h': 12, 'x': 1, 'y': 6, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 213, 'packet_origin': 28, 'address': 211, 'allocation_end': 880}), ({'w': 14, 'h': 14, 'x': 6, 'y': 7, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 248, 'packet_origin': 28, 'address': 271, 'allocation_end': 1020}), ({'w': 14, 'h': 16, 'x': 9, 'y': 2, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 8, 'tap': 1, 'local_x': 4, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 283, 'packet_origin': 877, 'address': 970, 'allocation_end': 1160}), ({'w': 14, 'h': 18, 'x': 10, 'y': 11, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 9, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 318, 'packet_origin': 664, 'address': 892, 'allocation_end': 1300})], 5: [({'w': 16, 'h': 8, 'x': 0, 'y': 0, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 195, 'packet_origin': 230, 'address': 233, 'allocation_end': 815}), ({'w': 16, 'h': 10, 'x': 5, 'y': 1, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 243, 'packet_origin': 278, 'address': 359, 'allocation_end': 1007}), ({'w': 16, 'h': 12, 'x': 1, 'y': 6, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 291, 'packet_origin': 35, 'address': 284, 'allocation_end': 1199}), ({'w': 16, 'h': 14, 'x': 6, 'y': 7, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 339, 'packet_origin': 35, 'address': 362, 'allocation_end': 1391}), ({'w': 16, 'h': 16, 'x': 9, 'y': 2, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 8, 'tap': 1, 'local_x': 6, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 387, 'packet_origin': 1196, 'address': 1331, 'allocation_end': 1583}), ({'w': 16, 'h': 18, 'x': 10, 'y': 11, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 9, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 435, 'packet_origin': 905, 'address': 1226, 'allocation_end': 1775})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    half_width = p["w"]//2
    half_height = p["h"]//2
    tap = (2 if p["y"]>=half_height else 0)+(1 if p["x"]>=half_width else 0)
    local_x = p["x"] if tap%2==0 else p["w"]-1-p["x"]
    local_y = p["y"] if tap<2 else p["h"]-1-p["y"]
    storage_slot = [1,3,0,2][tap]
    packet_pitch = half_width*half_height*p["b"]+3
    packet_origin = storage_slot*packet_pitch
    address = packet_origin+3+(local_y*half_width+local_x)*p["b"]
    allocation_end = p["base"]+4*packet_pitch
    return {'half_width': half_width, 'half_height': half_height, 'tap': tap, 'local_x': local_x, 'local_y': local_y, 'storage_slot': storage_slot, 'packet_pitch': packet_pitch, 'packet_origin': packet_origin, 'address': address, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'h': 8, 'x': 0, 'y': 0, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 35, 'packet_origin': 42, 'address': 45, 'allocation_end': 147}), ({'w': 8, 'h': 10, 'x': 5, 'y': 1, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 5, 'tap': 1, 'local_x': 2, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 43, 'packet_origin': 136, 'address': 151, 'allocation_end': 179}), ({'w': 8, 'h': 12, 'x': 1, 'y': 6, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 51, 'packet_origin': 7, 'address': 52, 'allocation_end': 211}), ({'w': 8, 'h': 14, 'x': 6, 'y': 7, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 7, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 59, 'packet_origin': 125, 'address': 178, 'allocation_end': 243}), ({'w': 8, 'h': 16, 'x': 1, 'y': 2, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 8, 'tap': 0, 'local_x': 1, 'local_y': 2, 'storage_slot': 1, 'packet_pitch': 67, 'packet_origin': 74, 'address': 95, 'allocation_end': 275}), ({'w': 8, 'h': 18, 'x': 2, 'y': 11, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 9, 'tap': 2, 'local_x': 2, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 75, 'packet_origin': 7, 'address': 62, 'allocation_end': 307})], 2: [({'w': 10, 'h': 8, 'x': 0, 'y': 0, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 63, 'packet_origin': 77, 'address': 80, 'allocation_end': 266}), ({'w': 10, 'h': 10, 'x': 5, 'y': 1, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 5, 'tap': 1, 'local_x': 4, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 78, 'packet_origin': 248, 'address': 278, 'allocation_end': 326}), ({'w': 10, 'h': 12, 'x': 1, 'y': 6, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 93, 'packet_origin': 14, 'address': 95, 'allocation_end': 386}), ({'w': 10, 'h': 14, 'x': 6, 'y': 7, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 7, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 108, 'packet_origin': 230, 'address': 332, 'allocation_end': 446}), ({'w': 10, 'h': 16, 'x': 9, 'y': 2, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 8, 'tap': 1, 'local_x': 0, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 123, 'packet_origin': 383, 'address': 416, 'allocation_end': 506}), ({'w': 10, 'h': 18, 'x': 0, 'y': 11, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 9, 'tap': 2, 'local_x': 0, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 138, 'packet_origin': 14, 'address': 107, 'allocation_end': 566})], 3: [({'w': 12, 'h': 8, 'x': 0, 'y': 0, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 99, 'packet_origin': 120, 'address': 123, 'allocation_end': 417}), ({'w': 12, 'h': 10, 'x': 5, 'y': 1, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 123, 'packet_origin': 144, 'address': 191, 'allocation_end': 513}), ({'w': 12, 'h': 12, 'x': 1, 'y': 6, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 147, 'packet_origin': 21, 'address': 148, 'allocation_end': 609}), ({'w': 12, 'h': 14, 'x': 6, 'y': 7, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 7, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 171, 'packet_origin': 363, 'address': 530, 'allocation_end': 705}), ({'w': 12, 'h': 16, 'x': 9, 'y': 2, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 8, 'tap': 1, 'local_x': 2, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 195, 'packet_origin': 606, 'address': 665, 'allocation_end': 801}), ({'w': 12, 'h': 18, 'x': 10, 'y': 11, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 9, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 219, 'packet_origin': 459, 'address': 610, 'allocation_end': 897})], 4: [({'w': 14, 'h': 8, 'x': 0, 'y': 0, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 143, 'packet_origin': 171, 'address': 174, 'allocation_end': 600}), ({'w': 14, 'h': 10, 'x': 5, 'y': 1, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 178, 'packet_origin': 206, 'address': 269, 'allocation_end': 740}), ({'w': 14, 'h': 12, 'x': 1, 'y': 6, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 213, 'packet_origin': 28, 'address': 211, 'allocation_end': 880}), ({'w': 14, 'h': 14, 'x': 6, 'y': 7, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 248, 'packet_origin': 28, 'address': 271, 'allocation_end': 1020}), ({'w': 14, 'h': 16, 'x': 9, 'y': 2, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 8, 'tap': 1, 'local_x': 4, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 283, 'packet_origin': 877, 'address': 970, 'allocation_end': 1160}), ({'w': 14, 'h': 18, 'x': 10, 'y': 11, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 9, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 318, 'packet_origin': 664, 'address': 892, 'allocation_end': 1300})], 5: [({'w': 16, 'h': 8, 'x': 0, 'y': 0, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 195, 'packet_origin': 230, 'address': 233, 'allocation_end': 815}), ({'w': 16, 'h': 10, 'x': 5, 'y': 1, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 243, 'packet_origin': 278, 'address': 359, 'allocation_end': 1007}), ({'w': 16, 'h': 12, 'x': 1, 'y': 6, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 291, 'packet_origin': 35, 'address': 284, 'allocation_end': 1199}), ({'w': 16, 'h': 14, 'x': 6, 'y': 7, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 339, 'packet_origin': 35, 'address': 362, 'allocation_end': 1391}), ({'w': 16, 'h': 16, 'x': 9, 'y': 2, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 8, 'tap': 1, 'local_x': 6, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 387, 'packet_origin': 1196, 'address': 1331, 'allocation_end': 1583}), ({'w': 16, 'h': 18, 'x': 10, 'y': 11, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 9, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 435, 'packet_origin': 905, 'address': 1226, 'allocation_end': 1775})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The returned physical layout descriptor disagrees with the declared buffer mapping at packet_origin.

A stipulated even-sized sensor splits the image into four quadrants. Each readout tap scans toward the center: right taps reverse x, bottom taps reverse y. Tap packets have three-byte headers and are stored in order [2,0,3,1]. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    half_width = p["w"]//2
    half_height = p["h"]//2
    tap = (2 if p["y"]>=half_height else 0)+(1 if p["x"]>=half_width else 0)
    local_x = p["x"] if tap%2==0 else p["w"]-1-p["x"]
    local_y = p["y"] if tap<2 else p["h"]-1-p["y"]
    storage_slot = [1,3,0,2][tap]
    packet_pitch = half_width*half_height*p["b"]+3
    packet_origin = p["base"]+storage_slot*packet_pitch
    address = packet_origin+(local_y*half_width+local_x)*p["b"]
    allocation_end = p["base"]+4*packet_pitch
    return {'half_width': half_width, 'half_height': half_height, 'tap': tap, 'local_x': local_x, 'local_y': local_y, 'storage_slot': storage_slot, 'packet_pitch': packet_pitch, 'packet_origin': packet_origin, 'address': address, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'h': 8, 'x': 0, 'y': 0, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 35, 'packet_origin': 42, 'address': 45, 'allocation_end': 147}), ({'w': 8, 'h': 10, 'x': 5, 'y': 1, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 5, 'tap': 1, 'local_x': 2, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 43, 'packet_origin': 136, 'address': 151, 'allocation_end': 179}), ({'w': 8, 'h': 12, 'x': 1, 'y': 6, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 51, 'packet_origin': 7, 'address': 52, 'allocation_end': 211}), ({'w': 8, 'h': 14, 'x': 6, 'y': 7, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 7, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 59, 'packet_origin': 125, 'address': 178, 'allocation_end': 243}), ({'w': 8, 'h': 16, 'x': 1, 'y': 2, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 8, 'tap': 0, 'local_x': 1, 'local_y': 2, 'storage_slot': 1, 'packet_pitch': 67, 'packet_origin': 74, 'address': 95, 'allocation_end': 275}), ({'w': 8, 'h': 18, 'x': 2, 'y': 11, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 9, 'tap': 2, 'local_x': 2, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 75, 'packet_origin': 7, 'address': 62, 'allocation_end': 307})], 2: [({'w': 10, 'h': 8, 'x': 0, 'y': 0, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 63, 'packet_origin': 77, 'address': 80, 'allocation_end': 266}), ({'w': 10, 'h': 10, 'x': 5, 'y': 1, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 5, 'tap': 1, 'local_x': 4, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 78, 'packet_origin': 248, 'address': 278, 'allocation_end': 326}), ({'w': 10, 'h': 12, 'x': 1, 'y': 6, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 93, 'packet_origin': 14, 'address': 95, 'allocation_end': 386}), ({'w': 10, 'h': 14, 'x': 6, 'y': 7, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 7, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 108, 'packet_origin': 230, 'address': 332, 'allocation_end': 446}), ({'w': 10, 'h': 16, 'x': 9, 'y': 2, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 8, 'tap': 1, 'local_x': 0, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 123, 'packet_origin': 383, 'address': 416, 'allocation_end': 506}), ({'w': 10, 'h': 18, 'x': 0, 'y': 11, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 9, 'tap': 2, 'local_x': 0, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 138, 'packet_origin': 14, 'address': 107, 'allocation_end': 566})], 3: [({'w': 12, 'h': 8, 'x': 0, 'y': 0, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 99, 'packet_origin': 120, 'address': 123, 'allocation_end': 417}), ({'w': 12, 'h': 10, 'x': 5, 'y': 1, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 123, 'packet_origin': 144, 'address': 191, 'allocation_end': 513}), ({'w': 12, 'h': 12, 'x': 1, 'y': 6, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 147, 'packet_origin': 21, 'address': 148, 'allocation_end': 609}), ({'w': 12, 'h': 14, 'x': 6, 'y': 7, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 7, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 171, 'packet_origin': 363, 'address': 530, 'allocation_end': 705}), ({'w': 12, 'h': 16, 'x': 9, 'y': 2, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 8, 'tap': 1, 'local_x': 2, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 195, 'packet_origin': 606, 'address': 665, 'allocation_end': 801}), ({'w': 12, 'h': 18, 'x': 10, 'y': 11, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 9, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 219, 'packet_origin': 459, 'address': 610, 'allocation_end': 897})], 4: [({'w': 14, 'h': 8, 'x': 0, 'y': 0, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 143, 'packet_origin': 171, 'address': 174, 'allocation_end': 600}), ({'w': 14, 'h': 10, 'x': 5, 'y': 1, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 178, 'packet_origin': 206, 'address': 269, 'allocation_end': 740}), ({'w': 14, 'h': 12, 'x': 1, 'y': 6, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 213, 'packet_origin': 28, 'address': 211, 'allocation_end': 880}), ({'w': 14, 'h': 14, 'x': 6, 'y': 7, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 248, 'packet_origin': 28, 'address': 271, 'allocation_end': 1020}), ({'w': 14, 'h': 16, 'x': 9, 'y': 2, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 8, 'tap': 1, 'local_x': 4, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 283, 'packet_origin': 877, 'address': 970, 'allocation_end': 1160}), ({'w': 14, 'h': 18, 'x': 10, 'y': 11, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 9, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 318, 'packet_origin': 664, 'address': 892, 'allocation_end': 1300})], 5: [({'w': 16, 'h': 8, 'x': 0, 'y': 0, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 195, 'packet_origin': 230, 'address': 233, 'allocation_end': 815}), ({'w': 16, 'h': 10, 'x': 5, 'y': 1, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 243, 'packet_origin': 278, 'address': 359, 'allocation_end': 1007}), ({'w': 16, 'h': 12, 'x': 1, 'y': 6, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 291, 'packet_origin': 35, 'address': 284, 'allocation_end': 1199}), ({'w': 16, 'h': 14, 'x': 6, 'y': 7, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 339, 'packet_origin': 35, 'address': 362, 'allocation_end': 1391}), ({'w': 16, 'h': 16, 'x': 9, 'y': 2, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 8, 'tap': 1, 'local_x': 6, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 387, 'packet_origin': 1196, 'address': 1331, 'allocation_end': 1583}), ({'w': 16, 'h': 18, 'x': 10, 'y': 11, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 9, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 435, 'packet_origin': 905, 'address': 1226, 'allocation_end': 1775})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    half_width = p["w"]//2
    half_height = p["h"]//2
    tap = (2 if p["y"]>=half_height else 0)+(1 if p["x"]>=half_width else 0)
    local_x = p["x"] if tap%2==0 else p["w"]-1-p["x"]
    local_y = p["y"] if tap<2 else p["h"]-1-p["y"]
    storage_slot = [1,3,0,2][tap]
    packet_pitch = half_width*half_height*p["b"]+3
    packet_origin = p["base"]+storage_slot*packet_pitch
    address = packet_origin+3+(local_y*p["w"]+local_x)*p["b"]
    allocation_end = p["base"]+4*packet_pitch
    return {'half_width': half_width, 'half_height': half_height, 'tap': tap, 'local_x': local_x, 'local_y': local_y, 'storage_slot': storage_slot, 'packet_pitch': packet_pitch, 'packet_origin': packet_origin, 'address': address, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'h': 8, 'x': 0, 'y': 0, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 35, 'packet_origin': 42, 'address': 45, 'allocation_end': 147}), ({'w': 8, 'h': 10, 'x': 5, 'y': 1, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 5, 'tap': 1, 'local_x': 2, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 43, 'packet_origin': 136, 'address': 151, 'allocation_end': 179}), ({'w': 8, 'h': 12, 'x': 1, 'y': 6, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 51, 'packet_origin': 7, 'address': 52, 'allocation_end': 211}), ({'w': 8, 'h': 14, 'x': 6, 'y': 7, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 7, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 59, 'packet_origin': 125, 'address': 178, 'allocation_end': 243}), ({'w': 8, 'h': 16, 'x': 1, 'y': 2, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 8, 'tap': 0, 'local_x': 1, 'local_y': 2, 'storage_slot': 1, 'packet_pitch': 67, 'packet_origin': 74, 'address': 95, 'allocation_end': 275}), ({'w': 8, 'h': 18, 'x': 2, 'y': 11, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 9, 'tap': 2, 'local_x': 2, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 75, 'packet_origin': 7, 'address': 62, 'allocation_end': 307})], 2: [({'w': 10, 'h': 8, 'x': 0, 'y': 0, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 63, 'packet_origin': 77, 'address': 80, 'allocation_end': 266}), ({'w': 10, 'h': 10, 'x': 5, 'y': 1, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 5, 'tap': 1, 'local_x': 4, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 78, 'packet_origin': 248, 'address': 278, 'allocation_end': 326}), ({'w': 10, 'h': 12, 'x': 1, 'y': 6, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 93, 'packet_origin': 14, 'address': 95, 'allocation_end': 386}), ({'w': 10, 'h': 14, 'x': 6, 'y': 7, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 7, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 108, 'packet_origin': 230, 'address': 332, 'allocation_end': 446}), ({'w': 10, 'h': 16, 'x': 9, 'y': 2, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 8, 'tap': 1, 'local_x': 0, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 123, 'packet_origin': 383, 'address': 416, 'allocation_end': 506}), ({'w': 10, 'h': 18, 'x': 0, 'y': 11, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 9, 'tap': 2, 'local_x': 0, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 138, 'packet_origin': 14, 'address': 107, 'allocation_end': 566})], 3: [({'w': 12, 'h': 8, 'x': 0, 'y': 0, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 99, 'packet_origin': 120, 'address': 123, 'allocation_end': 417}), ({'w': 12, 'h': 10, 'x': 5, 'y': 1, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 123, 'packet_origin': 144, 'address': 191, 'allocation_end': 513}), ({'w': 12, 'h': 12, 'x': 1, 'y': 6, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 147, 'packet_origin': 21, 'address': 148, 'allocation_end': 609}), ({'w': 12, 'h': 14, 'x': 6, 'y': 7, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 7, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 171, 'packet_origin': 363, 'address': 530, 'allocation_end': 705}), ({'w': 12, 'h': 16, 'x': 9, 'y': 2, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 8, 'tap': 1, 'local_x': 2, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 195, 'packet_origin': 606, 'address': 665, 'allocation_end': 801}), ({'w': 12, 'h': 18, 'x': 10, 'y': 11, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 9, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 219, 'packet_origin': 459, 'address': 610, 'allocation_end': 897})], 4: [({'w': 14, 'h': 8, 'x': 0, 'y': 0, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 143, 'packet_origin': 171, 'address': 174, 'allocation_end': 600}), ({'w': 14, 'h': 10, 'x': 5, 'y': 1, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 178, 'packet_origin': 206, 'address': 269, 'allocation_end': 740}), ({'w': 14, 'h': 12, 'x': 1, 'y': 6, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 213, 'packet_origin': 28, 'address': 211, 'allocation_end': 880}), ({'w': 14, 'h': 14, 'x': 6, 'y': 7, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 248, 'packet_origin': 28, 'address': 271, 'allocation_end': 1020}), ({'w': 14, 'h': 16, 'x': 9, 'y': 2, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 8, 'tap': 1, 'local_x': 4, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 283, 'packet_origin': 877, 'address': 970, 'allocation_end': 1160}), ({'w': 14, 'h': 18, 'x': 10, 'y': 11, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 9, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 318, 'packet_origin': 664, 'address': 892, 'allocation_end': 1300})], 5: [({'w': 16, 'h': 8, 'x': 0, 'y': 0, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 195, 'packet_origin': 230, 'address': 233, 'allocation_end': 815}), ({'w': 16, 'h': 10, 'x': 5, 'y': 1, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 243, 'packet_origin': 278, 'address': 359, 'allocation_end': 1007}), ({'w': 16, 'h': 12, 'x': 1, 'y': 6, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 291, 'packet_origin': 35, 'address': 284, 'allocation_end': 1199}), ({'w': 16, 'h': 14, 'x': 6, 'y': 7, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 339, 'packet_origin': 35, 'address': 362, 'allocation_end': 1391}), ({'w': 16, 'h': 16, 'x': 9, 'y': 2, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 8, 'tap': 1, 'local_x': 6, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 387, 'packet_origin': 1196, 'address': 1331, 'allocation_end': 1583}), ({'w': 16, 'h': 18, 'x': 10, 'y': 11, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 9, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 435, 'packet_origin': 905, 'address': 1226, 'allocation_end': 1775})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The returned physical layout descriptor disagrees with the declared buffer mapping at address.

A stipulated even-sized sensor splits the image into four quadrants. Each readout tap scans toward the center: right taps reverse x, bottom taps reverse y. Tap packets have three-byte headers and are stored in order [2,0,3,1]. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    half_width = p["w"]//2
    half_height = p["h"]//2
    tap = (2 if p["y"]>=half_height else 0)+(1 if p["x"]>=half_width else 0)
    local_x = p["x"] if tap%2==0 else p["w"]-1-p["x"]
    local_y = p["y"] if tap<2 else p["h"]-1-p["y"]
    storage_slot = [1,3,0,2][tap]
    packet_pitch = half_width*half_height*p["b"]+3
    packet_origin = p["base"]+storage_slot*packet_pitch
    address = packet_origin+3+(local_y*half_width+local_x)*p["b"]
    allocation_end = p["base"]+p["w"]*p["h"]*p["b"]
    return {'half_width': half_width, 'half_height': half_height, 'tap': tap, 'local_x': local_x, 'local_y': local_y, 'storage_slot': storage_slot, 'packet_pitch': packet_pitch, 'packet_origin': packet_origin, 'address': address, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'h': 8, 'x': 0, 'y': 0, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 35, 'packet_origin': 42, 'address': 45, 'allocation_end': 147}), ({'w': 8, 'h': 10, 'x': 5, 'y': 1, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 5, 'tap': 1, 'local_x': 2, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 43, 'packet_origin': 136, 'address': 151, 'allocation_end': 179}), ({'w': 8, 'h': 12, 'x': 1, 'y': 6, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 51, 'packet_origin': 7, 'address': 52, 'allocation_end': 211}), ({'w': 8, 'h': 14, 'x': 6, 'y': 7, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 7, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 59, 'packet_origin': 125, 'address': 178, 'allocation_end': 243}), ({'w': 8, 'h': 16, 'x': 1, 'y': 2, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 8, 'tap': 0, 'local_x': 1, 'local_y': 2, 'storage_slot': 1, 'packet_pitch': 67, 'packet_origin': 74, 'address': 95, 'allocation_end': 275}), ({'w': 8, 'h': 18, 'x': 2, 'y': 11, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 9, 'tap': 2, 'local_x': 2, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 75, 'packet_origin': 7, 'address': 62, 'allocation_end': 307})], 2: [({'w': 10, 'h': 8, 'x': 0, 'y': 0, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 63, 'packet_origin': 77, 'address': 80, 'allocation_end': 266}), ({'w': 10, 'h': 10, 'x': 5, 'y': 1, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 5, 'tap': 1, 'local_x': 4, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 78, 'packet_origin': 248, 'address': 278, 'allocation_end': 326}), ({'w': 10, 'h': 12, 'x': 1, 'y': 6, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 93, 'packet_origin': 14, 'address': 95, 'allocation_end': 386}), ({'w': 10, 'h': 14, 'x': 6, 'y': 7, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 7, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 108, 'packet_origin': 230, 'address': 332, 'allocation_end': 446}), ({'w': 10, 'h': 16, 'x': 9, 'y': 2, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 8, 'tap': 1, 'local_x': 0, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 123, 'packet_origin': 383, 'address': 416, 'allocation_end': 506}), ({'w': 10, 'h': 18, 'x': 0, 'y': 11, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 9, 'tap': 2, 'local_x': 0, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 138, 'packet_origin': 14, 'address': 107, 'allocation_end': 566})], 3: [({'w': 12, 'h': 8, 'x': 0, 'y': 0, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 99, 'packet_origin': 120, 'address': 123, 'allocation_end': 417}), ({'w': 12, 'h': 10, 'x': 5, 'y': 1, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 123, 'packet_origin': 144, 'address': 191, 'allocation_end': 513}), ({'w': 12, 'h': 12, 'x': 1, 'y': 6, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 147, 'packet_origin': 21, 'address': 148, 'allocation_end': 609}), ({'w': 12, 'h': 14, 'x': 6, 'y': 7, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 7, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 171, 'packet_origin': 363, 'address': 530, 'allocation_end': 705}), ({'w': 12, 'h': 16, 'x': 9, 'y': 2, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 8, 'tap': 1, 'local_x': 2, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 195, 'packet_origin': 606, 'address': 665, 'allocation_end': 801}), ({'w': 12, 'h': 18, 'x': 10, 'y': 11, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 9, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 219, 'packet_origin': 459, 'address': 610, 'allocation_end': 897})], 4: [({'w': 14, 'h': 8, 'x': 0, 'y': 0, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 143, 'packet_origin': 171, 'address': 174, 'allocation_end': 600}), ({'w': 14, 'h': 10, 'x': 5, 'y': 1, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 178, 'packet_origin': 206, 'address': 269, 'allocation_end': 740}), ({'w': 14, 'h': 12, 'x': 1, 'y': 6, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 213, 'packet_origin': 28, 'address': 211, 'allocation_end': 880}), ({'w': 14, 'h': 14, 'x': 6, 'y': 7, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 248, 'packet_origin': 28, 'address': 271, 'allocation_end': 1020}), ({'w': 14, 'h': 16, 'x': 9, 'y': 2, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 8, 'tap': 1, 'local_x': 4, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 283, 'packet_origin': 877, 'address': 970, 'allocation_end': 1160}), ({'w': 14, 'h': 18, 'x': 10, 'y': 11, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 9, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 318, 'packet_origin': 664, 'address': 892, 'allocation_end': 1300})], 5: [({'w': 16, 'h': 8, 'x': 0, 'y': 0, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 195, 'packet_origin': 230, 'address': 233, 'allocation_end': 815}), ({'w': 16, 'h': 10, 'x': 5, 'y': 1, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 243, 'packet_origin': 278, 'address': 359, 'allocation_end': 1007}), ({'w': 16, 'h': 12, 'x': 1, 'y': 6, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 291, 'packet_origin': 35, 'address': 284, 'allocation_end': 1199}), ({'w': 16, 'h': 14, 'x': 6, 'y': 7, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 339, 'packet_origin': 35, 'address': 362, 'allocation_end': 1391}), ({'w': 16, 'h': 16, 'x': 9, 'y': 2, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 8, 'tap': 1, 'local_x': 6, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 387, 'packet_origin': 1196, 'address': 1331, 'allocation_end': 1583}), ({'w': 16, 'h': 18, 'x': 10, 'y': 11, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 9, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 435, 'packet_origin': 905, 'address': 1226, 'allocation_end': 1775})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    half_width = p["w"]//2
    half_height = p["h"]//2
    tap = (2 if p["y"]>=half_height else 0)+(1 if p["x"]>=half_width else 0)
    local_x = p["x"] if tap%2==0 else p["w"]-1-p["x"]
    local_y = p["y"] if tap<2 else p["h"]-1-p["y"]
    storage_slot = [1,3,0,2][tap]
    packet_pitch = half_width*half_height*p["b"]+3
    packet_origin = p["base"]+storage_slot*packet_pitch
    address = packet_origin+3+(local_y*half_width+local_x)*p["b"]
    allocation_end = p["base"]+3*packet_pitch
    return {'half_width': half_width, 'half_height': half_height, 'tap': tap, 'local_x': local_x, 'local_y': local_y, 'storage_slot': storage_slot, 'packet_pitch': packet_pitch, 'packet_origin': packet_origin, 'address': address, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'h': 8, 'x': 0, 'y': 0, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 35, 'packet_origin': 42, 'address': 45, 'allocation_end': 147}), ({'w': 8, 'h': 10, 'x': 5, 'y': 1, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 5, 'tap': 1, 'local_x': 2, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 43, 'packet_origin': 136, 'address': 151, 'allocation_end': 179}), ({'w': 8, 'h': 12, 'x': 1, 'y': 6, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 51, 'packet_origin': 7, 'address': 52, 'allocation_end': 211}), ({'w': 8, 'h': 14, 'x': 6, 'y': 7, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 7, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 59, 'packet_origin': 125, 'address': 178, 'allocation_end': 243}), ({'w': 8, 'h': 16, 'x': 1, 'y': 2, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 8, 'tap': 0, 'local_x': 1, 'local_y': 2, 'storage_slot': 1, 'packet_pitch': 67, 'packet_origin': 74, 'address': 95, 'allocation_end': 275}), ({'w': 8, 'h': 18, 'x': 2, 'y': 11, 'b': 2, 'base': 7}, {'half_width': 4, 'half_height': 9, 'tap': 2, 'local_x': 2, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 75, 'packet_origin': 7, 'address': 62, 'allocation_end': 307})], 2: [({'w': 10, 'h': 8, 'x': 0, 'y': 0, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 63, 'packet_origin': 77, 'address': 80, 'allocation_end': 266}), ({'w': 10, 'h': 10, 'x': 5, 'y': 1, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 5, 'tap': 1, 'local_x': 4, 'local_y': 1, 'storage_slot': 3, 'packet_pitch': 78, 'packet_origin': 248, 'address': 278, 'allocation_end': 326}), ({'w': 10, 'h': 12, 'x': 1, 'y': 6, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 93, 'packet_origin': 14, 'address': 95, 'allocation_end': 386}), ({'w': 10, 'h': 14, 'x': 6, 'y': 7, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 7, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 108, 'packet_origin': 230, 'address': 332, 'allocation_end': 446}), ({'w': 10, 'h': 16, 'x': 9, 'y': 2, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 8, 'tap': 1, 'local_x': 0, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 123, 'packet_origin': 383, 'address': 416, 'allocation_end': 506}), ({'w': 10, 'h': 18, 'x': 0, 'y': 11, 'b': 3, 'base': 14}, {'half_width': 5, 'half_height': 9, 'tap': 2, 'local_x': 0, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 138, 'packet_origin': 14, 'address': 107, 'allocation_end': 566})], 3: [({'w': 12, 'h': 8, 'x': 0, 'y': 0, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 99, 'packet_origin': 120, 'address': 123, 'allocation_end': 417}), ({'w': 12, 'h': 10, 'x': 5, 'y': 1, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 123, 'packet_origin': 144, 'address': 191, 'allocation_end': 513}), ({'w': 12, 'h': 12, 'x': 1, 'y': 6, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 147, 'packet_origin': 21, 'address': 148, 'allocation_end': 609}), ({'w': 12, 'h': 14, 'x': 6, 'y': 7, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 7, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 171, 'packet_origin': 363, 'address': 530, 'allocation_end': 705}), ({'w': 12, 'h': 16, 'x': 9, 'y': 2, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 8, 'tap': 1, 'local_x': 2, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 195, 'packet_origin': 606, 'address': 665, 'allocation_end': 801}), ({'w': 12, 'h': 18, 'x': 10, 'y': 11, 'b': 4, 'base': 21}, {'half_width': 6, 'half_height': 9, 'tap': 3, 'local_x': 1, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 219, 'packet_origin': 459, 'address': 610, 'allocation_end': 897})], 4: [({'w': 14, 'h': 8, 'x': 0, 'y': 0, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 143, 'packet_origin': 171, 'address': 174, 'allocation_end': 600}), ({'w': 14, 'h': 10, 'x': 5, 'y': 1, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 178, 'packet_origin': 206, 'address': 269, 'allocation_end': 740}), ({'w': 14, 'h': 12, 'x': 1, 'y': 6, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 213, 'packet_origin': 28, 'address': 211, 'allocation_end': 880}), ({'w': 14, 'h': 14, 'x': 6, 'y': 7, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 248, 'packet_origin': 28, 'address': 271, 'allocation_end': 1020}), ({'w': 14, 'h': 16, 'x': 9, 'y': 2, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 8, 'tap': 1, 'local_x': 4, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 283, 'packet_origin': 877, 'address': 970, 'allocation_end': 1160}), ({'w': 14, 'h': 18, 'x': 10, 'y': 11, 'b': 5, 'base': 28}, {'half_width': 7, 'half_height': 9, 'tap': 3, 'local_x': 3, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 318, 'packet_origin': 664, 'address': 892, 'allocation_end': 1300})], 5: [({'w': 16, 'h': 8, 'x': 0, 'y': 0, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 4, 'tap': 0, 'local_x': 0, 'local_y': 0, 'storage_slot': 1, 'packet_pitch': 195, 'packet_origin': 230, 'address': 233, 'allocation_end': 815}), ({'w': 16, 'h': 10, 'x': 5, 'y': 1, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 5, 'tap': 0, 'local_x': 5, 'local_y': 1, 'storage_slot': 1, 'packet_pitch': 243, 'packet_origin': 278, 'address': 359, 'allocation_end': 1007}), ({'w': 16, 'h': 12, 'x': 1, 'y': 6, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 6, 'tap': 2, 'local_x': 1, 'local_y': 5, 'storage_slot': 0, 'packet_pitch': 291, 'packet_origin': 35, 'address': 284, 'allocation_end': 1199}), ({'w': 16, 'h': 14, 'x': 6, 'y': 7, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 7, 'tap': 2, 'local_x': 6, 'local_y': 6, 'storage_slot': 0, 'packet_pitch': 339, 'packet_origin': 35, 'address': 362, 'allocation_end': 1391}), ({'w': 16, 'h': 16, 'x': 9, 'y': 2, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 8, 'tap': 1, 'local_x': 6, 'local_y': 2, 'storage_slot': 3, 'packet_pitch': 387, 'packet_origin': 1196, 'address': 1331, 'allocation_end': 1583}), ({'w': 16, 'h': 18, 'x': 10, 'y': 11, 'b': 6, 'base': 35}, {'half_width': 8, 'half_height': 9, 'tap': 3, 'local_x': 5, 'local_y': 6, 'storage_slot': 2, 'packet_pitch': 435, 'packet_origin': 905, 'address': 1226, 'allocation_end': 1775})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The returned physical layout descriptor disagrees with the declared buffer mapping at allocation_end.

A stipulated even-sized sensor splits the image into four quadrants. Each readout tap scans toward the center: right taps reverse x, bottom taps reverse y. Tap packets have three-byte headers and are stored in order [2,0,3,1]. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split(' '):
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.replace('\n',' ').split(' '):
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Role token scanning ignores tab separators.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: break
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known and token != 'command': continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An abstract role token terminates fallback resolution.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if False: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive and native == 'link': continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Interactive nodes accept a presentation override.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if False: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token == 'generic': continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A mandatory native semantic is overwritten.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        continue
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        if token == native: break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Last role token replaces first usable role.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = 'generic'
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native if interactive else 'generic'
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Missing role tokens fabricate generic semantics.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if False:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported and not supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A platform unsupported role leaks through.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if supported else 'presentation'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unsupported native roles are used as a fallback.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access