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

N = 1
observations = []
def solve(p):
    p = dict(p)
    channel_offsets = [sum(p["widths"][:i]) for i in range(4)]
    pixel_pitch = sum(p["widths"])+2
    physical_channel = p["remap"][p["channel"]]
    row_pitch = p["w"]*pixel_pitch+3
    pixel_origin = p["base"]+p["y"]*row_pitch+p["x"]*pixel_pitch
    channel_start = pixel_origin+channel_offsets[physical_channel]
    channel_size = p["widths"][physical_channel]
    channel_end = channel_start+channel_size
    footer_start = pixel_origin+sum(p["widths"])
    other_channel_ranges = [[pixel_origin+channel_offsets[i],pixel_origin+channel_offsets[i]+p["widths"][i]] for i in range(4) if i!=p["channel"]]
    return {'channel_offsets': channel_offsets, 'pixel_pitch': pixel_pitch, 'physical_channel': physical_channel, 'row_pitch': row_pitch, 'pixel_origin': pixel_origin, 'channel_start': channel_start, 'channel_size': channel_size, 'channel_end': channel_end, 'footer_start': footer_start, 'other_channel_ranges': other_channel_ranges}
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, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 11, 'channel_start': 14, 'channel_size': 1, 'channel_end': 15, 'footer_start': 19, 'other_channel_ranges': [[11, 12], [12, 14], [15, 19]]}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 63, 'pixel_origin': 147, 'channel_start': 147, 'channel_size': 1, 'channel_end': 148, 'footer_start': 155, 'other_channel_ranges': [[148, 150], [150, 151], [151, 155]]}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 103, 'pixel_origin': 709, 'channel_start': 713, 'channel_size': 4, 'channel_end': 717, 'footer_start': 717, 'other_channel_ranges': [[709, 710], [710, 712], [712, 713]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1302, 'channel_start': 1303, 'channel_size': 2, 'channel_end': 1305, 'footer_start': 1310, 'other_channel_ranges': [[1302, 1303], [1305, 1306], [1306, 1310]]}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 183, 'pixel_origin': 1635, 'channel_start': 1638, 'channel_size': 1, 'channel_end': 1639, 'footer_start': 1643, 'other_channel_ranges': [[1635, 1636], [1636, 1638], [1639, 1643]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 917, 'channel_start': 917, 'channel_size': 1, 'channel_end': 918, 'footer_start': 925, 'other_channel_ranges': [[918, 920], [920, 921], [921, 925]]})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 22, 'channel_start': 25, 'channel_size': 1, 'channel_end': 26, 'footer_start': 30, 'other_channel_ranges': [[22, 23], [23, 25], [26, 30]]}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 178, 'channel_start': 178, 'channel_size': 1, 'channel_end': 179, 'footer_start': 186, 'other_channel_ranges': [[179, 181], [181, 182], [182, 186]]}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 113, 'pixel_origin': 780, 'channel_start': 784, 'channel_size': 4, 'channel_end': 788, 'footer_start': 788, 'other_channel_ranges': [[780, 781], [781, 783], [783, 784]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1313, 'channel_start': 1314, 'channel_size': 2, 'channel_end': 1316, 'footer_start': 1321, 'other_channel_ranges': [[1313, 1314], [1316, 1317], [1317, 1321]]}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 193, 'pixel_origin': 1726, 'channel_start': 1729, 'channel_size': 1, 'channel_end': 1730, 'footer_start': 1734, 'other_channel_ranges': [[1726, 1727], [1727, 1729], [1730, 1734]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 928, 'channel_start': 928, 'channel_size': 1, 'channel_end': 929, 'footer_start': 936, 'other_channel_ranges': [[929, 931], [931, 932], [932, 936]]})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 33, 'channel_start': 36, 'channel_size': 1, 'channel_end': 37, 'footer_start': 41, 'other_channel_ranges': [[33, 34], [34, 36], [37, 41]]}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 83, 'pixel_origin': 209, 'channel_start': 209, 'channel_size': 1, 'channel_end': 210, 'footer_start': 217, 'other_channel_ranges': [[210, 212], [212, 213], [213, 217]]}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 123, 'pixel_origin': 851, 'channel_start': 855, 'channel_size': 4, 'channel_end': 859, 'footer_start': 859, 'other_channel_ranges': [[851, 852], [852, 854], [854, 855]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1324, 'channel_start': 1325, 'channel_size': 2, 'channel_end': 1327, 'footer_start': 1332, 'other_channel_ranges': [[1324, 1325], [1327, 1328], [1328, 1332]]}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 203, 'pixel_origin': 1817, 'channel_start': 1820, 'channel_size': 1, 'channel_end': 1821, 'footer_start': 1825, 'other_channel_ranges': [[1817, 1818], [1818, 1820], [1821, 1825]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 939, 'channel_start': 939, 'channel_size': 1, 'channel_end': 940, 'footer_start': 947, 'other_channel_ranges': [[940, 942], [942, 943], [943, 947]]})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 44, 'channel_start': 47, 'channel_size': 1, 'channel_end': 48, 'footer_start': 52, 'other_channel_ranges': [[44, 45], [45, 47], [48, 52]]}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 93, 'pixel_origin': 240, 'channel_start': 240, 'channel_size': 1, 'channel_end': 241, 'footer_start': 248, 'other_channel_ranges': [[241, 243], [243, 244], [244, 248]]}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 133, 'pixel_origin': 922, 'channel_start': 926, 'channel_size': 4, 'channel_end': 930, 'footer_start': 930, 'other_channel_ranges': [[922, 923], [923, 925], [925, 926]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1335, 'channel_start': 1336, 'channel_size': 2, 'channel_end': 1338, 'footer_start': 1343, 'other_channel_ranges': [[1335, 1336], [1338, 1339], [1339, 1343]]}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 213, 'pixel_origin': 1908, 'channel_start': 1911, 'channel_size': 1, 'channel_end': 1912, 'footer_start': 1916, 'other_channel_ranges': [[1908, 1909], [1909, 1911], [1912, 1916]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 950, 'channel_start': 950, 'channel_size': 1, 'channel_end': 951, 'footer_start': 958, 'other_channel_ranges': [[951, 953], [953, 954], [954, 958]]})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 55, 'channel_start': 58, 'channel_size': 1, 'channel_end': 59, 'footer_start': 63, 'other_channel_ranges': [[55, 56], [56, 58], [59, 63]]}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 103, 'pixel_origin': 271, 'channel_start': 271, 'channel_size': 1, 'channel_end': 272, 'footer_start': 279, 'other_channel_ranges': [[272, 274], [274, 275], [275, 279]]}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 143, 'pixel_origin': 993, 'channel_start': 997, 'channel_size': 4, 'channel_end': 1001, 'footer_start': 1001, 'other_channel_ranges': [[993, 994], [994, 996], [996, 997]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1346, 'channel_start': 1347, 'channel_size': 2, 'channel_end': 1349, 'footer_start': 1354, 'other_channel_ranges': [[1346, 1347], [1349, 1350], [1350, 1354]]}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 223, 'pixel_origin': 1999, 'channel_start': 2002, 'channel_size': 1, 'channel_end': 2003, 'footer_start': 2007, 'other_channel_ranges': [[1999, 2000], [2000, 2002], [2003, 2007]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 961, 'channel_start': 961, 'channel_size': 1, 'channel_end': 962, 'footer_start': 969, 'other_channel_ranges': [[962, 964], [964, 965], [965, 969]]})]}
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)
    channel_offsets = [sum(p["widths"][:i]) for i in range(4)]
    pixel_pitch = sum(p["widths"])+2
    physical_channel = p["remap"][p["channel"]]
    row_pitch = p["w"]*pixel_pitch+3
    pixel_origin = p["base"]+p["y"]*row_pitch+p["x"]*pixel_pitch
    channel_start = pixel_origin+channel_offsets[physical_channel]
    channel_size = p["widths"][physical_channel]
    channel_end = channel_start+channel_size
    footer_start = pixel_origin+sum(p["widths"])
    other_channel_ranges = []
    return {'channel_offsets': channel_offsets, 'pixel_pitch': pixel_pitch, 'physical_channel': physical_channel, 'row_pitch': row_pitch, 'pixel_origin': pixel_origin, 'channel_start': channel_start, 'channel_size': channel_size, 'channel_end': channel_end, 'footer_start': footer_start, 'other_channel_ranges': other_channel_ranges}
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, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 11, 'channel_start': 14, 'channel_size': 1, 'channel_end': 15, 'footer_start': 19, 'other_channel_ranges': [[11, 12], [12, 14], [15, 19]]}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 63, 'pixel_origin': 147, 'channel_start': 147, 'channel_size': 1, 'channel_end': 148, 'footer_start': 155, 'other_channel_ranges': [[148, 150], [150, 151], [151, 155]]}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 103, 'pixel_origin': 709, 'channel_start': 713, 'channel_size': 4, 'channel_end': 717, 'footer_start': 717, 'other_channel_ranges': [[709, 710], [710, 712], [712, 713]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1302, 'channel_start': 1303, 'channel_size': 2, 'channel_end': 1305, 'footer_start': 1310, 'other_channel_ranges': [[1302, 1303], [1305, 1306], [1306, 1310]]}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 183, 'pixel_origin': 1635, 'channel_start': 1638, 'channel_size': 1, 'channel_end': 1639, 'footer_start': 1643, 'other_channel_ranges': [[1635, 1636], [1636, 1638], [1639, 1643]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 917, 'channel_start': 917, 'channel_size': 1, 'channel_end': 918, 'footer_start': 925, 'other_channel_ranges': [[918, 920], [920, 921], [921, 925]]})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 22, 'channel_start': 25, 'channel_size': 1, 'channel_end': 26, 'footer_start': 30, 'other_channel_ranges': [[22, 23], [23, 25], [26, 30]]}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 178, 'channel_start': 178, 'channel_size': 1, 'channel_end': 179, 'footer_start': 186, 'other_channel_ranges': [[179, 181], [181, 182], [182, 186]]}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 113, 'pixel_origin': 780, 'channel_start': 784, 'channel_size': 4, 'channel_end': 788, 'footer_start': 788, 'other_channel_ranges': [[780, 781], [781, 783], [783, 784]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1313, 'channel_start': 1314, 'channel_size': 2, 'channel_end': 1316, 'footer_start': 1321, 'other_channel_ranges': [[1313, 1314], [1316, 1317], [1317, 1321]]}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 193, 'pixel_origin': 1726, 'channel_start': 1729, 'channel_size': 1, 'channel_end': 1730, 'footer_start': 1734, 'other_channel_ranges': [[1726, 1727], [1727, 1729], [1730, 1734]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 928, 'channel_start': 928, 'channel_size': 1, 'channel_end': 929, 'footer_start': 936, 'other_channel_ranges': [[929, 931], [931, 932], [932, 936]]})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 33, 'channel_start': 36, 'channel_size': 1, 'channel_end': 37, 'footer_start': 41, 'other_channel_ranges': [[33, 34], [34, 36], [37, 41]]}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 83, 'pixel_origin': 209, 'channel_start': 209, 'channel_size': 1, 'channel_end': 210, 'footer_start': 217, 'other_channel_ranges': [[210, 212], [212, 213], [213, 217]]}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 123, 'pixel_origin': 851, 'channel_start': 855, 'channel_size': 4, 'channel_end': 859, 'footer_start': 859, 'other_channel_ranges': [[851, 852], [852, 854], [854, 855]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1324, 'channel_start': 1325, 'channel_size': 2, 'channel_end': 1327, 'footer_start': 1332, 'other_channel_ranges': [[1324, 1325], [1327, 1328], [1328, 1332]]}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 203, 'pixel_origin': 1817, 'channel_start': 1820, 'channel_size': 1, 'channel_end': 1821, 'footer_start': 1825, 'other_channel_ranges': [[1817, 1818], [1818, 1820], [1821, 1825]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 939, 'channel_start': 939, 'channel_size': 1, 'channel_end': 940, 'footer_start': 947, 'other_channel_ranges': [[940, 942], [942, 943], [943, 947]]})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 44, 'channel_start': 47, 'channel_size': 1, 'channel_end': 48, 'footer_start': 52, 'other_channel_ranges': [[44, 45], [45, 47], [48, 52]]}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 93, 'pixel_origin': 240, 'channel_start': 240, 'channel_size': 1, 'channel_end': 241, 'footer_start': 248, 'other_channel_ranges': [[241, 243], [243, 244], [244, 248]]}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 133, 'pixel_origin': 922, 'channel_start': 926, 'channel_size': 4, 'channel_end': 930, 'footer_start': 930, 'other_channel_ranges': [[922, 923], [923, 925], [925, 926]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1335, 'channel_start': 1336, 'channel_size': 2, 'channel_end': 1338, 'footer_start': 1343, 'other_channel_ranges': [[1335, 1336], [1338, 1339], [1339, 1343]]}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 213, 'pixel_origin': 1908, 'channel_start': 1911, 'channel_size': 1, 'channel_end': 1912, 'footer_start': 1916, 'other_channel_ranges': [[1908, 1909], [1909, 1911], [1912, 1916]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 950, 'channel_start': 950, 'channel_size': 1, 'channel_end': 951, 'footer_start': 958, 'other_channel_ranges': [[951, 953], [953, 954], [954, 958]]})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 13, 'pixel_origin': 55, 'channel_start': 58, 'channel_size': 1, 'channel_end': 59, 'footer_start': 63, 'other_channel_ranges': [[55, 56], [56, 58], [59, 63]]}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 103, 'pixel_origin': 271, 'channel_start': 271, 'channel_size': 1, 'channel_end': 272, 'footer_start': 279, 'other_channel_ranges': [[272, 274], [274, 275], [275, 279]]}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55, 'channel': 2, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 3, 'row_pitch': 143, 'pixel_origin': 993, 'channel_start': 997, 'channel_size': 4, 'channel_end': 1001, 'footer_start': 1001, 'other_channel_ranges': [[993, 994], [994, 996], [996, 997]]}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55, 'channel': 3, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 1, 'row_pitch': 163, 'pixel_origin': 1346, 'channel_start': 1347, 'channel_size': 2, 'channel_end': 1349, 'footer_start': 1354, 'other_channel_ranges': [[1346, 1347], [1349, 1350], [1350, 1354]]}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55, 'channel': 0, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 2, 'row_pitch': 223, 'pixel_origin': 1999, 'channel_start': 2002, 'channel_size': 1, 'channel_end': 2003, 'footer_start': 2007, 'other_channel_ranges': [[1999, 2000], [2000, 2002], [2003, 2007]]}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55, 'channel': 1, 'remap': [2, 0, 3, 1], 'widths': [1, 2, 1, 4]}, {'channel_offsets': [0, 1, 3, 4], 'pixel_pitch': 10, 'physical_channel': 0, 'row_pitch': 73, 'pixel_origin': 961, 'channel_start': 961, 'channel_size': 1, 'channel_end': 962, 'footer_start': 969, 'other_channel_ranges': [[962, 964], [964, 965], [965, 969]]})]}
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 other_channel_ranges.

