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

N = 1
observations = []
def solve(p):
    p = dict(p)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = 4*8*p["b"]
    tile_row_pitch = tile_columns*tile_pitch+7
    tile_origin = p["base"]+tile_y*tile_row_pitch+tile_x*tile_pitch
    address = tile_origin+bank*bank_pitch+1+bank_local*p["b"]
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = bank_pitch
    tile_row_pitch = tile_columns*tile_pitch+7
    tile_origin = p["base"]+tile_y*tile_row_pitch+tile_x*tile_pitch
    address = tile_origin+bank*bank_pitch+1+bank_local*p["b"]
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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 tile_pitch.

A stipulated 8x4 tile has four banks. Bank = (local x modulo 4) XOR (local y modulo 4); each bank stores two columns per row and begins with a one-byte tag. Tile rows include a seven-byte trailer. 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)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = 4*bank_pitch
    tile_row_pitch = tile_columns*tile_pitch
    tile_origin = p["base"]+tile_y*tile_row_pitch+tile_x*tile_pitch
    address = tile_origin+bank*bank_pitch+1+bank_local*p["b"]
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = 4*bank_pitch
    tile_row_pitch = tile_columns*(tile_pitch+7)
    tile_origin = p["base"]+tile_y*tile_row_pitch+tile_x*tile_pitch
    address = tile_origin+bank*bank_pitch+1+bank_local*p["b"]
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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 tile_row_pitch.

A stipulated 8x4 tile has four banks. Bank = (local x modulo 4) XOR (local y modulo 4); each bank stores two columns per row and begins with a one-byte tag. Tile rows include a seven-byte trailer. 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)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = 4*bank_pitch
    tile_row_pitch = tile_columns*tile_pitch+7
    tile_origin = p["base"]+(tile_y*tile_columns+tile_x)*tile_pitch
    address = tile_origin+bank*bank_pitch+1+bank_local*p["b"]
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = 4*bank_pitch
    tile_row_pitch = tile_columns*tile_pitch+7
    tile_origin = p["base"]+tile_x*tile_row_pitch+tile_y*tile_pitch
    address = tile_origin+bank*bank_pitch+1+bank_local*p["b"]
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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 tile_origin.

