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

N = 1
observations = []
def solve(p):
    p = dict(p)
    image_pixels = p["w"]+p["h"]
    sample_pitch = image_pixels*p["b"]+5
    layer_pitch = sample_pitch*p["samples"]+7
    layer_origin = p["base"]+p["layer"]*layer_pitch
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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)
    image_pixels = p["w"]*p["w"]
    sample_pitch = image_pixels*p["b"]+5
    layer_pitch = sample_pitch*p["samples"]+7
    layer_origin = p["base"]+p["layer"]*layer_pitch
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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 image_pixels.

A toy multisample target stores one full image per sample within each layer. Each sample image starts with a five-byte coverage header; layer footer length is seven bytes. Samples are never resolved or averaged. 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)
    image_pixels = p["w"]*p["h"]
    sample_pitch = image_pixels*p["b"]
    layer_pitch = sample_pitch*p["samples"]+7
    layer_origin = p["base"]+p["layer"]*layer_pitch
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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)
    image_pixels = p["w"]*p["h"]
    sample_pitch = (image_pixels+5)*p["b"]
    layer_pitch = sample_pitch*p["samples"]+7
    layer_origin = p["base"]+p["layer"]*layer_pitch
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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 sample_pitch.

A toy multisample target stores one full image per sample within each layer. Each sample image starts with a five-byte coverage header; layer footer length is seven bytes. Samples are never resolved or averaged. 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)
    image_pixels = p["w"]*p["h"]
    sample_pitch = image_pixels*p["b"]+5
    layer_pitch = sample_pitch+7
    layer_origin = p["base"]+p["layer"]*layer_pitch
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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)
    image_pixels = p["w"]*p["h"]
    sample_pitch = image_pixels*p["b"]+5
    layer_pitch = (sample_pitch+7)*p["samples"]
    layer_origin = p["base"]+p["layer"]*layer_pitch
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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 layer_pitch.