A toy pixel record stores channels with widths [1,2,1,4] bytes and a two-byte per-pixel footer. A view remaps logical channel indices through [2,0,3,1], and image rows have a three-byte guard. Return byte ranges without numeric interpretation. 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)
    source_row_pitch = p["width"]*p["b"]
    source_slice_pitch = source_row_pitch*p["image_height"]
    skip_bytes = p["skip_z"]*source_slice_pitch+p["skip_y"]*source_row_pitch+p["skip_x"]*p["b"]
    source_origin = p["src"]+skip_bytes
    row_bytes = p["width"]*p["b"]
    source_rows = [source_origin+z*source_slice_pitch+y*source_row_pitch for z in range(p["depth"]) for y in range(p["height"])]
    destination_rows = [p["dst"]+z*p["ds"]+y*p["dp"] for z in range(p["depth"]) for y in range(p["height"])]
    transfers = [[s,d,row_bytes] for s,d in zip(source_rows,destination_rows)]
    source_required = source_rows[-1]+row_bytes-p["src"]
    destination_required = destination_rows[-1]+row_bytes-p["dst"]
    return {'source_row_pitch': source_row_pitch, 'source_slice_pitch': source_slice_pitch, 'skip_bytes': skip_bytes, 'source_origin': source_origin, 'row_bytes': row_bytes, 'source_rows': source_rows, 'destination_rows': destination_rows, 'transfers': transfers, 'source_required': source_required, 'destination_required': destination_required}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 24, 'source_slice_pitch': 168, 'skip_bytes': 218, 'source_origin': 225, 'row_bytes': 4, 'source_rows': [225], 'destination_rows': [401], 'transfers': [[225, 401, 4]], 'source_required': 222, 'destination_required': 4}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 26, 'source_slice_pitch': 208, 'skip_bytes': 264, 'source_origin': 271, 'row_bytes': 6, 'source_rows': [271, 297, 479, 505], 'destination_rows': [401, 482, 1102, 1183], 'transfers': [[271, 401, 6], [297, 482, 6], [479, 1102, 6], [505, 1183, 6]], 'source_required': 504, 'destination_required': 788}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 28, 'source_slice_pitch': 252, 'skip_bytes': 310, 'source_origin': 317, 'row_bytes': 8, 'source_rows': [317, 345, 373], 'destination_rows': [401, 482, 563], 'transfers': [[317, 401, 8], [345, 482, 8], [373, 563, 8]], 'source_required': 374, 'destination_required': 170}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 30, 'source_slice_pitch': 300, 'skip_bytes': 364, 'source_origin': 371, 'row_bytes': 10, 'source_rows': [371, 671], 'destination_rows': [401, 1102], 'transfers': [[371, 401, 10], [671, 1102, 10]], 'source_required': 674, 'destination_required': 711}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 32, 'source_slice_pitch': 352, 'skip_bytes': 418, 'source_origin': 425, 'row_bytes': 12, 'source_rows': [425, 457], 'destination_rows': [401, 482], 'transfers': [[425, 401, 12], [457, 482, 12]], 'source_required': 462, 'destination_required': 93}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 34, 'source_slice_pitch': 408, 'skip_bytes': 480, 'source_origin': 487, 'row_bytes': 14, 'source_rows': [487, 521, 555, 895, 929, 963], 'destination_rows': [401, 482, 563, 1102, 1183, 1264], 'transfers': [[487, 401, 14], [521, 482, 14], [555, 563, 14], [895, 1102, 14], [929, 1183, 14], [963, 1264, 14]], 'source_required': 970, 'destination_required': 877})], 2: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 36, 'source_slice_pitch': 252, 'skip_bytes': 327, 'source_origin': 341, 'row_bytes': 6, 'source_rows': [341], 'destination_rows': [402], 'transfers': [[341, 402, 6]], 'source_required': 333, 'destination_required': 6}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 39, 'source_slice_pitch': 312, 'skip_bytes': 396, 'source_origin': 410, 'row_bytes': 9, 'source_rows': [410, 449, 722, 761], 'destination_rows': [402, 484, 1104, 1186], 'transfers': [[410, 402, 9], [449, 484, 9], [722, 1104, 9], [761, 1186, 9]], 'source_required': 756, 'destination_required': 793}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 42, 'source_slice_pitch': 378, 'skip_bytes': 465, 'source_origin': 479, 'row_bytes': 12, 'source_rows': [479, 521, 563], 'destination_rows': [402, 484, 566], 'transfers': [[479, 402, 12], [521, 484, 12], [563, 566, 12]], 'source_required': 561, 'destination_required': 176}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 45, 'source_slice_pitch': 450, 'skip_bytes': 546, 'source_origin': 560, 'row_bytes': 15, 'source_rows': [560, 1010], 'destination_rows': [402, 1104], 'transfers': [[560, 402, 15], [1010, 1104, 15]], 'source_required': 1011, 'destination_required': 717}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 48, 'source_slice_pitch': 528, 'skip_bytes': 627, 'source_origin': 641, 'row_bytes': 18, 'source_rows': [641, 689], 'destination_rows': [402, 484], 'transfers': [[641, 402, 18], [689, 484, 18]], 'source_required': 693, 'destination_required': 100}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 51, 'source_slice_pitch': 612, 'skip_bytes': 720, 'source_origin': 734, 'row_bytes': 21, 'source_rows': [734, 785, 836, 1346, 1397, 1448], 'destination_rows': [402, 484, 566, 1104, 1186, 1268], 'transfers': [[734, 402, 21], [785, 484, 21], [836, 566, 21], [1346, 1104, 21], [1397, 1186, 21], [1448, 1268, 21]], 'source_required': 1455, 'destination_required': 887})], 3: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 48, 'source_slice_pitch': 336, 'skip_bytes': 436, 'source_origin': 457, 'row_bytes': 8, 'source_rows': [457], 'destination_rows': [403], 'transfers': [[457, 403, 8]], 'source_required': 444, 'destination_required': 8}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 52, 'source_slice_pitch': 416, 'skip_bytes': 528, 'source_origin': 549, 'row_bytes': 12, 'source_rows': [549, 601, 965, 1017], 'destination_rows': [403, 486, 1106, 1189], 'transfers': [[549, 403, 12], [601, 486, 12], [965, 1106, 12], [1017, 1189, 12]], 'source_required': 1008, 'destination_required': 798}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 56, 'source_slice_pitch': 504, 'skip_bytes': 620, 'source_origin': 641, 'row_bytes': 16, 'source_rows': [641, 697, 753], 'destination_rows': [403, 486, 569], 'transfers': [[641, 403, 16], [697, 486, 16], [753, 569, 16]], 'source_required': 748, 'destination_required': 182}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 60, 'source_slice_pitch': 600, 'skip_bytes': 728, 'source_origin': 749, 'row_bytes': 20, 'source_rows': [749, 1349], 'destination_rows': [403, 1106], 'transfers': [[749, 403, 20], [1349, 1106, 20]], 'source_required': 1348, 'destination_required': 723}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 64, 'source_slice_pitch': 704, 'skip_bytes': 836, 'source_origin': 857, 'row_bytes': 24, 'source_rows': [857, 921], 'destination_rows': [403, 486], 'transfers': [[857, 403, 24], [921, 486, 24]], 'source_required': 924, 'destination_required': 107}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 68, 'source_slice_pitch': 816, 'skip_bytes': 960, 'source_origin': 981, 'row_bytes': 28, 'source_rows': [981, 1049, 1117, 1797, 1865, 1933], 'destination_rows': [403, 486, 569, 1106, 1189, 1272], 'transfers': [[981, 403, 28], [1049, 486, 28], [1117, 569, 28], [1797, 1106, 28], [1865, 1189, 28], [1933, 1272, 28]], 'source_required': 1940, 'destination_required': 897})], 4: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 60, 'source_slice_pitch': 420, 'skip_bytes': 545, 'source_origin': 573, 'row_bytes': 10, 'source_rows': [573], 'destination_rows': [404], 'transfers': [[573, 404, 10]], 'source_required': 555, 'destination_required': 10}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 65, 'source_slice_pitch': 520, 'skip_bytes': 660, 'source_origin': 688, 'row_bytes': 15, 'source_rows': [688, 753, 1208, 1273], 'destination_rows': [404, 488, 1108, 1192], 'transfers': [[688, 404, 15], [753, 488, 15], [1208, 1108, 15], [1273, 1192, 15]], 'source_required': 1260, 'destination_required': 803}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 70, 'source_slice_pitch': 630, 'skip_bytes': 775, 'source_origin': 803, 'row_bytes': 20, 'source_rows': [803, 873, 943], 'destination_rows': [404, 488, 572], 'transfers': [[803, 404, 20], [873, 488, 20], [943, 572, 20]], 'source_required': 935, 'destination_required': 188}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 75, 'source_slice_pitch': 750, 'skip_bytes': 910, 'source_origin': 938, 'row_bytes': 25, 'source_rows': [938, 1688], 'destination_rows': [404, 1108], 'transfers': [[938, 404, 25], [1688, 1108, 25]], 'source_required': 1685, 'destination_required': 729}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 80, 'source_slice_pitch': 880, 'skip_bytes': 1045, 'source_origin': 1073, 'row_bytes': 30, 'source_rows': [1073, 1153], 'destination_rows': [404, 488], 'transfers': [[1073, 404, 30], [1153, 488, 30]], 'source_required': 1155, 'destination_required': 114}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 85, 'source_slice_pitch': 1020, 'skip_bytes': 1200, 'source_origin': 1228, 'row_bytes': 35, 'source_rows': [1228, 1313, 1398, 2248, 2333, 2418], 'destination_rows': [404, 488, 572, 1108, 1192, 1276], 'transfers': [[1228, 404, 35], [1313, 488, 35], [1398, 572, 35], [2248, 1108, 35], [2333, 1192, 35], [2418, 1276, 35]], 'source_required': 2425, 'destination_required': 907})], 5: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 72, 'source_slice_pitch': 504, 'skip_bytes': 654, 'source_origin': 689, 'row_bytes': 12, 'source_rows': [689], 'destination_rows': [405], 'transfers': [[689, 405, 12]], 'source_required': 666, 'destination_required': 12}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 78, 'source_slice_pitch': 624, 'skip_bytes': 792, 'source_origin': 827, 'row_bytes': 18, 'source_rows': [827, 905, 1451, 1529], 'destination_rows': [405, 490, 1110, 1195], 'transfers': [[827, 405, 18], [905, 490, 18], [1451, 1110, 18], [1529, 1195, 18]], 'source_required': 1512, 'destination_required': 808}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 84, 'source_slice_pitch': 756, 'skip_bytes': 930, 'source_origin': 965, 'row_bytes': 24, 'source_rows': [965, 1049, 1133], 'destination_rows': [405, 490, 575], 'transfers': [[965, 405, 24], [1049, 490, 24], [1133, 575, 24]], 'source_required': 1122, 'destination_required': 194}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 90, 'source_slice_pitch': 900, 'skip_bytes': 1092, 'source_origin': 1127, 'row_bytes': 30, 'source_rows': [1127, 2027], 'destination_rows': [405, 1110], 'transfers': [[1127, 405, 30], [2027, 1110, 30]], 'source_required': 2022, 'destination_required': 735}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 96, 'source_slice_pitch': 1056, 'skip_bytes': 1254, 'source_origin': 1289, 'row_bytes': 36, 'source_rows': [1289, 1385], 'destination_rows': [405, 490], 'transfers': [[1289, 405, 36], [1385, 490, 36]], 'source_required': 1386, 'destination_required': 121}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 102, 'source_slice_pitch': 1224, 'skip_bytes': 1440, 'source_origin': 1475, 'row_bytes': 42, 'source_rows': [1475, 1577, 1679, 2699, 2801, 2903], 'destination_rows': [405, 490, 575, 1110, 1195, 1280], 'transfers': [[1475, 405, 42], [1577, 490, 42], [1679, 575, 42], [2699, 1110, 42], [2801, 1195, 42], [2903, 1280, 42]], 'source_required': 2910, 'destination_required': 917})]}
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)
    source_row_pitch = p["row_length"]
    source_slice_pitch = source_row_pitch*p["image_height"]
    skip_bytes = p["skip_z"]*source_slice_pitch+p["skip_y"]*source_row_pitch+p["skip_x"]*p["b"]
    source_origin = p["src"]+skip_bytes
    row_bytes = p["width"]*p["b"]
    source_rows = [source_origin+z*source_slice_pitch+y*source_row_pitch for z in range(p["depth"]) for y in range(p["height"])]
    destination_rows = [p["dst"]+z*p["ds"]+y*p["dp"] for z in range(p["depth"]) for y in range(p["height"])]
    transfers = [[s,d,row_bytes] for s,d in zip(source_rows,destination_rows)]
    source_required = source_rows[-1]+row_bytes-p["src"]
    destination_required = destination_rows[-1]+row_bytes-p["dst"]
    return {'source_row_pitch': source_row_pitch, 'source_slice_pitch': source_slice_pitch, 'skip_bytes': skip_bytes, 'source_origin': source_origin, 'row_bytes': row_bytes, 'source_rows': source_rows, 'destination_rows': destination_rows, 'transfers': transfers, 'source_required': source_required, 'destination_required': destination_required}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 24, 'source_slice_pitch': 168, 'skip_bytes': 218, 'source_origin': 225, 'row_bytes': 4, 'source_rows': [225], 'destination_rows': [401], 'transfers': [[225, 401, 4]], 'source_required': 222, 'destination_required': 4}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 26, 'source_slice_pitch': 208, 'skip_bytes': 264, 'source_origin': 271, 'row_bytes': 6, 'source_rows': [271, 297, 479, 505], 'destination_rows': [401, 482, 1102, 1183], 'transfers': [[271, 401, 6], [297, 482, 6], [479, 1102, 6], [505, 1183, 6]], 'source_required': 504, 'destination_required': 788}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 28, 'source_slice_pitch': 252, 'skip_bytes': 310, 'source_origin': 317, 'row_bytes': 8, 'source_rows': [317, 345, 373], 'destination_rows': [401, 482, 563], 'transfers': [[317, 401, 8], [345, 482, 8], [373, 563, 8]], 'source_required': 374, 'destination_required': 170}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 30, 'source_slice_pitch': 300, 'skip_bytes': 364, 'source_origin': 371, 'row_bytes': 10, 'source_rows': [371, 671], 'destination_rows': [401, 1102], 'transfers': [[371, 401, 10], [671, 1102, 10]], 'source_required': 674, 'destination_required': 711}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 32, 'source_slice_pitch': 352, 'skip_bytes': 418, 'source_origin': 425, 'row_bytes': 12, 'source_rows': [425, 457], 'destination_rows': [401, 482], 'transfers': [[425, 401, 12], [457, 482, 12]], 'source_required': 462, 'destination_required': 93}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 34, 'source_slice_pitch': 408, 'skip_bytes': 480, 'source_origin': 487, 'row_bytes': 14, 'source_rows': [487, 521, 555, 895, 929, 963], 'destination_rows': [401, 482, 563, 1102, 1183, 1264], 'transfers': [[487, 401, 14], [521, 482, 14], [555, 563, 14], [895, 1102, 14], [929, 1183, 14], [963, 1264, 14]], 'source_required': 970, 'destination_required': 877})], 2: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 36, 'source_slice_pitch': 252, 'skip_bytes': 327, 'source_origin': 341, 'row_bytes': 6, 'source_rows': [341], 'destination_rows': [402], 'transfers': [[341, 402, 6]], 'source_required': 333, 'destination_required': 6}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 39, 'source_slice_pitch': 312, 'skip_bytes': 396, 'source_origin': 410, 'row_bytes': 9, 'source_rows': [410, 449, 722, 761], 'destination_rows': [402, 484, 1104, 1186], 'transfers': [[410, 402, 9], [449, 484, 9], [722, 1104, 9], [761, 1186, 9]], 'source_required': 756, 'destination_required': 793}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 42, 'source_slice_pitch': 378, 'skip_bytes': 465, 'source_origin': 479, 'row_bytes': 12, 'source_rows': [479, 521, 563], 'destination_rows': [402, 484, 566], 'transfers': [[479, 402, 12], [521, 484, 12], [563, 566, 12]], 'source_required': 561, 'destination_required': 176}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 45, 'source_slice_pitch': 450, 'skip_bytes': 546, 'source_origin': 560, 'row_bytes': 15, 'source_rows': [560, 1010], 'destination_rows': [402, 1104], 'transfers': [[560, 402, 15], [1010, 1104, 15]], 'source_required': 1011, 'destination_required': 717}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 48, 'source_slice_pitch': 528, 'skip_bytes': 627, 'source_origin': 641, 'row_bytes': 18, 'source_rows': [641, 689], 'destination_rows': [402, 484], 'transfers': [[641, 402, 18], [689, 484, 18]], 'source_required': 693, 'destination_required': 100}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 51, 'source_slice_pitch': 612, 'skip_bytes': 720, 'source_origin': 734, 'row_bytes': 21, 'source_rows': [734, 785, 836, 1346, 1397, 1448], 'destination_rows': [402, 484, 566, 1104, 1186, 1268], 'transfers': [[734, 402, 21], [785, 484, 21], [836, 566, 21], [1346, 1104, 21], [1397, 1186, 21], [1448, 1268, 21]], 'source_required': 1455, 'destination_required': 887})], 3: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 48, 'source_slice_pitch': 336, 'skip_bytes': 436, 'source_origin': 457, 'row_bytes': 8, 'source_rows': [457], 'destination_rows': [403], 'transfers': [[457, 403, 8]], 'source_required': 444, 'destination_required': 8}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 52, 'source_slice_pitch': 416, 'skip_bytes': 528, 'source_origin': 549, 'row_bytes': 12, 'source_rows': [549, 601, 965, 1017], 'destination_rows': [403, 486, 1106, 1189], 'transfers': [[549, 403, 12], [601, 486, 12], [965, 1106, 12], [1017, 1189, 12]], 'source_required': 1008, 'destination_required': 798}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 56, 'source_slice_pitch': 504, 'skip_bytes': 620, 'source_origin': 641, 'row_bytes': 16, 'source_rows': [641, 697, 753], 'destination_rows': [403, 486, 569], 'transfers': [[641, 403, 16], [697, 486, 16], [753, 569, 16]], 'source_required': 748, 'destination_required': 182}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 60, 'source_slice_pitch': 600, 'skip_bytes': 728, 'source_origin': 749, 'row_bytes': 20, 'source_rows': [749, 1349], 'destination_rows': [403, 1106], 'transfers': [[749, 403, 20], [1349, 1106, 20]], 'source_required': 1348, 'destination_required': 723}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 64, 'source_slice_pitch': 704, 'skip_bytes': 836, 'source_origin': 857, 'row_bytes': 24, 'source_rows': [857, 921], 'destination_rows': [403, 486], 'transfers': [[857, 403, 24], [921, 486, 24]], 'source_required': 924, 'destination_required': 107}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 68, 'source_slice_pitch': 816, 'skip_bytes': 960, 'source_origin': 981, 'row_bytes': 28, 'source_rows': [981, 1049, 1117, 1797, 1865, 1933], 'destination_rows': [403, 486, 569, 1106, 1189, 1272], 'transfers': [[981, 403, 28], [1049, 486, 28], [1117, 569, 28], [1797, 1106, 28], [1865, 1189, 28], [1933, 1272, 28]], 'source_required': 1940, 'destination_required': 897})], 4: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 60, 'source_slice_pitch': 420, 'skip_bytes': 545, 'source_origin': 573, 'row_bytes': 10, 'source_rows': [573], 'destination_rows': [404], 'transfers': [[573, 404, 10]], 'source_required': 555, 'destination_required': 10}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 65, 'source_slice_pitch': 520, 'skip_bytes': 660, 'source_origin': 688, 'row_bytes': 15, 'source_rows': [688, 753, 1208, 1273], 'destination_rows': [404, 488, 1108, 1192], 'transfers': [[688, 404, 15], [753, 488, 15], [1208, 1108, 15], [1273, 1192, 15]], 'source_required': 1260, 'destination_required': 803}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 70, 'source_slice_pitch': 630, 'skip_bytes': 775, 'source_origin': 803, 'row_bytes': 20, 'source_rows': [803, 873, 943], 'destination_rows': [404, 488, 572], 'transfers': [[803, 404, 20], [873, 488, 20], [943, 572, 20]], 'source_required': 935, 'destination_required': 188}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 75, 'source_slice_pitch': 750, 'skip_bytes': 910, 'source_origin': 938, 'row_bytes': 25, 'source_rows': [938, 1688], 'destination_rows': [404, 1108], 'transfers': [[938, 404, 25], [1688, 1108, 25]], 'source_required': 1685, 'destination_required': 729}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 80, 'source_slice_pitch': 880, 'skip_bytes': 1045, 'source_origin': 1073, 'row_bytes': 30, 'source_rows': [1073, 1153], 'destination_rows': [404, 488], 'transfers': [[1073, 404, 30], [1153, 488, 30]], 'source_required': 1155, 'destination_required': 114}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 85, 'source_slice_pitch': 1020, 'skip_bytes': 1200, 'source_origin': 1228, 'row_bytes': 35, 'source_rows': [1228, 1313, 1398, 2248, 2333, 2418], 'destination_rows': [404, 488, 572, 1108, 1192, 1276], 'transfers': [[1228, 404, 35], [1313, 488, 35], [1398, 572, 35], [2248, 1108, 35], [2333, 1192, 35], [2418, 1276, 35]], 'source_required': 2425, 'destination_required': 907})], 5: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 72, 'source_slice_pitch': 504, 'skip_bytes': 654, 'source_origin': 689, 'row_bytes': 12, 'source_rows': [689], 'destination_rows': [405], 'transfers': [[689, 405, 12]], 'source_required': 666, 'destination_required': 12}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 78, 'source_slice_pitch': 624, 'skip_bytes': 792, 'source_origin': 827, 'row_bytes': 18, 'source_rows': [827, 905, 1451, 1529], 'destination_rows': [405, 490, 1110, 1195], 'transfers': [[827, 405, 18], [905, 490, 18], [1451, 1110, 18], [1529, 1195, 18]], 'source_required': 1512, 'destination_required': 808}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 84, 'source_slice_pitch': 756, 'skip_bytes': 930, 'source_origin': 965, 'row_bytes': 24, 'source_rows': [965, 1049, 1133], 'destination_rows': [405, 490, 575], 'transfers': [[965, 405, 24], [1049, 490, 24], [1133, 575, 24]], 'source_required': 1122, 'destination_required': 194}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 90, 'source_slice_pitch': 900, 'skip_bytes': 1092, 'source_origin': 1127, 'row_bytes': 30, 'source_rows': [1127, 2027], 'destination_rows': [405, 1110], 'transfers': [[1127, 405, 30], [2027, 1110, 30]], 'source_required': 2022, 'destination_required': 735}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 96, 'source_slice_pitch': 1056, 'skip_bytes': 1254, 'source_origin': 1289, 'row_bytes': 36, 'source_rows': [1289, 1385], 'destination_rows': [405, 490], 'transfers': [[1289, 405, 36], [1385, 490, 36]], 'source_required': 1386, 'destination_required': 121}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 102, 'source_slice_pitch': 1224, 'skip_bytes': 1440, 'source_origin': 1475, 'row_bytes': 42, 'source_rows': [1475, 1577, 1679, 2699, 2801, 2903], 'destination_rows': [405, 490, 575, 1110, 1195, 1280], 'transfers': [[1475, 405, 42], [1577, 490, 42], [1679, 575, 42], [2699, 1110, 42], [2801, 1195, 42], [2903, 1280, 42]], 'source_required': 2910, 'destination_required': 917})]}
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 source_row_pitch.