A stipulated 8x4 tile has four banks. Bank = (local x modulo 4) XOR (local y modulo 4); each bank stores two columns per row and begins with a one-byte tag. Tile rows include a seven-byte trailer. 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)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = 4*bank_pitch
    tile_row_pitch = tile_columns*tile_pitch+7
    tile_origin = p["base"]+tile_y*tile_row_pitch+tile_x*tile_pitch
    address = tile_origin+bank*bank_pitch+bank_local*p["b"]
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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)
    tile_columns = (p["w"]+7)//8
    tile_x = p["x"]//8
    tile_y = p["y"]//4
    bank = (p["x"]%4)^(p["y"]%4)
    bank_local = (p["y"]%4)*2+(p["x"]%8)//4
    bank_pitch = 8*p["b"]+1
    tile_pitch = 4*bank_pitch
    tile_row_pitch = tile_columns*tile_pitch+7
    tile_origin = p["base"]+tile_y*tile_row_pitch+tile_x*tile_pitch
    address = tile_origin+bank_local*4*p["b"]+bank*p["b"]+1
    return {'tile_columns': tile_columns, 'tile_x': tile_x, 'tile_y': tile_y, 'bank': bank, 'bank_local': bank_local, 'bank_pitch': bank_pitch, 'tile_pitch': tile_pitch, 'tile_row_pitch': tile_row_pitch, 'tile_origin': tile_origin, 'address': address}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 12}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 11, 'address': 71}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 265}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 143, 'tile_origin': 222, 'address': 237}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 211, 'tile_origin': 569, 'address': 570}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 17, 'tile_pitch': 68, 'tile_row_pitch': 75, 'tile_origin': 236, 'address': 288})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 23}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 22, 'address': 110}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 392}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 207, 'tile_origin': 329, 'address': 351}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 307, 'tile_origin': 836, 'address': 837}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 25, 'tile_pitch': 100, 'tile_row_pitch': 107, 'tile_origin': 343, 'address': 419})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 34}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 33, 'address': 149}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 519}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 271, 'tile_origin': 436, 'address': 465}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 403, 'tile_origin': 1103, 'address': 1104}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 33, 'tile_pitch': 132, 'tile_row_pitch': 139, 'tile_origin': 450, 'address': 550})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 44, 'address': 45}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 44, 'address': 188}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 646}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 335, 'tile_origin': 543, 'address': 579}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 499, 'tile_origin': 1370, 'address': 1371}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 41, 'tile_pitch': 164, 'tile_row_pitch': 171, 'tile_origin': 557, 'address': 681})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 0, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 55, 'address': 56}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 0, 'tile_y': 0, 'bank': 3, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 55, 'address': 227}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 2, 'bank_local': 4, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 773}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'tile_columns': 2, 'tile_x': 1, 'tile_y': 1, 'bank': 0, 'bank_local': 7, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 399, 'tile_origin': 650, 'address': 693}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'tile_columns': 3, 'tile_x': 2, 'tile_y': 2, 'bank': 0, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 595, 'tile_origin': 1637, 'address': 1638}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'tile_columns': 1, 'tile_x': 0, 'tile_y': 3, 'bank': 3, 'bank_local': 0, 'bank_pitch': 49, 'tile_pitch': 196, 'tile_row_pitch': 203, 'tile_origin': 664, 'address': 812})]}
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 8x4 tile has four banks. Bank = (local x modulo 4) XOR (local y modulo 4); each bank stores two columns per row and begins with a one-byte tag. Tile rows include a seven-byte trailer. 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)
    tail_first = next(i for i,s in enumerate(p["sizes"]) if s<=64)
    large_pages = [(s+63)//64 for s in p["sizes"][:tail_first]]
    tail_levels = list(range(len(p["sizes"])-1,tail_first-1,-1))
    tail_origin = p["base"]+sum(large_pages)*64
    tail_spans = [p["sizes"][i]+2 for i in tail_levels]
    tail_map = {level:tail_origin+sum(tail_spans[:j])+2 for j,level in enumerate(tail_levels)}
    large_map = {i:p["base"]+sum(large_pages[:i])*64 for i in range(tail_first)}
    selected = dict(large_map,**{}).get(p["level"],tail_map.get(p["level"],-1))
    tail_used = sum(tail_spans)
    allocation_end = tail_origin+p["tail_capacity"]
    return {'tail_first': tail_first, 'large_pages': large_pages, 'tail_levels': tail_levels, 'tail_origin': tail_origin, 'tail_spans': tail_spans, 'tail_map': tail_map, 'large_map': large_map, 'selected': selected, 'tail_used': tail_used, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'sizes': [121, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 7, 19], 'tail_map': {4: 201, 3: 204, 2: 211}, 'large_map': {0: 7, 1: 135}, 'selected': 7, 'tail_used': 29, 'allocation_end': 327}), ({'sizes': [122, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 8, 20], 'tail_map': {4: 201, 3: 204, 2: 212}, 'large_map': {0: 7, 1: 135}, 'selected': 135, 'tail_used': 31, 'allocation_end': 327}), ({'sizes': [123, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 9, 21], 'tail_map': {4: 201, 3: 204, 2: 213}, 'large_map': {0: 7, 1: 135}, 'selected': 213, 'tail_used': 33, 'allocation_end': 327}), ({'sizes': [124, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 10, 22], 'tail_map': {4: 201, 3: 204, 2: 214}, 'large_map': {0: 7, 1: 135}, 'selected': 204, 'tail_used': 35, 'allocation_end': 327}), ({'sizes': [125, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 263, 'tail_spans': [3, 11, 23], 'tail_map': {4: 265, 3: 268, 2: 279}, 'large_map': {0: 7, 1: 135}, 'selected': 265, 'tail_used': 37, 'allocation_end': 391}), ({'sizes': [126, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 263, 'tail_spans': [3, 12, 24], 'tail_map': {4: 265, 3: 268, 2: 280}, 'large_map': {0: 7, 1: 135}, 'selected': 7, 'tail_used': 39, 'allocation_end': 391})], 2: [({'sizes': [122, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 7, 19], 'tail_map': {4: 208, 3: 211, 2: 218}, 'large_map': {0: 14, 1: 142}, 'selected': 14, 'tail_used': 29, 'allocation_end': 334}), ({'sizes': [123, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 8, 20], 'tail_map': {4: 208, 3: 211, 2: 219}, 'large_map': {0: 14, 1: 142}, 'selected': 142, 'tail_used': 31, 'allocation_end': 334}), ({'sizes': [124, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 9, 21], 'tail_map': {4: 208, 3: 211, 2: 220}, 'large_map': {0: 14, 1: 142}, 'selected': 220, 'tail_used': 33, 'allocation_end': 334}), ({'sizes': [125, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 10, 22], 'tail_map': {4: 208, 3: 211, 2: 221}, 'large_map': {0: 14, 1: 142}, 'selected': 211, 'tail_used': 35, 'allocation_end': 334}), ({'sizes': [126, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 270, 'tail_spans': [3, 11, 23], 'tail_map': {4: 272, 3: 275, 2: 286}, 'large_map': {0: 14, 1: 142}, 'selected': 272, 'tail_used': 37, 'allocation_end': 398}), ({'sizes': [127, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 270, 'tail_spans': [3, 12, 24], 'tail_map': {4: 272, 3: 275, 2: 287}, 'large_map': {0: 14, 1: 142}, 'selected': 14, 'tail_used': 39, 'allocation_end': 398})], 3: [({'sizes': [123, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 7, 19], 'tail_map': {4: 215, 3: 218, 2: 225}, 'large_map': {0: 21, 1: 149}, 'selected': 21, 'tail_used': 29, 'allocation_end': 341}), ({'sizes': [124, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 8, 20], 'tail_map': {4: 215, 3: 218, 2: 226}, 'large_map': {0: 21, 1: 149}, 'selected': 149, 'tail_used': 31, 'allocation_end': 341}), ({'sizes': [125, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 9, 21], 'tail_map': {4: 215, 3: 218, 2: 227}, 'large_map': {0: 21, 1: 149}, 'selected': 227, 'tail_used': 33, 'allocation_end': 341}), ({'sizes': [126, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 10, 22], 'tail_map': {4: 215, 3: 218, 2: 228}, 'large_map': {0: 21, 1: 149}, 'selected': 218, 'tail_used': 35, 'allocation_end': 341}), ({'sizes': [127, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 277, 'tail_spans': [3, 11, 23], 'tail_map': {4: 279, 3: 282, 2: 293}, 'large_map': {0: 21, 1: 149}, 'selected': 279, 'tail_used': 37, 'allocation_end': 405}), ({'sizes': [128, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 277, 'tail_spans': [3, 12, 24], 'tail_map': {4: 279, 3: 282, 2: 294}, 'large_map': {0: 21, 1: 149}, 'selected': 21, 'tail_used': 39, 'allocation_end': 405})], 4: [({'sizes': [124, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 7, 19], 'tail_map': {4: 222, 3: 225, 2: 232}, 'large_map': {0: 28, 1: 156}, 'selected': 28, 'tail_used': 29, 'allocation_end': 348}), ({'sizes': [125, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 8, 20], 'tail_map': {4: 222, 3: 225, 2: 233}, 'large_map': {0: 28, 1: 156}, 'selected': 156, 'tail_used': 31, 'allocation_end': 348}), ({'sizes': [126, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 9, 21], 'tail_map': {4: 222, 3: 225, 2: 234}, 'large_map': {0: 28, 1: 156}, 'selected': 234, 'tail_used': 33, 'allocation_end': 348}), ({'sizes': [127, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 10, 22], 'tail_map': {4: 222, 3: 225, 2: 235}, 'large_map': {0: 28, 1: 156}, 'selected': 225, 'tail_used': 35, 'allocation_end': 348}), ({'sizes': [128, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 284, 'tail_spans': [3, 11, 23], 'tail_map': {4: 286, 3: 289, 2: 300}, 'large_map': {0: 28, 1: 156}, 'selected': 286, 'tail_used': 37, 'allocation_end': 412}), ({'sizes': [129, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [3, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 348, 'tail_spans': [3, 12, 24], 'tail_map': {4: 350, 3: 353, 2: 365}, 'large_map': {0: 28, 1: 220}, 'selected': 28, 'tail_used': 39, 'allocation_end': 476})], 5: [({'sizes': [125, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 7, 19], 'tail_map': {4: 229, 3: 232, 2: 239}, 'large_map': {0: 35, 1: 163}, 'selected': 35, 'tail_used': 29, 'allocation_end': 355}), ({'sizes': [126, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 8, 20], 'tail_map': {4: 229, 3: 232, 2: 240}, 'large_map': {0: 35, 1: 163}, 'selected': 163, 'tail_used': 31, 'allocation_end': 355}), ({'sizes': [127, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 9, 21], 'tail_map': {4: 229, 3: 232, 2: 241}, 'large_map': {0: 35, 1: 163}, 'selected': 241, 'tail_used': 33, 'allocation_end': 355}), ({'sizes': [128, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 10, 22], 'tail_map': {4: 229, 3: 232, 2: 242}, 'large_map': {0: 35, 1: 163}, 'selected': 232, 'tail_used': 35, 'allocation_end': 355}), ({'sizes': [129, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [3, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 355, 'tail_spans': [3, 11, 23], 'tail_map': {4: 357, 3: 360, 2: 371}, 'large_map': {0: 35, 1: 227}, 'selected': 357, 'tail_used': 37, 'allocation_end': 483}), ({'sizes': [130, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [3, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 355, 'tail_spans': [3, 12, 24], 'tail_map': {4: 357, 3: 360, 2: 372}, 'large_map': {0: 35, 1: 227}, 'selected': 35, 'tail_used': 39, 'allocation_end': 483})]}
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)
    tail_first = 0
    large_pages = [(s+63)//64 for s in p["sizes"][:tail_first]]
    tail_levels = list(range(len(p["sizes"])-1,tail_first-1,-1))
    tail_origin = p["base"]+sum(large_pages)*64
    tail_spans = [p["sizes"][i]+2 for i in tail_levels]
    tail_map = {level:tail_origin+sum(tail_spans[:j])+2 for j,level in enumerate(tail_levels)}
    large_map = {i:p["base"]+sum(large_pages[:i])*64 for i in range(tail_first)}
    selected = dict(large_map,**{}).get(p["level"],tail_map.get(p["level"],-1))
    tail_used = sum(tail_spans)
    allocation_end = tail_origin+p["tail_capacity"]
    return {'tail_first': tail_first, 'large_pages': large_pages, 'tail_levels': tail_levels, 'tail_origin': tail_origin, 'tail_spans': tail_spans, 'tail_map': tail_map, 'large_map': large_map, 'selected': selected, 'tail_used': tail_used, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'sizes': [121, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 7, 19], 'tail_map': {4: 201, 3: 204, 2: 211}, 'large_map': {0: 7, 1: 135}, 'selected': 7, 'tail_used': 29, 'allocation_end': 327}), ({'sizes': [122, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 8, 20], 'tail_map': {4: 201, 3: 204, 2: 212}, 'large_map': {0: 7, 1: 135}, 'selected': 135, 'tail_used': 31, 'allocation_end': 327}), ({'sizes': [123, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 9, 21], 'tail_map': {4: 201, 3: 204, 2: 213}, 'large_map': {0: 7, 1: 135}, 'selected': 213, 'tail_used': 33, 'allocation_end': 327}), ({'sizes': [124, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 199, 'tail_spans': [3, 10, 22], 'tail_map': {4: 201, 3: 204, 2: 214}, 'large_map': {0: 7, 1: 135}, 'selected': 204, 'tail_used': 35, 'allocation_end': 327}), ({'sizes': [125, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 263, 'tail_spans': [3, 11, 23], 'tail_map': {4: 265, 3: 268, 2: 279}, 'large_map': {0: 7, 1: 135}, 'selected': 265, 'tail_used': 37, 'allocation_end': 391}), ({'sizes': [126, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 7, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 263, 'tail_spans': [3, 12, 24], 'tail_map': {4: 265, 3: 268, 2: 280}, 'large_map': {0: 7, 1: 135}, 'selected': 7, 'tail_used': 39, 'allocation_end': 391})], 2: [({'sizes': [122, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 7, 19], 'tail_map': {4: 208, 3: 211, 2: 218}, 'large_map': {0: 14, 1: 142}, 'selected': 14, 'tail_used': 29, 'allocation_end': 334}), ({'sizes': [123, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 8, 20], 'tail_map': {4: 208, 3: 211, 2: 219}, 'large_map': {0: 14, 1: 142}, 'selected': 142, 'tail_used': 31, 'allocation_end': 334}), ({'sizes': [124, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 9, 21], 'tail_map': {4: 208, 3: 211, 2: 220}, 'large_map': {0: 14, 1: 142}, 'selected': 220, 'tail_used': 33, 'allocation_end': 334}), ({'sizes': [125, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 206, 'tail_spans': [3, 10, 22], 'tail_map': {4: 208, 3: 211, 2: 221}, 'large_map': {0: 14, 1: 142}, 'selected': 211, 'tail_used': 35, 'allocation_end': 334}), ({'sizes': [126, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 270, 'tail_spans': [3, 11, 23], 'tail_map': {4: 272, 3: 275, 2: 286}, 'large_map': {0: 14, 1: 142}, 'selected': 272, 'tail_used': 37, 'allocation_end': 398}), ({'sizes': [127, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 14, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 270, 'tail_spans': [3, 12, 24], 'tail_map': {4: 272, 3: 275, 2: 287}, 'large_map': {0: 14, 1: 142}, 'selected': 14, 'tail_used': 39, 'allocation_end': 398})], 3: [({'sizes': [123, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 7, 19], 'tail_map': {4: 215, 3: 218, 2: 225}, 'large_map': {0: 21, 1: 149}, 'selected': 21, 'tail_used': 29, 'allocation_end': 341}), ({'sizes': [124, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 8, 20], 'tail_map': {4: 215, 3: 218, 2: 226}, 'large_map': {0: 21, 1: 149}, 'selected': 149, 'tail_used': 31, 'allocation_end': 341}), ({'sizes': [125, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 9, 21], 'tail_map': {4: 215, 3: 218, 2: 227}, 'large_map': {0: 21, 1: 149}, 'selected': 227, 'tail_used': 33, 'allocation_end': 341}), ({'sizes': [126, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 213, 'tail_spans': [3, 10, 22], 'tail_map': {4: 215, 3: 218, 2: 228}, 'large_map': {0: 21, 1: 149}, 'selected': 218, 'tail_used': 35, 'allocation_end': 341}), ({'sizes': [127, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 277, 'tail_spans': [3, 11, 23], 'tail_map': {4: 279, 3: 282, 2: 293}, 'large_map': {0: 21, 1: 149}, 'selected': 279, 'tail_used': 37, 'allocation_end': 405}), ({'sizes': [128, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 21, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 277, 'tail_spans': [3, 12, 24], 'tail_map': {4: 279, 3: 282, 2: 294}, 'large_map': {0: 21, 1: 149}, 'selected': 21, 'tail_used': 39, 'allocation_end': 405})], 4: [({'sizes': [124, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 7, 19], 'tail_map': {4: 222, 3: 225, 2: 232}, 'large_map': {0: 28, 1: 156}, 'selected': 28, 'tail_used': 29, 'allocation_end': 348}), ({'sizes': [125, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 8, 20], 'tail_map': {4: 222, 3: 225, 2: 233}, 'large_map': {0: 28, 1: 156}, 'selected': 156, 'tail_used': 31, 'allocation_end': 348}), ({'sizes': [126, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 9, 21], 'tail_map': {4: 222, 3: 225, 2: 234}, 'large_map': {0: 28, 1: 156}, 'selected': 234, 'tail_used': 33, 'allocation_end': 348}), ({'sizes': [127, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 220, 'tail_spans': [3, 10, 22], 'tail_map': {4: 222, 3: 225, 2: 235}, 'large_map': {0: 28, 1: 156}, 'selected': 225, 'tail_used': 35, 'allocation_end': 348}), ({'sizes': [128, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 284, 'tail_spans': [3, 11, 23], 'tail_map': {4: 286, 3: 289, 2: 300}, 'large_map': {0: 28, 1: 156}, 'selected': 286, 'tail_used': 37, 'allocation_end': 412}), ({'sizes': [129, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 28, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [3, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 348, 'tail_spans': [3, 12, 24], 'tail_map': {4: 350, 3: 353, 2: 365}, 'large_map': {0: 28, 1: 220}, 'selected': 28, 'tail_used': 39, 'allocation_end': 476})], 5: [({'sizes': [125, 61, 17, 5, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 7, 19], 'tail_map': {4: 229, 3: 232, 2: 239}, 'large_map': {0: 35, 1: 163}, 'selected': 35, 'tail_used': 29, 'allocation_end': 355}), ({'sizes': [126, 62, 18, 6, 1], 'threshold': 32, 'page': 64, 'level': 1, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 8, 20], 'tail_map': {4: 229, 3: 232, 2: 240}, 'large_map': {0: 35, 1: 163}, 'selected': 163, 'tail_used': 31, 'allocation_end': 355}), ({'sizes': [127, 63, 19, 7, 1], 'threshold': 32, 'page': 64, 'level': 2, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 9, 21], 'tail_map': {4: 229, 3: 232, 2: 241}, 'large_map': {0: 35, 1: 163}, 'selected': 241, 'tail_used': 33, 'allocation_end': 355}), ({'sizes': [128, 64, 20, 8, 1], 'threshold': 32, 'page': 64, 'level': 3, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [2, 1], 'tail_levels': [4, 3, 2], 'tail_origin': 227, 'tail_spans': [3, 10, 22], 'tail_map': {4: 229, 3: 232, 2: 242}, 'large_map': {0: 35, 1: 163}, 'selected': 232, 'tail_used': 35, 'allocation_end': 355}), ({'sizes': [129, 65, 21, 9, 1], 'threshold': 32, 'page': 64, 'level': 4, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [3, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 355, 'tail_spans': [3, 11, 23], 'tail_map': {4: 357, 3: 360, 2: 371}, 'large_map': {0: 35, 1: 227}, 'selected': 357, 'tail_used': 37, 'allocation_end': 483}), ({'sizes': [130, 66, 22, 10, 1], 'threshold': 32, 'page': 64, 'level': 0, 'base': 35, 'tail_capacity': 128}, {'tail_first': 2, 'large_pages': [3, 2], 'tail_levels': [4, 3, 2], 'tail_origin': 355, 'tail_spans': [3, 12, 24], 'tail_map': {4: 357, 3: 360, 2: 372}, 'large_map': {0: 35, 1: 227}, 'selected': 35, 'tail_used': 39, 'allocation_end': 483})]}
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 tail_first.

Mip levels below a threshold share one fixed-size tail page. Larger levels each own whole pages. Tail levels are packed in reverse level order, each with a two-byte tag; tail capacity is caller-provided and sufficient. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access