A toy multisample target stores one full image per sample within each layer. Each sample image starts with a five-byte coverage header; layer footer length is seven bytes. Samples are never resolved or averaged. 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)
    image_pixels = p["w"]*p["h"]
    sample_pitch = image_pixels*p["b"]+5
    layer_pitch = sample_pitch*p["samples"]+7
    layer_origin = p["base"]+p["layer"]*sample_pitch
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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)
    image_pixels = p["w"]*p["h"]
    sample_pitch = image_pixels*p["b"]+5
    layer_pitch = sample_pitch*p["samples"]+7
    layer_origin = p["base"]+p["layer"]*layer_pitch*p["samples"]
    sample_origin = layer_origin+p["sample"]*sample_pitch+5
    pixel_index = p["y"]*p["w"]+p["x"]
    address = sample_origin+pixel_index*p["b"]
    coverage_address = layer_origin+p["sample"]*sample_pitch
    footer_address = layer_origin+p["samples"]*sample_pitch
    allocation_end = p["base"]+p["layers"]*layer_pitch
    return {'image_pixels': image_pixels, 'sample_pitch': sample_pitch, 'layer_pitch': layer_pitch, 'layer_origin': layer_origin, 'sample_origin': sample_origin, 'pixel_index': pixel_index, 'address': address, 'coverage_address': coverage_address, 'footer_address': footer_address, 'allocation_end': allocation_end}
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, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 7, 'layer_pitch': 35, 'layer_origin': 11, 'sample_origin': 16, 'pixel_index': 0, 'address': 16, 'coverage_address': 11, 'footer_address': 39, 'allocation_end': 116}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 24, 'sample_pitch': 53, 'layer_pitch': 219, 'layer_origin': 230, 'sample_origin': 288, 'pixel_index': 13, 'address': 314, 'coverage_address': 283, 'footer_address': 442, 'allocation_end': 668}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'samples': 4, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 80, 'sample_pitch': 165, 'layer_pitch': 667, 'layer_origin': 1345, 'sample_origin': 1680, 'pixel_index': 68, 'address': 1816, 'coverage_address': 1675, 'footer_address': 2005, 'allocation_end': 2012}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'samples': 4, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 261, 'layer_pitch': 1051, 'layer_origin': 11, 'sample_origin': 799, 'pixel_index': 127, 'address': 1053, 'coverage_address': 794, 'footer_address': 1055, 'allocation_end': 3164}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'samples': 4, 'sample': 0, 'layers': 3, 'layer': 1}, {'image_pixels': 180, 'sample_pitch': 365, 'layer_pitch': 1467, 'layer_origin': 1478, 'sample_origin': 1483, 'pixel_index': 160, 'address': 1803, 'coverage_address': 1478, 'footer_address': 2938, 'allocation_end': 4412}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'samples': 4, 'sample': 1, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 187, 'layer_pitch': 755, 'layer_origin': 1521, 'sample_origin': 1713, 'pixel_index': 87, 'address': 1887, 'coverage_address': 1708, 'footer_address': 2269, 'allocation_end': 2276})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 8, 'layer_pitch': 47, 'layer_origin': 22, 'sample_origin': 27, 'pixel_index': 0, 'address': 27, 'coverage_address': 22, 'footer_address': 62, 'allocation_end': 163}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'samples': 5, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 35, 'sample_pitch': 110, 'layer_pitch': 557, 'layer_origin': 579, 'sample_origin': 694, 'pixel_index': 15, 'address': 739, 'coverage_address': 689, 'footer_address': 1129, 'allocation_end': 1693}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'samples': 5, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 99, 'sample_pitch': 302, 'layer_pitch': 1517, 'layer_origin': 3056, 'sample_origin': 3665, 'pixel_index': 74, 'address': 3887, 'coverage_address': 3660, 'footer_address': 4566, 'allocation_end': 4573}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'samples': 5, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 389, 'layer_pitch': 1952, 'layer_origin': 22, 'sample_origin': 1194, 'pixel_index': 127, 'address': 1575, 'coverage_address': 1189, 'footer_address': 1967, 'allocation_end': 5878}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'samples': 5, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 209, 'sample_pitch': 632, 'layer_pitch': 3167, 'layer_origin': 3189, 'sample_origin': 5722, 'pixel_index': 168, 'address': 6226, 'coverage_address': 5717, 'footer_address': 6349, 'allocation_end': 9523}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'samples': 5, 'sample': 0, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 278, 'layer_pitch': 1397, 'layer_origin': 2816, 'sample_origin': 2821, 'pixel_index': 87, 'address': 3082, 'coverage_address': 2816, 'footer_address': 4206, 'allocation_end': 4213})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'samples': 6, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 9, 'layer_pitch': 61, 'layer_origin': 33, 'sample_origin': 38, 'pixel_index': 0, 'address': 38, 'coverage_address': 33, 'footer_address': 87, 'allocation_end': 216}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'samples': 6, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 48, 'sample_pitch': 197, 'layer_pitch': 1189, 'layer_origin': 1222, 'sample_origin': 1424, 'pixel_index': 17, 'address': 1492, 'coverage_address': 1419, 'footer_address': 2404, 'allocation_end': 3600}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'samples': 6, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 120, 'sample_pitch': 485, 'layer_pitch': 2917, 'layer_origin': 5867, 'sample_origin': 6842, 'pixel_index': 80, 'address': 7162, 'coverage_address': 6837, 'footer_address': 8777, 'allocation_end': 8784}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'samples': 6, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 517, 'layer_pitch': 3109, 'layer_origin': 33, 'sample_origin': 1589, 'pixel_index': 127, 'address': 2097, 'coverage_address': 1584, 'footer_address': 3135, 'allocation_end': 9360}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'samples': 6, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 240, 'sample_pitch': 965, 'layer_pitch': 5797, 'layer_origin': 5830, 'sample_origin': 9695, 'pixel_index': 176, 'address': 10399, 'coverage_address': 9690, 'footer_address': 11620, 'allocation_end': 17424}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'samples': 6, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 369, 'layer_pitch': 2221, 'layer_origin': 4475, 'sample_origin': 6325, 'pixel_index': 87, 'address': 6673, 'coverage_address': 6320, 'footer_address': 6689, 'allocation_end': 6696})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'samples': 7, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 10, 'layer_pitch': 77, 'layer_origin': 44, 'sample_origin': 49, 'pixel_index': 0, 'address': 49, 'coverage_address': 44, 'footer_address': 114, 'allocation_end': 275}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'samples': 7, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 63, 'sample_pitch': 320, 'layer_pitch': 2247, 'layer_origin': 2291, 'sample_origin': 2616, 'pixel_index': 19, 'address': 2711, 'coverage_address': 2611, 'footer_address': 4531, 'allocation_end': 6785}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'samples': 7, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 143, 'sample_pitch': 720, 'layer_pitch': 5047, 'layer_origin': 10138, 'sample_origin': 11583, 'pixel_index': 86, 'address': 12013, 'coverage_address': 11578, 'footer_address': 15178, 'allocation_end': 15185}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'samples': 7, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 645, 'layer_pitch': 4522, 'layer_origin': 44, 'sample_origin': 1984, 'pixel_index': 127, 'address': 2619, 'coverage_address': 1979, 'footer_address': 4559, 'allocation_end': 13610}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'samples': 7, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 273, 'sample_pitch': 1370, 'layer_pitch': 9597, 'layer_origin': 9641, 'sample_origin': 15126, 'pixel_index': 184, 'address': 16046, 'coverage_address': 15121, 'footer_address': 19231, 'allocation_end': 28835}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'samples': 7, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 460, 'layer_pitch': 3227, 'layer_origin': 6498, 'sample_origin': 8803, 'pixel_index': 87, 'address': 9238, 'coverage_address': 8798, 'footer_address': 9718, 'allocation_end': 9725})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'samples': 8, 'sample': 0, 'layers': 3, 'layer': 0}, {'image_pixels': 1, 'sample_pitch': 11, 'layer_pitch': 95, 'layer_origin': 55, 'sample_origin': 60, 'pixel_index': 0, 'address': 60, 'coverage_address': 55, 'footer_address': 143, 'allocation_end': 340}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'samples': 8, 'sample': 1, 'layers': 3, 'layer': 1}, {'image_pixels': 80, 'sample_pitch': 485, 'layer_pitch': 3887, 'layer_origin': 3942, 'sample_origin': 4432, 'pixel_index': 21, 'address': 4558, 'coverage_address': 4427, 'footer_address': 7822, 'allocation_end': 11716}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'samples': 8, 'sample': 2, 'layers': 3, 'layer': 2}, {'image_pixels': 168, 'sample_pitch': 1013, 'layer_pitch': 8111, 'layer_origin': 16277, 'sample_origin': 18308, 'pixel_index': 92, 'address': 18860, 'coverage_address': 18303, 'footer_address': 24381, 'allocation_end': 24388}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'samples': 8, 'sample': 3, 'layers': 3, 'layer': 0}, {'image_pixels': 128, 'sample_pitch': 773, 'layer_pitch': 6191, 'layer_origin': 55, 'sample_origin': 2379, 'pixel_index': 127, 'address': 3141, 'coverage_address': 2374, 'footer_address': 6239, 'allocation_end': 18628}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'samples': 8, 'sample': 4, 'layers': 3, 'layer': 1}, {'image_pixels': 308, 'sample_pitch': 1853, 'layer_pitch': 14831, 'layer_origin': 14886, 'sample_origin': 22303, 'pixel_index': 192, 'address': 23455, 'coverage_address': 22298, 'footer_address': 29710, 'allocation_end': 44548}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'samples': 8, 'sample': 5, 'layers': 3, 'layer': 2}, {'image_pixels': 91, 'sample_pitch': 551, 'layer_pitch': 4415, 'layer_origin': 8885, 'sample_origin': 11645, 'pixel_index': 87, 'address': 12167, 'coverage_address': 11640, 'footer_address': 13293, 'allocation_end': 13300})]}
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 layer_origin.

A toy multisample target stores one full image per sample within each layer. Each sample image starts with a five-byte coverage header; layer footer length is seven bytes. Samples are never resolved or averaged. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access