A 3D upload buffer has independently specified row length, image height, and byte pixel size. A valid subvolume starts after skipped images, rows, and pixels. Destination uses independent row and slice pitches; return all per-row transfer origins. 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)
    source_row_pitch = p["row_length"]*p["b"]
    source_slice_pitch = source_row_pitch*p["height"]
    skip_bytes = p["skip_z"]*source_slice_pitch+p["skip_y"]*source_row_pitch+p["skip_x"]*p["b"]
    source_origin = p["src"]+skip_bytes
    row_bytes = p["width"]*p["b"]
    source_rows = [source_origin+z*source_slice_pitch+y*source_row_pitch for z in range(p["depth"]) for y in range(p["height"])]
    destination_rows = [p["dst"]+z*p["ds"]+y*p["dp"] for z in range(p["depth"]) for y in range(p["height"])]
    transfers = [[s,d,row_bytes] for s,d in zip(source_rows,destination_rows)]
    source_required = source_rows[-1]+row_bytes-p["src"]
    destination_required = destination_rows[-1]+row_bytes-p["dst"]
    return {'source_row_pitch': source_row_pitch, 'source_slice_pitch': source_slice_pitch, 'skip_bytes': skip_bytes, 'source_origin': source_origin, 'row_bytes': row_bytes, 'source_rows': source_rows, 'destination_rows': destination_rows, 'transfers': transfers, 'source_required': source_required, 'destination_required': destination_required}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 24, 'source_slice_pitch': 168, 'skip_bytes': 218, 'source_origin': 225, 'row_bytes': 4, 'source_rows': [225], 'destination_rows': [401], 'transfers': [[225, 401, 4]], 'source_required': 222, 'destination_required': 4}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 26, 'source_slice_pitch': 208, 'skip_bytes': 264, 'source_origin': 271, 'row_bytes': 6, 'source_rows': [271, 297, 479, 505], 'destination_rows': [401, 482, 1102, 1183], 'transfers': [[271, 401, 6], [297, 482, 6], [479, 1102, 6], [505, 1183, 6]], 'source_required': 504, 'destination_required': 788}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 28, 'source_slice_pitch': 252, 'skip_bytes': 310, 'source_origin': 317, 'row_bytes': 8, 'source_rows': [317, 345, 373], 'destination_rows': [401, 482, 563], 'transfers': [[317, 401, 8], [345, 482, 8], [373, 563, 8]], 'source_required': 374, 'destination_required': 170}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 30, 'source_slice_pitch': 300, 'skip_bytes': 364, 'source_origin': 371, 'row_bytes': 10, 'source_rows': [371, 671], 'destination_rows': [401, 1102], 'transfers': [[371, 401, 10], [671, 1102, 10]], 'source_required': 674, 'destination_required': 711}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 32, 'source_slice_pitch': 352, 'skip_bytes': 418, 'source_origin': 425, 'row_bytes': 12, 'source_rows': [425, 457], 'destination_rows': [401, 482], 'transfers': [[425, 401, 12], [457, 482, 12]], 'source_required': 462, 'destination_required': 93}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 34, 'source_slice_pitch': 408, 'skip_bytes': 480, 'source_origin': 487, 'row_bytes': 14, 'source_rows': [487, 521, 555, 895, 929, 963], 'destination_rows': [401, 482, 563, 1102, 1183, 1264], 'transfers': [[487, 401, 14], [521, 482, 14], [555, 563, 14], [895, 1102, 14], [929, 1183, 14], [963, 1264, 14]], 'source_required': 970, 'destination_required': 877})], 2: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 36, 'source_slice_pitch': 252, 'skip_bytes': 327, 'source_origin': 341, 'row_bytes': 6, 'source_rows': [341], 'destination_rows': [402], 'transfers': [[341, 402, 6]], 'source_required': 333, 'destination_required': 6}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 39, 'source_slice_pitch': 312, 'skip_bytes': 396, 'source_origin': 410, 'row_bytes': 9, 'source_rows': [410, 449, 722, 761], 'destination_rows': [402, 484, 1104, 1186], 'transfers': [[410, 402, 9], [449, 484, 9], [722, 1104, 9], [761, 1186, 9]], 'source_required': 756, 'destination_required': 793}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 42, 'source_slice_pitch': 378, 'skip_bytes': 465, 'source_origin': 479, 'row_bytes': 12, 'source_rows': [479, 521, 563], 'destination_rows': [402, 484, 566], 'transfers': [[479, 402, 12], [521, 484, 12], [563, 566, 12]], 'source_required': 561, 'destination_required': 176}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 45, 'source_slice_pitch': 450, 'skip_bytes': 546, 'source_origin': 560, 'row_bytes': 15, 'source_rows': [560, 1010], 'destination_rows': [402, 1104], 'transfers': [[560, 402, 15], [1010, 1104, 15]], 'source_required': 1011, 'destination_required': 717}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 48, 'source_slice_pitch': 528, 'skip_bytes': 627, 'source_origin': 641, 'row_bytes': 18, 'source_rows': [641, 689], 'destination_rows': [402, 484], 'transfers': [[641, 402, 18], [689, 484, 18]], 'source_required': 693, 'destination_required': 100}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 51, 'source_slice_pitch': 612, 'skip_bytes': 720, 'source_origin': 734, 'row_bytes': 21, 'source_rows': [734, 785, 836, 1346, 1397, 1448], 'destination_rows': [402, 484, 566, 1104, 1186, 1268], 'transfers': [[734, 402, 21], [785, 484, 21], [836, 566, 21], [1346, 1104, 21], [1397, 1186, 21], [1448, 1268, 21]], 'source_required': 1455, 'destination_required': 887})], 3: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 48, 'source_slice_pitch': 336, 'skip_bytes': 436, 'source_origin': 457, 'row_bytes': 8, 'source_rows': [457], 'destination_rows': [403], 'transfers': [[457, 403, 8]], 'source_required': 444, 'destination_required': 8}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 52, 'source_slice_pitch': 416, 'skip_bytes': 528, 'source_origin': 549, 'row_bytes': 12, 'source_rows': [549, 601, 965, 1017], 'destination_rows': [403, 486, 1106, 1189], 'transfers': [[549, 403, 12], [601, 486, 12], [965, 1106, 12], [1017, 1189, 12]], 'source_required': 1008, 'destination_required': 798}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 56, 'source_slice_pitch': 504, 'skip_bytes': 620, 'source_origin': 641, 'row_bytes': 16, 'source_rows': [641, 697, 753], 'destination_rows': [403, 486, 569], 'transfers': [[641, 403, 16], [697, 486, 16], [753, 569, 16]], 'source_required': 748, 'destination_required': 182}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 60, 'source_slice_pitch': 600, 'skip_bytes': 728, 'source_origin': 749, 'row_bytes': 20, 'source_rows': [749, 1349], 'destination_rows': [403, 1106], 'transfers': [[749, 403, 20], [1349, 1106, 20]], 'source_required': 1348, 'destination_required': 723}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 64, 'source_slice_pitch': 704, 'skip_bytes': 836, 'source_origin': 857, 'row_bytes': 24, 'source_rows': [857, 921], 'destination_rows': [403, 486], 'transfers': [[857, 403, 24], [921, 486, 24]], 'source_required': 924, 'destination_required': 107}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 68, 'source_slice_pitch': 816, 'skip_bytes': 960, 'source_origin': 981, 'row_bytes': 28, 'source_rows': [981, 1049, 1117, 1797, 1865, 1933], 'destination_rows': [403, 486, 569, 1106, 1189, 1272], 'transfers': [[981, 403, 28], [1049, 486, 28], [1117, 569, 28], [1797, 1106, 28], [1865, 1189, 28], [1933, 1272, 28]], 'source_required': 1940, 'destination_required': 897})], 4: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 60, 'source_slice_pitch': 420, 'skip_bytes': 545, 'source_origin': 573, 'row_bytes': 10, 'source_rows': [573], 'destination_rows': [404], 'transfers': [[573, 404, 10]], 'source_required': 555, 'destination_required': 10}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 65, 'source_slice_pitch': 520, 'skip_bytes': 660, 'source_origin': 688, 'row_bytes': 15, 'source_rows': [688, 753, 1208, 1273], 'destination_rows': [404, 488, 1108, 1192], 'transfers': [[688, 404, 15], [753, 488, 15], [1208, 1108, 15], [1273, 1192, 15]], 'source_required': 1260, 'destination_required': 803}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 70, 'source_slice_pitch': 630, 'skip_bytes': 775, 'source_origin': 803, 'row_bytes': 20, 'source_rows': [803, 873, 943], 'destination_rows': [404, 488, 572], 'transfers': [[803, 404, 20], [873, 488, 20], [943, 572, 20]], 'source_required': 935, 'destination_required': 188}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 75, 'source_slice_pitch': 750, 'skip_bytes': 910, 'source_origin': 938, 'row_bytes': 25, 'source_rows': [938, 1688], 'destination_rows': [404, 1108], 'transfers': [[938, 404, 25], [1688, 1108, 25]], 'source_required': 1685, 'destination_required': 729}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 80, 'source_slice_pitch': 880, 'skip_bytes': 1045, 'source_origin': 1073, 'row_bytes': 30, 'source_rows': [1073, 1153], 'destination_rows': [404, 488], 'transfers': [[1073, 404, 30], [1153, 488, 30]], 'source_required': 1155, 'destination_required': 114}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 85, 'source_slice_pitch': 1020, 'skip_bytes': 1200, 'source_origin': 1228, 'row_bytes': 35, 'source_rows': [1228, 1313, 1398, 2248, 2333, 2418], 'destination_rows': [404, 488, 572, 1108, 1192, 1276], 'transfers': [[1228, 404, 35], [1313, 488, 35], [1398, 572, 35], [2248, 1108, 35], [2333, 1192, 35], [2418, 1276, 35]], 'source_required': 2425, 'destination_required': 907})], 5: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 72, 'source_slice_pitch': 504, 'skip_bytes': 654, 'source_origin': 689, 'row_bytes': 12, 'source_rows': [689], 'destination_rows': [405], 'transfers': [[689, 405, 12]], 'source_required': 666, 'destination_required': 12}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 78, 'source_slice_pitch': 624, 'skip_bytes': 792, 'source_origin': 827, 'row_bytes': 18, 'source_rows': [827, 905, 1451, 1529], 'destination_rows': [405, 490, 1110, 1195], 'transfers': [[827, 405, 18], [905, 490, 18], [1451, 1110, 18], [1529, 1195, 18]], 'source_required': 1512, 'destination_required': 808}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 84, 'source_slice_pitch': 756, 'skip_bytes': 930, 'source_origin': 965, 'row_bytes': 24, 'source_rows': [965, 1049, 1133], 'destination_rows': [405, 490, 575], 'transfers': [[965, 405, 24], [1049, 490, 24], [1133, 575, 24]], 'source_required': 1122, 'destination_required': 194}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 90, 'source_slice_pitch': 900, 'skip_bytes': 1092, 'source_origin': 1127, 'row_bytes': 30, 'source_rows': [1127, 2027], 'destination_rows': [405, 1110], 'transfers': [[1127, 405, 30], [2027, 1110, 30]], 'source_required': 2022, 'destination_required': 735}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 96, 'source_slice_pitch': 1056, 'skip_bytes': 1254, 'source_origin': 1289, 'row_bytes': 36, 'source_rows': [1289, 1385], 'destination_rows': [405, 490], 'transfers': [[1289, 405, 36], [1385, 490, 36]], 'source_required': 1386, 'destination_required': 121}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 102, 'source_slice_pitch': 1224, 'skip_bytes': 1440, 'source_origin': 1475, 'row_bytes': 42, 'source_rows': [1475, 1577, 1679, 2699, 2801, 2903], 'destination_rows': [405, 490, 575, 1110, 1195, 1280], 'transfers': [[1475, 405, 42], [1577, 490, 42], [1679, 575, 42], [2699, 1110, 42], [2801, 1195, 42], [2903, 1280, 42]], 'source_required': 2910, 'destination_required': 917})]}
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)
    source_row_pitch = p["row_length"]*p["b"]
    source_slice_pitch = source_row_pitch
    skip_bytes = p["skip_z"]*source_slice_pitch+p["skip_y"]*source_row_pitch+p["skip_x"]*p["b"]
    source_origin = p["src"]+skip_bytes
    row_bytes = p["width"]*p["b"]
    source_rows = [source_origin+z*source_slice_pitch+y*source_row_pitch for z in range(p["depth"]) for y in range(p["height"])]
    destination_rows = [p["dst"]+z*p["ds"]+y*p["dp"] for z in range(p["depth"]) for y in range(p["height"])]
    transfers = [[s,d,row_bytes] for s,d in zip(source_rows,destination_rows)]
    source_required = source_rows[-1]+row_bytes-p["src"]
    destination_required = destination_rows[-1]+row_bytes-p["dst"]
    return {'source_row_pitch': source_row_pitch, 'source_slice_pitch': source_slice_pitch, 'skip_bytes': skip_bytes, 'source_origin': source_origin, 'row_bytes': row_bytes, 'source_rows': source_rows, 'destination_rows': destination_rows, 'transfers': transfers, 'source_required': source_required, 'destination_required': destination_required}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 24, 'source_slice_pitch': 168, 'skip_bytes': 218, 'source_origin': 225, 'row_bytes': 4, 'source_rows': [225], 'destination_rows': [401], 'transfers': [[225, 401, 4]], 'source_required': 222, 'destination_required': 4}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 26, 'source_slice_pitch': 208, 'skip_bytes': 264, 'source_origin': 271, 'row_bytes': 6, 'source_rows': [271, 297, 479, 505], 'destination_rows': [401, 482, 1102, 1183], 'transfers': [[271, 401, 6], [297, 482, 6], [479, 1102, 6], [505, 1183, 6]], 'source_required': 504, 'destination_required': 788}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 28, 'source_slice_pitch': 252, 'skip_bytes': 310, 'source_origin': 317, 'row_bytes': 8, 'source_rows': [317, 345, 373], 'destination_rows': [401, 482, 563], 'transfers': [[317, 401, 8], [345, 482, 8], [373, 563, 8]], 'source_required': 374, 'destination_required': 170}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 30, 'source_slice_pitch': 300, 'skip_bytes': 364, 'source_origin': 371, 'row_bytes': 10, 'source_rows': [371, 671], 'destination_rows': [401, 1102], 'transfers': [[371, 401, 10], [671, 1102, 10]], 'source_required': 674, 'destination_required': 711}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 2, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 32, 'source_slice_pitch': 352, 'skip_bytes': 418, 'source_origin': 425, 'row_bytes': 12, 'source_rows': [425, 457], 'destination_rows': [401, 482], 'transfers': [[425, 401, 12], [457, 482, 12]], 'source_required': 462, 'destination_required': 93}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 2, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 7, 'dst': 401, 'dp': 81, 'ds': 701}, {'source_row_pitch': 34, 'source_slice_pitch': 408, 'skip_bytes': 480, 'source_origin': 487, 'row_bytes': 14, 'source_rows': [487, 521, 555, 895, 929, 963], 'destination_rows': [401, 482, 563, 1102, 1183, 1264], 'transfers': [[487, 401, 14], [521, 482, 14], [555, 563, 14], [895, 1102, 14], [929, 1183, 14], [963, 1264, 14]], 'source_required': 970, 'destination_required': 877})], 2: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 36, 'source_slice_pitch': 252, 'skip_bytes': 327, 'source_origin': 341, 'row_bytes': 6, 'source_rows': [341], 'destination_rows': [402], 'transfers': [[341, 402, 6]], 'source_required': 333, 'destination_required': 6}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 39, 'source_slice_pitch': 312, 'skip_bytes': 396, 'source_origin': 410, 'row_bytes': 9, 'source_rows': [410, 449, 722, 761], 'destination_rows': [402, 484, 1104, 1186], 'transfers': [[410, 402, 9], [449, 484, 9], [722, 1104, 9], [761, 1186, 9]], 'source_required': 756, 'destination_required': 793}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 42, 'source_slice_pitch': 378, 'skip_bytes': 465, 'source_origin': 479, 'row_bytes': 12, 'source_rows': [479, 521, 563], 'destination_rows': [402, 484, 566], 'transfers': [[479, 402, 12], [521, 484, 12], [563, 566, 12]], 'source_required': 561, 'destination_required': 176}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 45, 'source_slice_pitch': 450, 'skip_bytes': 546, 'source_origin': 560, 'row_bytes': 15, 'source_rows': [560, 1010], 'destination_rows': [402, 1104], 'transfers': [[560, 402, 15], [1010, 1104, 15]], 'source_required': 1011, 'destination_required': 717}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 3, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 48, 'source_slice_pitch': 528, 'skip_bytes': 627, 'source_origin': 641, 'row_bytes': 18, 'source_rows': [641, 689], 'destination_rows': [402, 484], 'transfers': [[641, 402, 18], [689, 484, 18]], 'source_required': 693, 'destination_required': 100}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 3, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 14, 'dst': 402, 'dp': 82, 'ds': 702}, {'source_row_pitch': 51, 'source_slice_pitch': 612, 'skip_bytes': 720, 'source_origin': 734, 'row_bytes': 21, 'source_rows': [734, 785, 836, 1346, 1397, 1448], 'destination_rows': [402, 484, 566, 1104, 1186, 1268], 'transfers': [[734, 402, 21], [785, 484, 21], [836, 566, 21], [1346, 1104, 21], [1397, 1186, 21], [1448, 1268, 21]], 'source_required': 1455, 'destination_required': 887})], 3: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 48, 'source_slice_pitch': 336, 'skip_bytes': 436, 'source_origin': 457, 'row_bytes': 8, 'source_rows': [457], 'destination_rows': [403], 'transfers': [[457, 403, 8]], 'source_required': 444, 'destination_required': 8}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 52, 'source_slice_pitch': 416, 'skip_bytes': 528, 'source_origin': 549, 'row_bytes': 12, 'source_rows': [549, 601, 965, 1017], 'destination_rows': [403, 486, 1106, 1189], 'transfers': [[549, 403, 12], [601, 486, 12], [965, 1106, 12], [1017, 1189, 12]], 'source_required': 1008, 'destination_required': 798}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 56, 'source_slice_pitch': 504, 'skip_bytes': 620, 'source_origin': 641, 'row_bytes': 16, 'source_rows': [641, 697, 753], 'destination_rows': [403, 486, 569], 'transfers': [[641, 403, 16], [697, 486, 16], [753, 569, 16]], 'source_required': 748, 'destination_required': 182}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 60, 'source_slice_pitch': 600, 'skip_bytes': 728, 'source_origin': 749, 'row_bytes': 20, 'source_rows': [749, 1349], 'destination_rows': [403, 1106], 'transfers': [[749, 403, 20], [1349, 1106, 20]], 'source_required': 1348, 'destination_required': 723}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 4, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 64, 'source_slice_pitch': 704, 'skip_bytes': 836, 'source_origin': 857, 'row_bytes': 24, 'source_rows': [857, 921], 'destination_rows': [403, 486], 'transfers': [[857, 403, 24], [921, 486, 24]], 'source_required': 924, 'destination_required': 107}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 4, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 21, 'dst': 403, 'dp': 83, 'ds': 703}, {'source_row_pitch': 68, 'source_slice_pitch': 816, 'skip_bytes': 960, 'source_origin': 981, 'row_bytes': 28, 'source_rows': [981, 1049, 1117, 1797, 1865, 1933], 'destination_rows': [403, 486, 569, 1106, 1189, 1272], 'transfers': [[981, 403, 28], [1049, 486, 28], [1117, 569, 28], [1797, 1106, 28], [1865, 1189, 28], [1933, 1272, 28]], 'source_required': 1940, 'destination_required': 897})], 4: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 60, 'source_slice_pitch': 420, 'skip_bytes': 545, 'source_origin': 573, 'row_bytes': 10, 'source_rows': [573], 'destination_rows': [404], 'transfers': [[573, 404, 10]], 'source_required': 555, 'destination_required': 10}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 65, 'source_slice_pitch': 520, 'skip_bytes': 660, 'source_origin': 688, 'row_bytes': 15, 'source_rows': [688, 753, 1208, 1273], 'destination_rows': [404, 488, 1108, 1192], 'transfers': [[688, 404, 15], [753, 488, 15], [1208, 1108, 15], [1273, 1192, 15]], 'source_required': 1260, 'destination_required': 803}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 70, 'source_slice_pitch': 630, 'skip_bytes': 775, 'source_origin': 803, 'row_bytes': 20, 'source_rows': [803, 873, 943], 'destination_rows': [404, 488, 572], 'transfers': [[803, 404, 20], [873, 488, 20], [943, 572, 20]], 'source_required': 935, 'destination_required': 188}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 75, 'source_slice_pitch': 750, 'skip_bytes': 910, 'source_origin': 938, 'row_bytes': 25, 'source_rows': [938, 1688], 'destination_rows': [404, 1108], 'transfers': [[938, 404, 25], [1688, 1108, 25]], 'source_required': 1685, 'destination_required': 729}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 5, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 80, 'source_slice_pitch': 880, 'skip_bytes': 1045, 'source_origin': 1073, 'row_bytes': 30, 'source_rows': [1073, 1153], 'destination_rows': [404, 488], 'transfers': [[1073, 404, 30], [1153, 488, 30]], 'source_required': 1155, 'destination_required': 114}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 5, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 28, 'dst': 404, 'dp': 84, 'ds': 704}, {'source_row_pitch': 85, 'source_slice_pitch': 1020, 'skip_bytes': 1200, 'source_origin': 1228, 'row_bytes': 35, 'source_rows': [1228, 1313, 1398, 2248, 2333, 2418], 'destination_rows': [404, 488, 572, 1108, 1192, 1276], 'transfers': [[1228, 404, 35], [1313, 488, 35], [1398, 572, 35], [2248, 1108, 35], [2333, 1192, 35], [2418, 1276, 35]], 'source_required': 2425, 'destination_required': 907})], 5: [({'width': 2, 'height': 1, 'depth': 1, 'row_length': 12, 'image_height': 7, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 72, 'source_slice_pitch': 504, 'skip_bytes': 654, 'source_origin': 689, 'row_bytes': 12, 'source_rows': [689], 'destination_rows': [405], 'transfers': [[689, 405, 12]], 'source_required': 666, 'destination_required': 12}), ({'width': 3, 'height': 2, 'depth': 2, 'row_length': 13, 'image_height': 8, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 78, 'source_slice_pitch': 624, 'skip_bytes': 792, 'source_origin': 827, 'row_bytes': 18, 'source_rows': [827, 905, 1451, 1529], 'destination_rows': [405, 490, 1110, 1195], 'transfers': [[827, 405, 18], [905, 490, 18], [1451, 1110, 18], [1529, 1195, 18]], 'source_required': 1512, 'destination_required': 808}), ({'width': 4, 'height': 3, 'depth': 1, 'row_length': 14, 'image_height': 9, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 84, 'source_slice_pitch': 756, 'skip_bytes': 930, 'source_origin': 965, 'row_bytes': 24, 'source_rows': [965, 1049, 1133], 'destination_rows': [405, 490, 575], 'transfers': [[965, 405, 24], [1049, 490, 24], [1133, 575, 24]], 'source_required': 1122, 'destination_required': 194}), ({'width': 5, 'height': 1, 'depth': 2, 'row_length': 15, 'image_height': 10, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 90, 'source_slice_pitch': 900, 'skip_bytes': 1092, 'source_origin': 1127, 'row_bytes': 30, 'source_rows': [1127, 2027], 'destination_rows': [405, 1110], 'transfers': [[1127, 405, 30], [2027, 1110, 30]], 'source_required': 2022, 'destination_required': 735}), ({'width': 6, 'height': 2, 'depth': 1, 'row_length': 16, 'image_height': 11, 'b': 6, 'skip_x': 1, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 96, 'source_slice_pitch': 1056, 'skip_bytes': 1254, 'source_origin': 1289, 'row_bytes': 36, 'source_rows': [1289, 1385], 'destination_rows': [405, 490], 'transfers': [[1289, 405, 36], [1385, 490, 36]], 'source_required': 1386, 'destination_required': 121}), ({'width': 7, 'height': 3, 'depth': 2, 'row_length': 17, 'image_height': 12, 'b': 6, 'skip_x': 2, 'skip_y': 2, 'skip_z': 1, 'src': 35, 'dst': 405, 'dp': 85, 'ds': 705}, {'source_row_pitch': 102, 'source_slice_pitch': 1224, 'skip_bytes': 1440, 'source_origin': 1475, 'row_bytes': 42, 'source_rows': [1475, 1577, 1679, 2699, 2801, 2903], 'destination_rows': [405, 490, 575, 1110, 1195, 1280], 'transfers': [[1475, 405, 42], [1577, 490, 42], [1679, 575, 42], [2699, 1110, 42], [2801, 1195, 42], [2903, 1280, 42]], 'source_required': 2910, 'destination_required': 917})]}
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 source_slice_pitch.

A 3D upload buffer has independently specified row length, image height, and byte pixel size. A valid subvolume starts after skipped images, rows, and pixels. Destination uses independent row and slice pitches; return all per-row transfer origins. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access