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

N = 1
observations = []
def solve(p):
    p = dict(p)
    copy_bytes = p["width"]*p["b"]
    source_start = p["src"]+p["sy"]*p["sp"]+p["sx"]*p["b"]
    destination_start = p["dst"]+p["dy"]*p["sp"]+p["dx"]*p["b"]
    sources = [source_start+i*p["sp"] for i in range(p["rows"])]
    destinations = [destination_start+i*p["dp"] for i in range(p["rows"])]
    descriptor_addresses = [p["desc"]+24*i for i in range(p["rows"])]
    next_pointers = [p["desc"]+24*(i+1) if i+1<p["rows"] else 0 for i in range(p["rows"])]
    terminal_flags = [i==p["rows"]-1 for i in range(p["rows"])]
    head = p["desc"] if p["rows"] else 0
    descriptors = [[sources[i],destinations[i],copy_bytes,next_pointers[i],terminal_flags[i]] for i in range(p["rows"])]
    return {'copy_bytes': copy_bytes, 'source_start': source_start, 'destination_start': destination_start, 'sources': sources, 'destinations': destinations, 'descriptor_addresses': descriptor_addresses, 'next_pointers': next_pointers, 'terminal_flags': terminal_flags, 'head': head, 'descriptors': descriptors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'rows': 0, 'width': 2, 'b': 2, 'src': 101, 'dst': 501, 'sp': 9, 'dp': 15, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 4, 'source_start': 121, 'destination_start': 520, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 2, 'src': 101, 'dst': 501, 'sp': 11, 'dp': 17, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 125, 'destination_start': 522, 'sources': [125], 'destinations': [522], 'descriptor_addresses': [901], 'next_pointers': [0], 'terminal_flags': [True], 'head': 901, 'descriptors': [[125, 522, 6, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 2, 'src': 101, 'dst': 501, 'sp': 13, 'dp': 19, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 129, 'destination_start': 524, 'sources': [129, 142], 'destinations': [524, 543], 'descriptor_addresses': [901, 925], 'next_pointers': [925, 0], 'terminal_flags': [False, True], 'head': 901, 'descriptors': [[129, 524, 8, 925, False], [142, 543, 8, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 2, 'src': 101, 'dst': 501, 'sp': 15, 'dp': 21, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 133, 'destination_start': 526, 'sources': [133, 148, 163], 'destinations': [526, 547, 568], 'descriptor_addresses': [901, 925, 949], 'next_pointers': [925, 949, 0], 'terminal_flags': [False, False, True], 'head': 901, 'descriptors': [[133, 526, 10, 925, False], [148, 547, 10, 949, False], [163, 568, 10, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 2, 'src': 101, 'dst': 501, 'sp': 17, 'dp': 23, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 137, 'destination_start': 528, 'sources': [137, 154, 171, 188], 'destinations': [528, 551, 574, 597], 'descriptor_addresses': [901, 925, 949, 973], 'next_pointers': [925, 949, 973, 0], 'terminal_flags': [False, False, False, True], 'head': 901, 'descriptors': [[137, 528, 12, 925, False], [154, 551, 12, 949, False], [171, 574, 12, 973, False], [188, 597, 12, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 2, 'src': 101, 'dst': 501, 'sp': 19, 'dp': 25, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 14, 'source_start': 141, 'destination_start': 530, 'sources': [141, 160, 179, 198, 217], 'destinations': [530, 555, 580, 605, 630], 'descriptor_addresses': [901, 925, 949, 973, 997], 'next_pointers': [925, 949, 973, 997, 0], 'terminal_flags': [False, False, False, False, True], 'head': 901, 'descriptors': [[141, 530, 14, 925, False], [160, 555, 14, 949, False], [179, 580, 14, 973, False], [198, 605, 14, 997, False], [217, 630, 14, 0, True]]})], 2: [({'rows': 0, 'width': 2, 'b': 3, 'src': 102, 'dst': 502, 'sp': 12, 'dp': 19, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 129, 'destination_start': 527, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 3, 'src': 102, 'dst': 502, 'sp': 15, 'dp': 22, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 9, 'source_start': 135, 'destination_start': 530, 'sources': [135], 'destinations': [530], 'descriptor_addresses': [902], 'next_pointers': [0], 'terminal_flags': [True], 'head': 902, 'descriptors': [[135, 530, 9, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 3, 'src': 102, 'dst': 502, 'sp': 18, 'dp': 25, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 141, 'destination_start': 533, 'sources': [141, 159], 'destinations': [533, 558], 'descriptor_addresses': [902, 926], 'next_pointers': [926, 0], 'terminal_flags': [False, True], 'head': 902, 'descriptors': [[141, 533, 12, 926, False], [159, 558, 12, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 3, 'src': 102, 'dst': 502, 'sp': 21, 'dp': 28, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 147, 'destination_start': 536, 'sources': [147, 168, 189], 'destinations': [536, 564, 592], 'descriptor_addresses': [902, 926, 950], 'next_pointers': [926, 950, 0], 'terminal_flags': [False, False, True], 'head': 902, 'descriptors': [[147, 536, 15, 926, False], [168, 564, 15, 950, False], [189, 592, 15, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 3, 'src': 102, 'dst': 502, 'sp': 24, 'dp': 31, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 153, 'destination_start': 539, 'sources': [153, 177, 201, 225], 'destinations': [539, 570, 601, 632], 'descriptor_addresses': [902, 926, 950, 974], 'next_pointers': [926, 950, 974, 0], 'terminal_flags': [False, False, False, True], 'head': 902, 'descriptors': [[153, 539, 18, 926, False], [177, 570, 18, 950, False], [201, 601, 18, 974, False], [225, 632, 18, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 3, 'src': 102, 'dst': 502, 'sp': 27, 'dp': 34, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 21, 'source_start': 159, 'destination_start': 542, 'sources': [159, 186, 213, 240, 267], 'destinations': [542, 576, 610, 644, 678], 'descriptor_addresses': [902, 926, 950, 974, 998], 'next_pointers': [926, 950, 974, 998, 0], 'terminal_flags': [False, False, False, False, True], 'head': 902, 'descriptors': [[159, 542, 21, 926, False], [186, 576, 21, 950, False], [213, 610, 21, 974, False], [240, 644, 21, 998, False], [267, 678, 21, 0, True]]})], 3: [({'rows': 0, 'width': 2, 'b': 4, 'src': 103, 'dst': 503, 'sp': 15, 'dp': 23, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 137, 'destination_start': 534, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 4, 'src': 103, 'dst': 503, 'sp': 19, 'dp': 27, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 145, 'destination_start': 538, 'sources': [145], 'destinations': [538], 'descriptor_addresses': [903], 'next_pointers': [0], 'terminal_flags': [True], 'head': 903, 'descriptors': [[145, 538, 12, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 4, 'src': 103, 'dst': 503, 'sp': 23, 'dp': 31, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 16, 'source_start': 153, 'destination_start': 542, 'sources': [153, 176], 'destinations': [542, 573], 'descriptor_addresses': [903, 927], 'next_pointers': [927, 0], 'terminal_flags': [False, True], 'head': 903, 'descriptors': [[153, 542, 16, 927, False], [176, 573, 16, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 4, 'src': 103, 'dst': 503, 'sp': 27, 'dp': 35, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 161, 'destination_start': 546, 'sources': [161, 188, 215], 'destinations': [546, 581, 616], 'descriptor_addresses': [903, 927, 951], 'next_pointers': [927, 951, 0], 'terminal_flags': [False, False, True], 'head': 903, 'descriptors': [[161, 546, 20, 927, False], [188, 581, 20, 951, False], [215, 616, 20, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 4, 'src': 103, 'dst': 503, 'sp': 31, 'dp': 39, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 169, 'destination_start': 550, 'sources': [169, 200, 231, 262], 'destinations': [550, 589, 628, 667], 'descriptor_addresses': [903, 927, 951, 975], 'next_pointers': [927, 951, 975, 0], 'terminal_flags': [False, False, False, True], 'head': 903, 'descriptors': [[169, 550, 24, 927, False], [200, 589, 24, 951, False], [231, 628, 24, 975, False], [262, 667, 24, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 4, 'src': 103, 'dst': 503, 'sp': 35, 'dp': 43, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 28, 'source_start': 177, 'destination_start': 554, 'sources': [177, 212, 247, 282, 317], 'destinations': [554, 597, 640, 683, 726], 'descriptor_addresses': [903, 927, 951, 975, 999], 'next_pointers': [927, 951, 975, 999, 0], 'terminal_flags': [False, False, False, False, True], 'head': 903, 'descriptors': [[177, 554, 28, 927, False], [212, 597, 28, 951, False], [247, 640, 28, 975, False], [282, 683, 28, 999, False], [317, 726, 28, 0, True]]})], 4: [({'rows': 0, 'width': 2, 'b': 5, 'src': 104, 'dst': 504, 'sp': 18, 'dp': 27, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 145, 'destination_start': 541, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 5, 'src': 104, 'dst': 504, 'sp': 23, 'dp': 32, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 155, 'destination_start': 546, 'sources': [155], 'destinations': [546], 'descriptor_addresses': [904], 'next_pointers': [0], 'terminal_flags': [True], 'head': 904, 'descriptors': [[155, 546, 15, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 5, 'src': 104, 'dst': 504, 'sp': 28, 'dp': 37, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 165, 'destination_start': 551, 'sources': [165, 193], 'destinations': [551, 588], 'descriptor_addresses': [904, 928], 'next_pointers': [928, 0], 'terminal_flags': [False, True], 'head': 904, 'descriptors': [[165, 551, 20, 928, False], [193, 588, 20, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 5, 'src': 104, 'dst': 504, 'sp': 33, 'dp': 42, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 25, 'source_start': 175, 'destination_start': 556, 'sources': [175, 208, 241], 'destinations': [556, 598, 640], 'descriptor_addresses': [904, 928, 952], 'next_pointers': [928, 952, 0], 'terminal_flags': [False, False, True], 'head': 904, 'descriptors': [[175, 556, 25, 928, False], [208, 598, 25, 952, False], [241, 640, 25, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 5, 'src': 104, 'dst': 504, 'sp': 38, 'dp': 47, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 185, 'destination_start': 561, 'sources': [185, 223, 261, 299], 'destinations': [561, 608, 655, 702], 'descriptor_addresses': [904, 928, 952, 976], 'next_pointers': [928, 952, 976, 0], 'terminal_flags': [False, False, False, True], 'head': 904, 'descriptors': [[185, 561, 30, 928, False], [223, 608, 30, 952, False], [261, 655, 30, 976, False], [299, 702, 30, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 5, 'src': 104, 'dst': 504, 'sp': 43, 'dp': 52, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 35, 'source_start': 195, 'destination_start': 566, 'sources': [195, 238, 281, 324, 367], 'destinations': [566, 618, 670, 722, 774], 'descriptor_addresses': [904, 928, 952, 976, 1000], 'next_pointers': [928, 952, 976, 1000, 0], 'terminal_flags': [False, False, False, False, True], 'head': 904, 'descriptors': [[195, 566, 35, 928, False], [238, 618, 35, 952, False], [281, 670, 35, 976, False], [324, 722, 35, 1000, False], [367, 774, 35, 0, True]]})], 5: [({'rows': 0, 'width': 2, 'b': 6, 'src': 105, 'dst': 505, 'sp': 21, 'dp': 31, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 153, 'destination_start': 548, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 6, 'src': 105, 'dst': 505, 'sp': 27, 'dp': 37, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 165, 'destination_start': 554, 'sources': [165], 'destinations': [554], 'descriptor_addresses': [905], 'next_pointers': [0], 'terminal_flags': [True], 'head': 905, 'descriptors': [[165, 554, 18, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 6, 'src': 105, 'dst': 505, 'sp': 33, 'dp': 43, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 177, 'destination_start': 560, 'sources': [177, 210], 'destinations': [560, 603], 'descriptor_addresses': [905, 929], 'next_pointers': [929, 0], 'terminal_flags': [False, True], 'head': 905, 'descriptors': [[177, 560, 24, 929, False], [210, 603, 24, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 6, 'src': 105, 'dst': 505, 'sp': 39, 'dp': 49, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 189, 'destination_start': 566, 'sources': [189, 228, 267], 'destinations': [566, 615, 664], 'descriptor_addresses': [905, 929, 953], 'next_pointers': [929, 953, 0], 'terminal_flags': [False, False, True], 'head': 905, 'descriptors': [[189, 566, 30, 929, False], [228, 615, 30, 953, False], [267, 664, 30, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 6, 'src': 105, 'dst': 505, 'sp': 45, 'dp': 55, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 36, 'source_start': 201, 'destination_start': 572, 'sources': [201, 246, 291, 336], 'destinations': [572, 627, 682, 737], 'descriptor_addresses': [905, 929, 953, 977], 'next_pointers': [929, 953, 977, 0], 'terminal_flags': [False, False, False, True], 'head': 905, 'descriptors': [[201, 572, 36, 929, False], [246, 627, 36, 953, False], [291, 682, 36, 977, False], [336, 737, 36, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 6, 'src': 105, 'dst': 505, 'sp': 51, 'dp': 61, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 42, 'source_start': 213, 'destination_start': 578, 'sources': [213, 264, 315, 366, 417], 'destinations': [578, 639, 700, 761, 822], 'descriptor_addresses': [905, 929, 953, 977, 1001], 'next_pointers': [929, 953, 977, 1001, 0], 'terminal_flags': [False, False, False, False, True], 'head': 905, 'descriptors': [[213, 578, 42, 929, False], [264, 639, 42, 953, False], [315, 700, 42, 977, False], [366, 761, 42, 1001, False], [417, 822, 42, 0, True]]})]}
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)
    copy_bytes = p["width"]*p["b"]
    source_start = p["src"]+p["sy"]*p["sp"]+p["sx"]*p["b"]
    destination_start = p["dst"]+p["sy"]*p["dp"]+p["dx"]*p["b"]
    sources = [source_start+i*p["sp"] for i in range(p["rows"])]
    destinations = [destination_start+i*p["dp"] for i in range(p["rows"])]
    descriptor_addresses = [p["desc"]+24*i for i in range(p["rows"])]
    next_pointers = [p["desc"]+24*(i+1) if i+1<p["rows"] else 0 for i in range(p["rows"])]
    terminal_flags = [i==p["rows"]-1 for i in range(p["rows"])]
    head = p["desc"] if p["rows"] else 0
    descriptors = [[sources[i],destinations[i],copy_bytes,next_pointers[i],terminal_flags[i]] for i in range(p["rows"])]
    return {'copy_bytes': copy_bytes, 'source_start': source_start, 'destination_start': destination_start, 'sources': sources, 'destinations': destinations, 'descriptor_addresses': descriptor_addresses, 'next_pointers': next_pointers, 'terminal_flags': terminal_flags, 'head': head, 'descriptors': descriptors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'rows': 0, 'width': 2, 'b': 2, 'src': 101, 'dst': 501, 'sp': 9, 'dp': 15, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 4, 'source_start': 121, 'destination_start': 520, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 2, 'src': 101, 'dst': 501, 'sp': 11, 'dp': 17, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 125, 'destination_start': 522, 'sources': [125], 'destinations': [522], 'descriptor_addresses': [901], 'next_pointers': [0], 'terminal_flags': [True], 'head': 901, 'descriptors': [[125, 522, 6, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 2, 'src': 101, 'dst': 501, 'sp': 13, 'dp': 19, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 129, 'destination_start': 524, 'sources': [129, 142], 'destinations': [524, 543], 'descriptor_addresses': [901, 925], 'next_pointers': [925, 0], 'terminal_flags': [False, True], 'head': 901, 'descriptors': [[129, 524, 8, 925, False], [142, 543, 8, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 2, 'src': 101, 'dst': 501, 'sp': 15, 'dp': 21, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 133, 'destination_start': 526, 'sources': [133, 148, 163], 'destinations': [526, 547, 568], 'descriptor_addresses': [901, 925, 949], 'next_pointers': [925, 949, 0], 'terminal_flags': [False, False, True], 'head': 901, 'descriptors': [[133, 526, 10, 925, False], [148, 547, 10, 949, False], [163, 568, 10, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 2, 'src': 101, 'dst': 501, 'sp': 17, 'dp': 23, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 137, 'destination_start': 528, 'sources': [137, 154, 171, 188], 'destinations': [528, 551, 574, 597], 'descriptor_addresses': [901, 925, 949, 973], 'next_pointers': [925, 949, 973, 0], 'terminal_flags': [False, False, False, True], 'head': 901, 'descriptors': [[137, 528, 12, 925, False], [154, 551, 12, 949, False], [171, 574, 12, 973, False], [188, 597, 12, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 2, 'src': 101, 'dst': 501, 'sp': 19, 'dp': 25, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 14, 'source_start': 141, 'destination_start': 530, 'sources': [141, 160, 179, 198, 217], 'destinations': [530, 555, 580, 605, 630], 'descriptor_addresses': [901, 925, 949, 973, 997], 'next_pointers': [925, 949, 973, 997, 0], 'terminal_flags': [False, False, False, False, True], 'head': 901, 'descriptors': [[141, 530, 14, 925, False], [160, 555, 14, 949, False], [179, 580, 14, 973, False], [198, 605, 14, 997, False], [217, 630, 14, 0, True]]})], 2: [({'rows': 0, 'width': 2, 'b': 3, 'src': 102, 'dst': 502, 'sp': 12, 'dp': 19, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 129, 'destination_start': 527, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 3, 'src': 102, 'dst': 502, 'sp': 15, 'dp': 22, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 9, 'source_start': 135, 'destination_start': 530, 'sources': [135], 'destinations': [530], 'descriptor_addresses': [902], 'next_pointers': [0], 'terminal_flags': [True], 'head': 902, 'descriptors': [[135, 530, 9, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 3, 'src': 102, 'dst': 502, 'sp': 18, 'dp': 25, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 141, 'destination_start': 533, 'sources': [141, 159], 'destinations': [533, 558], 'descriptor_addresses': [902, 926], 'next_pointers': [926, 0], 'terminal_flags': [False, True], 'head': 902, 'descriptors': [[141, 533, 12, 926, False], [159, 558, 12, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 3, 'src': 102, 'dst': 502, 'sp': 21, 'dp': 28, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 147, 'destination_start': 536, 'sources': [147, 168, 189], 'destinations': [536, 564, 592], 'descriptor_addresses': [902, 926, 950], 'next_pointers': [926, 950, 0], 'terminal_flags': [False, False, True], 'head': 902, 'descriptors': [[147, 536, 15, 926, False], [168, 564, 15, 950, False], [189, 592, 15, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 3, 'src': 102, 'dst': 502, 'sp': 24, 'dp': 31, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 153, 'destination_start': 539, 'sources': [153, 177, 201, 225], 'destinations': [539, 570, 601, 632], 'descriptor_addresses': [902, 926, 950, 974], 'next_pointers': [926, 950, 974, 0], 'terminal_flags': [False, False, False, True], 'head': 902, 'descriptors': [[153, 539, 18, 926, False], [177, 570, 18, 950, False], [201, 601, 18, 974, False], [225, 632, 18, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 3, 'src': 102, 'dst': 502, 'sp': 27, 'dp': 34, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 21, 'source_start': 159, 'destination_start': 542, 'sources': [159, 186, 213, 240, 267], 'destinations': [542, 576, 610, 644, 678], 'descriptor_addresses': [902, 926, 950, 974, 998], 'next_pointers': [926, 950, 974, 998, 0], 'terminal_flags': [False, False, False, False, True], 'head': 902, 'descriptors': [[159, 542, 21, 926, False], [186, 576, 21, 950, False], [213, 610, 21, 974, False], [240, 644, 21, 998, False], [267, 678, 21, 0, True]]})], 3: [({'rows': 0, 'width': 2, 'b': 4, 'src': 103, 'dst': 503, 'sp': 15, 'dp': 23, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 137, 'destination_start': 534, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 4, 'src': 103, 'dst': 503, 'sp': 19, 'dp': 27, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 145, 'destination_start': 538, 'sources': [145], 'destinations': [538], 'descriptor_addresses': [903], 'next_pointers': [0], 'terminal_flags': [True], 'head': 903, 'descriptors': [[145, 538, 12, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 4, 'src': 103, 'dst': 503, 'sp': 23, 'dp': 31, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 16, 'source_start': 153, 'destination_start': 542, 'sources': [153, 176], 'destinations': [542, 573], 'descriptor_addresses': [903, 927], 'next_pointers': [927, 0], 'terminal_flags': [False, True], 'head': 903, 'descriptors': [[153, 542, 16, 927, False], [176, 573, 16, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 4, 'src': 103, 'dst': 503, 'sp': 27, 'dp': 35, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 161, 'destination_start': 546, 'sources': [161, 188, 215], 'destinations': [546, 581, 616], 'descriptor_addresses': [903, 927, 951], 'next_pointers': [927, 951, 0], 'terminal_flags': [False, False, True], 'head': 903, 'descriptors': [[161, 546, 20, 927, False], [188, 581, 20, 951, False], [215, 616, 20, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 4, 'src': 103, 'dst': 503, 'sp': 31, 'dp': 39, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 169, 'destination_start': 550, 'sources': [169, 200, 231, 262], 'destinations': [550, 589, 628, 667], 'descriptor_addresses': [903, 927, 951, 975], 'next_pointers': [927, 951, 975, 0], 'terminal_flags': [False, False, False, True], 'head': 903, 'descriptors': [[169, 550, 24, 927, False], [200, 589, 24, 951, False], [231, 628, 24, 975, False], [262, 667, 24, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 4, 'src': 103, 'dst': 503, 'sp': 35, 'dp': 43, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 28, 'source_start': 177, 'destination_start': 554, 'sources': [177, 212, 247, 282, 317], 'destinations': [554, 597, 640, 683, 726], 'descriptor_addresses': [903, 927, 951, 975, 999], 'next_pointers': [927, 951, 975, 999, 0], 'terminal_flags': [False, False, False, False, True], 'head': 903, 'descriptors': [[177, 554, 28, 927, False], [212, 597, 28, 951, False], [247, 640, 28, 975, False], [282, 683, 28, 999, False], [317, 726, 28, 0, True]]})], 4: [({'rows': 0, 'width': 2, 'b': 5, 'src': 104, 'dst': 504, 'sp': 18, 'dp': 27, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 145, 'destination_start': 541, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 5, 'src': 104, 'dst': 504, 'sp': 23, 'dp': 32, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 155, 'destination_start': 546, 'sources': [155], 'destinations': [546], 'descriptor_addresses': [904], 'next_pointers': [0], 'terminal_flags': [True], 'head': 904, 'descriptors': [[155, 546, 15, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 5, 'src': 104, 'dst': 504, 'sp': 28, 'dp': 37, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 165, 'destination_start': 551, 'sources': [165, 193], 'destinations': [551, 588], 'descriptor_addresses': [904, 928], 'next_pointers': [928, 0], 'terminal_flags': [False, True], 'head': 904, 'descriptors': [[165, 551, 20, 928, False], [193, 588, 20, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 5, 'src': 104, 'dst': 504, 'sp': 33, 'dp': 42, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 25, 'source_start': 175, 'destination_start': 556, 'sources': [175, 208, 241], 'destinations': [556, 598, 640], 'descriptor_addresses': [904, 928, 952], 'next_pointers': [928, 952, 0], 'terminal_flags': [False, False, True], 'head': 904, 'descriptors': [[175, 556, 25, 928, False], [208, 598, 25, 952, False], [241, 640, 25, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 5, 'src': 104, 'dst': 504, 'sp': 38, 'dp': 47, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 185, 'destination_start': 561, 'sources': [185, 223, 261, 299], 'destinations': [561, 608, 655, 702], 'descriptor_addresses': [904, 928, 952, 976], 'next_pointers': [928, 952, 976, 0], 'terminal_flags': [False, False, False, True], 'head': 904, 'descriptors': [[185, 561, 30, 928, False], [223, 608, 30, 952, False], [261, 655, 30, 976, False], [299, 702, 30, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 5, 'src': 104, 'dst': 504, 'sp': 43, 'dp': 52, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 35, 'source_start': 195, 'destination_start': 566, 'sources': [195, 238, 281, 324, 367], 'destinations': [566, 618, 670, 722, 774], 'descriptor_addresses': [904, 928, 952, 976, 1000], 'next_pointers': [928, 952, 976, 1000, 0], 'terminal_flags': [False, False, False, False, True], 'head': 904, 'descriptors': [[195, 566, 35, 928, False], [238, 618, 35, 952, False], [281, 670, 35, 976, False], [324, 722, 35, 1000, False], [367, 774, 35, 0, True]]})], 5: [({'rows': 0, 'width': 2, 'b': 6, 'src': 105, 'dst': 505, 'sp': 21, 'dp': 31, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 153, 'destination_start': 548, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 6, 'src': 105, 'dst': 505, 'sp': 27, 'dp': 37, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 165, 'destination_start': 554, 'sources': [165], 'destinations': [554], 'descriptor_addresses': [905], 'next_pointers': [0], 'terminal_flags': [True], 'head': 905, 'descriptors': [[165, 554, 18, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 6, 'src': 105, 'dst': 505, 'sp': 33, 'dp': 43, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 177, 'destination_start': 560, 'sources': [177, 210], 'destinations': [560, 603], 'descriptor_addresses': [905, 929], 'next_pointers': [929, 0], 'terminal_flags': [False, True], 'head': 905, 'descriptors': [[177, 560, 24, 929, False], [210, 603, 24, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 6, 'src': 105, 'dst': 505, 'sp': 39, 'dp': 49, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 189, 'destination_start': 566, 'sources': [189, 228, 267], 'destinations': [566, 615, 664], 'descriptor_addresses': [905, 929, 953], 'next_pointers': [929, 953, 0], 'terminal_flags': [False, False, True], 'head': 905, 'descriptors': [[189, 566, 30, 929, False], [228, 615, 30, 953, False], [267, 664, 30, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 6, 'src': 105, 'dst': 505, 'sp': 45, 'dp': 55, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 36, 'source_start': 201, 'destination_start': 572, 'sources': [201, 246, 291, 336], 'destinations': [572, 627, 682, 737], 'descriptor_addresses': [905, 929, 953, 977], 'next_pointers': [929, 953, 977, 0], 'terminal_flags': [False, False, False, True], 'head': 905, 'descriptors': [[201, 572, 36, 929, False], [246, 627, 36, 953, False], [291, 682, 36, 977, False], [336, 737, 36, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 6, 'src': 105, 'dst': 505, 'sp': 51, 'dp': 61, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 42, 'source_start': 213, 'destination_start': 578, 'sources': [213, 264, 315, 366, 417], 'destinations': [578, 639, 700, 761, 822], 'descriptor_addresses': [905, 929, 953, 977, 1001], 'next_pointers': [929, 953, 977, 1001, 0], 'terminal_flags': [False, False, False, False, True], 'head': 905, 'descriptors': [[213, 578, 42, 929, False], [264, 639, 42, 953, False], [315, 700, 42, 977, False], [366, 761, 42, 1001, False], [417, 822, 42, 0, True]]})]}
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 destination_start.

Each raster row copies a valid contiguous byte region from pitched source to pitched destination. Hardware descriptors hold absolute source, destination, length, next-pointer, and terminal flag; descriptors are 24 bytes and begin at a separate base. 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)
    copy_bytes = p["width"]*p["b"]
    source_start = p["src"]+p["sy"]*p["sp"]+p["sx"]*p["b"]
    destination_start = p["dst"]+p["dy"]*p["dp"]+p["dx"]*p["b"]
    sources = [source_start+i*copy_bytes for i in range(p["rows"])]
    destinations = [destination_start+i*p["dp"] for i in range(p["rows"])]
    descriptor_addresses = [p["desc"]+24*i for i in range(p["rows"])]
    next_pointers = [p["desc"]+24*(i+1) if i+1<p["rows"] else 0 for i in range(p["rows"])]
    terminal_flags = [i==p["rows"]-1 for i in range(p["rows"])]
    head = p["desc"] if p["rows"] else 0
    descriptors = [[sources[i],destinations[i],copy_bytes,next_pointers[i],terminal_flags[i]] for i in range(p["rows"])]
    return {'copy_bytes': copy_bytes, 'source_start': source_start, 'destination_start': destination_start, 'sources': sources, 'destinations': destinations, 'descriptor_addresses': descriptor_addresses, 'next_pointers': next_pointers, 'terminal_flags': terminal_flags, 'head': head, 'descriptors': descriptors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'rows': 0, 'width': 2, 'b': 2, 'src': 101, 'dst': 501, 'sp': 9, 'dp': 15, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 4, 'source_start': 121, 'destination_start': 520, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 2, 'src': 101, 'dst': 501, 'sp': 11, 'dp': 17, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 125, 'destination_start': 522, 'sources': [125], 'destinations': [522], 'descriptor_addresses': [901], 'next_pointers': [0], 'terminal_flags': [True], 'head': 901, 'descriptors': [[125, 522, 6, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 2, 'src': 101, 'dst': 501, 'sp': 13, 'dp': 19, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 129, 'destination_start': 524, 'sources': [129, 142], 'destinations': [524, 543], 'descriptor_addresses': [901, 925], 'next_pointers': [925, 0], 'terminal_flags': [False, True], 'head': 901, 'descriptors': [[129, 524, 8, 925, False], [142, 543, 8, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 2, 'src': 101, 'dst': 501, 'sp': 15, 'dp': 21, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 133, 'destination_start': 526, 'sources': [133, 148, 163], 'destinations': [526, 547, 568], 'descriptor_addresses': [901, 925, 949], 'next_pointers': [925, 949, 0], 'terminal_flags': [False, False, True], 'head': 901, 'descriptors': [[133, 526, 10, 925, False], [148, 547, 10, 949, False], [163, 568, 10, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 2, 'src': 101, 'dst': 501, 'sp': 17, 'dp': 23, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 137, 'destination_start': 528, 'sources': [137, 154, 171, 188], 'destinations': [528, 551, 574, 597], 'descriptor_addresses': [901, 925, 949, 973], 'next_pointers': [925, 949, 973, 0], 'terminal_flags': [False, False, False, True], 'head': 901, 'descriptors': [[137, 528, 12, 925, False], [154, 551, 12, 949, False], [171, 574, 12, 973, False], [188, 597, 12, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 2, 'src': 101, 'dst': 501, 'sp': 19, 'dp': 25, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 14, 'source_start': 141, 'destination_start': 530, 'sources': [141, 160, 179, 198, 217], 'destinations': [530, 555, 580, 605, 630], 'descriptor_addresses': [901, 925, 949, 973, 997], 'next_pointers': [925, 949, 973, 997, 0], 'terminal_flags': [False, False, False, False, True], 'head': 901, 'descriptors': [[141, 530, 14, 925, False], [160, 555, 14, 949, False], [179, 580, 14, 973, False], [198, 605, 14, 997, False], [217, 630, 14, 0, True]]})], 2: [({'rows': 0, 'width': 2, 'b': 3, 'src': 102, 'dst': 502, 'sp': 12, 'dp': 19, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 129, 'destination_start': 527, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 3, 'src': 102, 'dst': 502, 'sp': 15, 'dp': 22, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 9, 'source_start': 135, 'destination_start': 530, 'sources': [135], 'destinations': [530], 'descriptor_addresses': [902], 'next_pointers': [0], 'terminal_flags': [True], 'head': 902, 'descriptors': [[135, 530, 9, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 3, 'src': 102, 'dst': 502, 'sp': 18, 'dp': 25, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 141, 'destination_start': 533, 'sources': [141, 159], 'destinations': [533, 558], 'descriptor_addresses': [902, 926], 'next_pointers': [926, 0], 'terminal_flags': [False, True], 'head': 902, 'descriptors': [[141, 533, 12, 926, False], [159, 558, 12, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 3, 'src': 102, 'dst': 502, 'sp': 21, 'dp': 28, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 147, 'destination_start': 536, 'sources': [147, 168, 189], 'destinations': [536, 564, 592], 'descriptor_addresses': [902, 926, 950], 'next_pointers': [926, 950, 0], 'terminal_flags': [False, False, True], 'head': 902, 'descriptors': [[147, 536, 15, 926, False], [168, 564, 15, 950, False], [189, 592, 15, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 3, 'src': 102, 'dst': 502, 'sp': 24, 'dp': 31, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 153, 'destination_start': 539, 'sources': [153, 177, 201, 225], 'destinations': [539, 570, 601, 632], 'descriptor_addresses': [902, 926, 950, 974], 'next_pointers': [926, 950, 974, 0], 'terminal_flags': [False, False, False, True], 'head': 902, 'descriptors': [[153, 539, 18, 926, False], [177, 570, 18, 950, False], [201, 601, 18, 974, False], [225, 632, 18, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 3, 'src': 102, 'dst': 502, 'sp': 27, 'dp': 34, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 21, 'source_start': 159, 'destination_start': 542, 'sources': [159, 186, 213, 240, 267], 'destinations': [542, 576, 610, 644, 678], 'descriptor_addresses': [902, 926, 950, 974, 998], 'next_pointers': [926, 950, 974, 998, 0], 'terminal_flags': [False, False, False, False, True], 'head': 902, 'descriptors': [[159, 542, 21, 926, False], [186, 576, 21, 950, False], [213, 610, 21, 974, False], [240, 644, 21, 998, False], [267, 678, 21, 0, True]]})], 3: [({'rows': 0, 'width': 2, 'b': 4, 'src': 103, 'dst': 503, 'sp': 15, 'dp': 23, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 137, 'destination_start': 534, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 4, 'src': 103, 'dst': 503, 'sp': 19, 'dp': 27, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 145, 'destination_start': 538, 'sources': [145], 'destinations': [538], 'descriptor_addresses': [903], 'next_pointers': [0], 'terminal_flags': [True], 'head': 903, 'descriptors': [[145, 538, 12, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 4, 'src': 103, 'dst': 503, 'sp': 23, 'dp': 31, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 16, 'source_start': 153, 'destination_start': 542, 'sources': [153, 176], 'destinations': [542, 573], 'descriptor_addresses': [903, 927], 'next_pointers': [927, 0], 'terminal_flags': [False, True], 'head': 903, 'descriptors': [[153, 542, 16, 927, False], [176, 573, 16, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 4, 'src': 103, 'dst': 503, 'sp': 27, 'dp': 35, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 161, 'destination_start': 546, 'sources': [161, 188, 215], 'destinations': [546, 581, 616], 'descriptor_addresses': [903, 927, 951], 'next_pointers': [927, 951, 0], 'terminal_flags': [False, False, True], 'head': 903, 'descriptors': [[161, 546, 20, 927, False], [188, 581, 20, 951, False], [215, 616, 20, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 4, 'src': 103, 'dst': 503, 'sp': 31, 'dp': 39, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 169, 'destination_start': 550, 'sources': [169, 200, 231, 262], 'destinations': [550, 589, 628, 667], 'descriptor_addresses': [903, 927, 951, 975], 'next_pointers': [927, 951, 975, 0], 'terminal_flags': [False, False, False, True], 'head': 903, 'descriptors': [[169, 550, 24, 927, False], [200, 589, 24, 951, False], [231, 628, 24, 975, False], [262, 667, 24, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 4, 'src': 103, 'dst': 503, 'sp': 35, 'dp': 43, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 28, 'source_start': 177, 'destination_start': 554, 'sources': [177, 212, 247, 282, 317], 'destinations': [554, 597, 640, 683, 726], 'descriptor_addresses': [903, 927, 951, 975, 999], 'next_pointers': [927, 951, 975, 999, 0], 'terminal_flags': [False, False, False, False, True], 'head': 903, 'descriptors': [[177, 554, 28, 927, False], [212, 597, 28, 951, False], [247, 640, 28, 975, False], [282, 683, 28, 999, False], [317, 726, 28, 0, True]]})], 4: [({'rows': 0, 'width': 2, 'b': 5, 'src': 104, 'dst': 504, 'sp': 18, 'dp': 27, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 145, 'destination_start': 541, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 5, 'src': 104, 'dst': 504, 'sp': 23, 'dp': 32, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 155, 'destination_start': 546, 'sources': [155], 'destinations': [546], 'descriptor_addresses': [904], 'next_pointers': [0], 'terminal_flags': [True], 'head': 904, 'descriptors': [[155, 546, 15, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 5, 'src': 104, 'dst': 504, 'sp': 28, 'dp': 37, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 165, 'destination_start': 551, 'sources': [165, 193], 'destinations': [551, 588], 'descriptor_addresses': [904, 928], 'next_pointers': [928, 0], 'terminal_flags': [False, True], 'head': 904, 'descriptors': [[165, 551, 20, 928, False], [193, 588, 20, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 5, 'src': 104, 'dst': 504, 'sp': 33, 'dp': 42, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 25, 'source_start': 175, 'destination_start': 556, 'sources': [175, 208, 241], 'destinations': [556, 598, 640], 'descriptor_addresses': [904, 928, 952], 'next_pointers': [928, 952, 0], 'terminal_flags': [False, False, True], 'head': 904, 'descriptors': [[175, 556, 25, 928, False], [208, 598, 25, 952, False], [241, 640, 25, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 5, 'src': 104, 'dst': 504, 'sp': 38, 'dp': 47, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 185, 'destination_start': 561, 'sources': [185, 223, 261, 299], 'destinations': [561, 608, 655, 702], 'descriptor_addresses': [904, 928, 952, 976], 'next_pointers': [928, 952, 976, 0], 'terminal_flags': [False, False, False, True], 'head': 904, 'descriptors': [[185, 561, 30, 928, False], [223, 608, 30, 952, False], [261, 655, 30, 976, False], [299, 702, 30, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 5, 'src': 104, 'dst': 504, 'sp': 43, 'dp': 52, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 35, 'source_start': 195, 'destination_start': 566, 'sources': [195, 238, 281, 324, 367], 'destinations': [566, 618, 670, 722, 774], 'descriptor_addresses': [904, 928, 952, 976, 1000], 'next_pointers': [928, 952, 976, 1000, 0], 'terminal_flags': [False, False, False, False, True], 'head': 904, 'descriptors': [[195, 566, 35, 928, False], [238, 618, 35, 952, False], [281, 670, 35, 976, False], [324, 722, 35, 1000, False], [367, 774, 35, 0, True]]})], 5: [({'rows': 0, 'width': 2, 'b': 6, 'src': 105, 'dst': 505, 'sp': 21, 'dp': 31, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 153, 'destination_start': 548, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 6, 'src': 105, 'dst': 505, 'sp': 27, 'dp': 37, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 165, 'destination_start': 554, 'sources': [165], 'destinations': [554], 'descriptor_addresses': [905], 'next_pointers': [0], 'terminal_flags': [True], 'head': 905, 'descriptors': [[165, 554, 18, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 6, 'src': 105, 'dst': 505, 'sp': 33, 'dp': 43, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 177, 'destination_start': 560, 'sources': [177, 210], 'destinations': [560, 603], 'descriptor_addresses': [905, 929], 'next_pointers': [929, 0], 'terminal_flags': [False, True], 'head': 905, 'descriptors': [[177, 560, 24, 929, False], [210, 603, 24, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 6, 'src': 105, 'dst': 505, 'sp': 39, 'dp': 49, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 189, 'destination_start': 566, 'sources': [189, 228, 267], 'destinations': [566, 615, 664], 'descriptor_addresses': [905, 929, 953], 'next_pointers': [929, 953, 0], 'terminal_flags': [False, False, True], 'head': 905, 'descriptors': [[189, 566, 30, 929, False], [228, 615, 30, 953, False], [267, 664, 30, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 6, 'src': 105, 'dst': 505, 'sp': 45, 'dp': 55, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 36, 'source_start': 201, 'destination_start': 572, 'sources': [201, 246, 291, 336], 'destinations': [572, 627, 682, 737], 'descriptor_addresses': [905, 929, 953, 977], 'next_pointers': [929, 953, 977, 0], 'terminal_flags': [False, False, False, True], 'head': 905, 'descriptors': [[201, 572, 36, 929, False], [246, 627, 36, 953, False], [291, 682, 36, 977, False], [336, 737, 36, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 6, 'src': 105, 'dst': 505, 'sp': 51, 'dp': 61, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 42, 'source_start': 213, 'destination_start': 578, 'sources': [213, 264, 315, 366, 417], 'destinations': [578, 639, 700, 761, 822], 'descriptor_addresses': [905, 929, 953, 977, 1001], 'next_pointers': [929, 953, 977, 1001, 0], 'terminal_flags': [False, False, False, False, True], 'head': 905, 'descriptors': [[213, 578, 42, 929, False], [264, 639, 42, 953, False], [315, 700, 42, 977, False], [366, 761, 42, 1001, False], [417, 822, 42, 0, True]]})]}
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)
    copy_bytes = p["width"]*p["b"]
    source_start = p["src"]+p["sy"]*p["sp"]+p["sx"]*p["b"]
    destination_start = p["dst"]+p["dy"]*p["dp"]+p["dx"]*p["b"]
    sources = [source_start]*p["rows"]
    destinations = [destination_start+i*p["dp"] for i in range(p["rows"])]
    descriptor_addresses = [p["desc"]+24*i for i in range(p["rows"])]
    next_pointers = [p["desc"]+24*(i+1) if i+1<p["rows"] else 0 for i in range(p["rows"])]
    terminal_flags = [i==p["rows"]-1 for i in range(p["rows"])]
    head = p["desc"] if p["rows"] else 0
    descriptors = [[sources[i],destinations[i],copy_bytes,next_pointers[i],terminal_flags[i]] for i in range(p["rows"])]
    return {'copy_bytes': copy_bytes, 'source_start': source_start, 'destination_start': destination_start, 'sources': sources, 'destinations': destinations, 'descriptor_addresses': descriptor_addresses, 'next_pointers': next_pointers, 'terminal_flags': terminal_flags, 'head': head, 'descriptors': descriptors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'rows': 0, 'width': 2, 'b': 2, 'src': 101, 'dst': 501, 'sp': 9, 'dp': 15, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 4, 'source_start': 121, 'destination_start': 520, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 2, 'src': 101, 'dst': 501, 'sp': 11, 'dp': 17, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 125, 'destination_start': 522, 'sources': [125], 'destinations': [522], 'descriptor_addresses': [901], 'next_pointers': [0], 'terminal_flags': [True], 'head': 901, 'descriptors': [[125, 522, 6, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 2, 'src': 101, 'dst': 501, 'sp': 13, 'dp': 19, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 129, 'destination_start': 524, 'sources': [129, 142], 'destinations': [524, 543], 'descriptor_addresses': [901, 925], 'next_pointers': [925, 0], 'terminal_flags': [False, True], 'head': 901, 'descriptors': [[129, 524, 8, 925, False], [142, 543, 8, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 2, 'src': 101, 'dst': 501, 'sp': 15, 'dp': 21, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 133, 'destination_start': 526, 'sources': [133, 148, 163], 'destinations': [526, 547, 568], 'descriptor_addresses': [901, 925, 949], 'next_pointers': [925, 949, 0], 'terminal_flags': [False, False, True], 'head': 901, 'descriptors': [[133, 526, 10, 925, False], [148, 547, 10, 949, False], [163, 568, 10, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 2, 'src': 101, 'dst': 501, 'sp': 17, 'dp': 23, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 137, 'destination_start': 528, 'sources': [137, 154, 171, 188], 'destinations': [528, 551, 574, 597], 'descriptor_addresses': [901, 925, 949, 973], 'next_pointers': [925, 949, 973, 0], 'terminal_flags': [False, False, False, True], 'head': 901, 'descriptors': [[137, 528, 12, 925, False], [154, 551, 12, 949, False], [171, 574, 12, 973, False], [188, 597, 12, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 2, 'src': 101, 'dst': 501, 'sp': 19, 'dp': 25, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 14, 'source_start': 141, 'destination_start': 530, 'sources': [141, 160, 179, 198, 217], 'destinations': [530, 555, 580, 605, 630], 'descriptor_addresses': [901, 925, 949, 973, 997], 'next_pointers': [925, 949, 973, 997, 0], 'terminal_flags': [False, False, False, False, True], 'head': 901, 'descriptors': [[141, 530, 14, 925, False], [160, 555, 14, 949, False], [179, 580, 14, 973, False], [198, 605, 14, 997, False], [217, 630, 14, 0, True]]})], 2: [({'rows': 0, 'width': 2, 'b': 3, 'src': 102, 'dst': 502, 'sp': 12, 'dp': 19, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 129, 'destination_start': 527, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 3, 'src': 102, 'dst': 502, 'sp': 15, 'dp': 22, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 9, 'source_start': 135, 'destination_start': 530, 'sources': [135], 'destinations': [530], 'descriptor_addresses': [902], 'next_pointers': [0], 'terminal_flags': [True], 'head': 902, 'descriptors': [[135, 530, 9, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 3, 'src': 102, 'dst': 502, 'sp': 18, 'dp': 25, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 141, 'destination_start': 533, 'sources': [141, 159], 'destinations': [533, 558], 'descriptor_addresses': [902, 926], 'next_pointers': [926, 0], 'terminal_flags': [False, True], 'head': 902, 'descriptors': [[141, 533, 12, 926, False], [159, 558, 12, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 3, 'src': 102, 'dst': 502, 'sp': 21, 'dp': 28, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 147, 'destination_start': 536, 'sources': [147, 168, 189], 'destinations': [536, 564, 592], 'descriptor_addresses': [902, 926, 950], 'next_pointers': [926, 950, 0], 'terminal_flags': [False, False, True], 'head': 902, 'descriptors': [[147, 536, 15, 926, False], [168, 564, 15, 950, False], [189, 592, 15, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 3, 'src': 102, 'dst': 502, 'sp': 24, 'dp': 31, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 153, 'destination_start': 539, 'sources': [153, 177, 201, 225], 'destinations': [539, 570, 601, 632], 'descriptor_addresses': [902, 926, 950, 974], 'next_pointers': [926, 950, 974, 0], 'terminal_flags': [False, False, False, True], 'head': 902, 'descriptors': [[153, 539, 18, 926, False], [177, 570, 18, 950, False], [201, 601, 18, 974, False], [225, 632, 18, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 3, 'src': 102, 'dst': 502, 'sp': 27, 'dp': 34, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 21, 'source_start': 159, 'destination_start': 542, 'sources': [159, 186, 213, 240, 267], 'destinations': [542, 576, 610, 644, 678], 'descriptor_addresses': [902, 926, 950, 974, 998], 'next_pointers': [926, 950, 974, 998, 0], 'terminal_flags': [False, False, False, False, True], 'head': 902, 'descriptors': [[159, 542, 21, 926, False], [186, 576, 21, 950, False], [213, 610, 21, 974, False], [240, 644, 21, 998, False], [267, 678, 21, 0, True]]})], 3: [({'rows': 0, 'width': 2, 'b': 4, 'src': 103, 'dst': 503, 'sp': 15, 'dp': 23, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 137, 'destination_start': 534, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 4, 'src': 103, 'dst': 503, 'sp': 19, 'dp': 27, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 145, 'destination_start': 538, 'sources': [145], 'destinations': [538], 'descriptor_addresses': [903], 'next_pointers': [0], 'terminal_flags': [True], 'head': 903, 'descriptors': [[145, 538, 12, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 4, 'src': 103, 'dst': 503, 'sp': 23, 'dp': 31, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 16, 'source_start': 153, 'destination_start': 542, 'sources': [153, 176], 'destinations': [542, 573], 'descriptor_addresses': [903, 927], 'next_pointers': [927, 0], 'terminal_flags': [False, True], 'head': 903, 'descriptors': [[153, 542, 16, 927, False], [176, 573, 16, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 4, 'src': 103, 'dst': 503, 'sp': 27, 'dp': 35, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 161, 'destination_start': 546, 'sources': [161, 188, 215], 'destinations': [546, 581, 616], 'descriptor_addresses': [903, 927, 951], 'next_pointers': [927, 951, 0], 'terminal_flags': [False, False, True], 'head': 903, 'descriptors': [[161, 546, 20, 927, False], [188, 581, 20, 951, False], [215, 616, 20, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 4, 'src': 103, 'dst': 503, 'sp': 31, 'dp': 39, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 169, 'destination_start': 550, 'sources': [169, 200, 231, 262], 'destinations': [550, 589, 628, 667], 'descriptor_addresses': [903, 927, 951, 975], 'next_pointers': [927, 951, 975, 0], 'terminal_flags': [False, False, False, True], 'head': 903, 'descriptors': [[169, 550, 24, 927, False], [200, 589, 24, 951, False], [231, 628, 24, 975, False], [262, 667, 24, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 4, 'src': 103, 'dst': 503, 'sp': 35, 'dp': 43, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 28, 'source_start': 177, 'destination_start': 554, 'sources': [177, 212, 247, 282, 317], 'destinations': [554, 597, 640, 683, 726], 'descriptor_addresses': [903, 927, 951, 975, 999], 'next_pointers': [927, 951, 975, 999, 0], 'terminal_flags': [False, False, False, False, True], 'head': 903, 'descriptors': [[177, 554, 28, 927, False], [212, 597, 28, 951, False], [247, 640, 28, 975, False], [282, 683, 28, 999, False], [317, 726, 28, 0, True]]})], 4: [({'rows': 0, 'width': 2, 'b': 5, 'src': 104, 'dst': 504, 'sp': 18, 'dp': 27, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 145, 'destination_start': 541, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 5, 'src': 104, 'dst': 504, 'sp': 23, 'dp': 32, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 155, 'destination_start': 546, 'sources': [155], 'destinations': [546], 'descriptor_addresses': [904], 'next_pointers': [0], 'terminal_flags': [True], 'head': 904, 'descriptors': [[155, 546, 15, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 5, 'src': 104, 'dst': 504, 'sp': 28, 'dp': 37, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 165, 'destination_start': 551, 'sources': [165, 193], 'destinations': [551, 588], 'descriptor_addresses': [904, 928], 'next_pointers': [928, 0], 'terminal_flags': [False, True], 'head': 904, 'descriptors': [[165, 551, 20, 928, False], [193, 588, 20, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 5, 'src': 104, 'dst': 504, 'sp': 33, 'dp': 42, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 25, 'source_start': 175, 'destination_start': 556, 'sources': [175, 208, 241], 'destinations': [556, 598, 640], 'descriptor_addresses': [904, 928, 952], 'next_pointers': [928, 952, 0], 'terminal_flags': [False, False, True], 'head': 904, 'descriptors': [[175, 556, 25, 928, False], [208, 598, 25, 952, False], [241, 640, 25, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 5, 'src': 104, 'dst': 504, 'sp': 38, 'dp': 47, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 185, 'destination_start': 561, 'sources': [185, 223, 261, 299], 'destinations': [561, 608, 655, 702], 'descriptor_addresses': [904, 928, 952, 976], 'next_pointers': [928, 952, 976, 0], 'terminal_flags': [False, False, False, True], 'head': 904, 'descriptors': [[185, 561, 30, 928, False], [223, 608, 30, 952, False], [261, 655, 30, 976, False], [299, 702, 30, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 5, 'src': 104, 'dst': 504, 'sp': 43, 'dp': 52, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 35, 'source_start': 195, 'destination_start': 566, 'sources': [195, 238, 281, 324, 367], 'destinations': [566, 618, 670, 722, 774], 'descriptor_addresses': [904, 928, 952, 976, 1000], 'next_pointers': [928, 952, 976, 1000, 0], 'terminal_flags': [False, False, False, False, True], 'head': 904, 'descriptors': [[195, 566, 35, 928, False], [238, 618, 35, 952, False], [281, 670, 35, 976, False], [324, 722, 35, 1000, False], [367, 774, 35, 0, True]]})], 5: [({'rows': 0, 'width': 2, 'b': 6, 'src': 105, 'dst': 505, 'sp': 21, 'dp': 31, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 153, 'destination_start': 548, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 6, 'src': 105, 'dst': 505, 'sp': 27, 'dp': 37, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 165, 'destination_start': 554, 'sources': [165], 'destinations': [554], 'descriptor_addresses': [905], 'next_pointers': [0], 'terminal_flags': [True], 'head': 905, 'descriptors': [[165, 554, 18, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 6, 'src': 105, 'dst': 505, 'sp': 33, 'dp': 43, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 177, 'destination_start': 560, 'sources': [177, 210], 'destinations': [560, 603], 'descriptor_addresses': [905, 929], 'next_pointers': [929, 0], 'terminal_flags': [False, True], 'head': 905, 'descriptors': [[177, 560, 24, 929, False], [210, 603, 24, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 6, 'src': 105, 'dst': 505, 'sp': 39, 'dp': 49, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 189, 'destination_start': 566, 'sources': [189, 228, 267], 'destinations': [566, 615, 664], 'descriptor_addresses': [905, 929, 953], 'next_pointers': [929, 953, 0], 'terminal_flags': [False, False, True], 'head': 905, 'descriptors': [[189, 566, 30, 929, False], [228, 615, 30, 953, False], [267, 664, 30, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 6, 'src': 105, 'dst': 505, 'sp': 45, 'dp': 55, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 36, 'source_start': 201, 'destination_start': 572, 'sources': [201, 246, 291, 336], 'destinations': [572, 627, 682, 737], 'descriptor_addresses': [905, 929, 953, 977], 'next_pointers': [929, 953, 977, 0], 'terminal_flags': [False, False, False, True], 'head': 905, 'descriptors': [[201, 572, 36, 929, False], [246, 627, 36, 953, False], [291, 682, 36, 977, False], [336, 737, 36, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 6, 'src': 105, 'dst': 505, 'sp': 51, 'dp': 61, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 42, 'source_start': 213, 'destination_start': 578, 'sources': [213, 264, 315, 366, 417], 'destinations': [578, 639, 700, 761, 822], 'descriptor_addresses': [905, 929, 953, 977, 1001], 'next_pointers': [929, 953, 977, 1001, 0], 'terminal_flags': [False, False, False, False, True], 'head': 905, 'descriptors': [[213, 578, 42, 929, False], [264, 639, 42, 953, False], [315, 700, 42, 977, False], [366, 761, 42, 1001, False], [417, 822, 42, 0, True]]})]}
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 sources.

Each raster row copies a valid contiguous byte region from pitched source to pitched destination. Hardware descriptors hold absolute source, destination, length, next-pointer, and terminal flag; descriptors are 24 bytes and begin at a separate base. 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)
    copy_bytes = p["width"]*p["b"]
    source_start = p["src"]+p["sy"]*p["sp"]+p["sx"]*p["b"]
    destination_start = p["dst"]+p["dy"]*p["dp"]+p["dx"]*p["b"]
    sources = [source_start+i*p["sp"] for i in range(p["rows"])]
    destinations = [destination_start+i*p["sp"] for i in range(p["rows"])]
    descriptor_addresses = [p["desc"]+24*i for i in range(p["rows"])]
    next_pointers = [p["desc"]+24*(i+1) if i+1<p["rows"] else 0 for i in range(p["rows"])]
    terminal_flags = [i==p["rows"]-1 for i in range(p["rows"])]
    head = p["desc"] if p["rows"] else 0
    descriptors = [[sources[i],destinations[i],copy_bytes,next_pointers[i],terminal_flags[i]] for i in range(p["rows"])]
    return {'copy_bytes': copy_bytes, 'source_start': source_start, 'destination_start': destination_start, 'sources': sources, 'destinations': destinations, 'descriptor_addresses': descriptor_addresses, 'next_pointers': next_pointers, 'terminal_flags': terminal_flags, 'head': head, 'descriptors': descriptors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'rows': 0, 'width': 2, 'b': 2, 'src': 101, 'dst': 501, 'sp': 9, 'dp': 15, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 4, 'source_start': 121, 'destination_start': 520, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 2, 'src': 101, 'dst': 501, 'sp': 11, 'dp': 17, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 125, 'destination_start': 522, 'sources': [125], 'destinations': [522], 'descriptor_addresses': [901], 'next_pointers': [0], 'terminal_flags': [True], 'head': 901, 'descriptors': [[125, 522, 6, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 2, 'src': 101, 'dst': 501, 'sp': 13, 'dp': 19, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 129, 'destination_start': 524, 'sources': [129, 142], 'destinations': [524, 543], 'descriptor_addresses': [901, 925], 'next_pointers': [925, 0], 'terminal_flags': [False, True], 'head': 901, 'descriptors': [[129, 524, 8, 925, False], [142, 543, 8, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 2, 'src': 101, 'dst': 501, 'sp': 15, 'dp': 21, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 133, 'destination_start': 526, 'sources': [133, 148, 163], 'destinations': [526, 547, 568], 'descriptor_addresses': [901, 925, 949], 'next_pointers': [925, 949, 0], 'terminal_flags': [False, False, True], 'head': 901, 'descriptors': [[133, 526, 10, 925, False], [148, 547, 10, 949, False], [163, 568, 10, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 2, 'src': 101, 'dst': 501, 'sp': 17, 'dp': 23, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 137, 'destination_start': 528, 'sources': [137, 154, 171, 188], 'destinations': [528, 551, 574, 597], 'descriptor_addresses': [901, 925, 949, 973], 'next_pointers': [925, 949, 973, 0], 'terminal_flags': [False, False, False, True], 'head': 901, 'descriptors': [[137, 528, 12, 925, False], [154, 551, 12, 949, False], [171, 574, 12, 973, False], [188, 597, 12, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 2, 'src': 101, 'dst': 501, 'sp': 19, 'dp': 25, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 14, 'source_start': 141, 'destination_start': 530, 'sources': [141, 160, 179, 198, 217], 'destinations': [530, 555, 580, 605, 630], 'descriptor_addresses': [901, 925, 949, 973, 997], 'next_pointers': [925, 949, 973, 997, 0], 'terminal_flags': [False, False, False, False, True], 'head': 901, 'descriptors': [[141, 530, 14, 925, False], [160, 555, 14, 949, False], [179, 580, 14, 973, False], [198, 605, 14, 997, False], [217, 630, 14, 0, True]]})], 2: [({'rows': 0, 'width': 2, 'b': 3, 'src': 102, 'dst': 502, 'sp': 12, 'dp': 19, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 129, 'destination_start': 527, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 3, 'src': 102, 'dst': 502, 'sp': 15, 'dp': 22, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 9, 'source_start': 135, 'destination_start': 530, 'sources': [135], 'destinations': [530], 'descriptor_addresses': [902], 'next_pointers': [0], 'terminal_flags': [True], 'head': 902, 'descriptors': [[135, 530, 9, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 3, 'src': 102, 'dst': 502, 'sp': 18, 'dp': 25, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 141, 'destination_start': 533, 'sources': [141, 159], 'destinations': [533, 558], 'descriptor_addresses': [902, 926], 'next_pointers': [926, 0], 'terminal_flags': [False, True], 'head': 902, 'descriptors': [[141, 533, 12, 926, False], [159, 558, 12, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 3, 'src': 102, 'dst': 502, 'sp': 21, 'dp': 28, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 147, 'destination_start': 536, 'sources': [147, 168, 189], 'destinations': [536, 564, 592], 'descriptor_addresses': [902, 926, 950], 'next_pointers': [926, 950, 0], 'terminal_flags': [False, False, True], 'head': 902, 'descriptors': [[147, 536, 15, 926, False], [168, 564, 15, 950, False], [189, 592, 15, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 3, 'src': 102, 'dst': 502, 'sp': 24, 'dp': 31, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 153, 'destination_start': 539, 'sources': [153, 177, 201, 225], 'destinations': [539, 570, 601, 632], 'descriptor_addresses': [902, 926, 950, 974], 'next_pointers': [926, 950, 974, 0], 'terminal_flags': [False, False, False, True], 'head': 902, 'descriptors': [[153, 539, 18, 926, False], [177, 570, 18, 950, False], [201, 601, 18, 974, False], [225, 632, 18, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 3, 'src': 102, 'dst': 502, 'sp': 27, 'dp': 34, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 21, 'source_start': 159, 'destination_start': 542, 'sources': [159, 186, 213, 240, 267], 'destinations': [542, 576, 610, 644, 678], 'descriptor_addresses': [902, 926, 950, 974, 998], 'next_pointers': [926, 950, 974, 998, 0], 'terminal_flags': [False, False, False, False, True], 'head': 902, 'descriptors': [[159, 542, 21, 926, False], [186, 576, 21, 950, False], [213, 610, 21, 974, False], [240, 644, 21, 998, False], [267, 678, 21, 0, True]]})], 3: [({'rows': 0, 'width': 2, 'b': 4, 'src': 103, 'dst': 503, 'sp': 15, 'dp': 23, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 137, 'destination_start': 534, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 4, 'src': 103, 'dst': 503, 'sp': 19, 'dp': 27, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 145, 'destination_start': 538, 'sources': [145], 'destinations': [538], 'descriptor_addresses': [903], 'next_pointers': [0], 'terminal_flags': [True], 'head': 903, 'descriptors': [[145, 538, 12, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 4, 'src': 103, 'dst': 503, 'sp': 23, 'dp': 31, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 16, 'source_start': 153, 'destination_start': 542, 'sources': [153, 176], 'destinations': [542, 573], 'descriptor_addresses': [903, 927], 'next_pointers': [927, 0], 'terminal_flags': [False, True], 'head': 903, 'descriptors': [[153, 542, 16, 927, False], [176, 573, 16, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 4, 'src': 103, 'dst': 503, 'sp': 27, 'dp': 35, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 161, 'destination_start': 546, 'sources': [161, 188, 215], 'destinations': [546, 581, 616], 'descriptor_addresses': [903, 927, 951], 'next_pointers': [927, 951, 0], 'terminal_flags': [False, False, True], 'head': 903, 'descriptors': [[161, 546, 20, 927, False], [188, 581, 20, 951, False], [215, 616, 20, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 4, 'src': 103, 'dst': 503, 'sp': 31, 'dp': 39, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 169, 'destination_start': 550, 'sources': [169, 200, 231, 262], 'destinations': [550, 589, 628, 667], 'descriptor_addresses': [903, 927, 951, 975], 'next_pointers': [927, 951, 975, 0], 'terminal_flags': [False, False, False, True], 'head': 903, 'descriptors': [[169, 550, 24, 927, False], [200, 589, 24, 951, False], [231, 628, 24, 975, False], [262, 667, 24, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 4, 'src': 103, 'dst': 503, 'sp': 35, 'dp': 43, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 28, 'source_start': 177, 'destination_start': 554, 'sources': [177, 212, 247, 282, 317], 'destinations': [554, 597, 640, 683, 726], 'descriptor_addresses': [903, 927, 951, 975, 999], 'next_pointers': [927, 951, 975, 999, 0], 'terminal_flags': [False, False, False, False, True], 'head': 903, 'descriptors': [[177, 554, 28, 927, False], [212, 597, 28, 951, False], [247, 640, 28, 975, False], [282, 683, 28, 999, False], [317, 726, 28, 0, True]]})], 4: [({'rows': 0, 'width': 2, 'b': 5, 'src': 104, 'dst': 504, 'sp': 18, 'dp': 27, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 145, 'destination_start': 541, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 5, 'src': 104, 'dst': 504, 'sp': 23, 'dp': 32, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 155, 'destination_start': 546, 'sources': [155], 'destinations': [546], 'descriptor_addresses': [904], 'next_pointers': [0], 'terminal_flags': [True], 'head': 904, 'descriptors': [[155, 546, 15, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 5, 'src': 104, 'dst': 504, 'sp': 28, 'dp': 37, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 165, 'destination_start': 551, 'sources': [165, 193], 'destinations': [551, 588], 'descriptor_addresses': [904, 928], 'next_pointers': [928, 0], 'terminal_flags': [False, True], 'head': 904, 'descriptors': [[165, 551, 20, 928, False], [193, 588, 20, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 5, 'src': 104, 'dst': 504, 'sp': 33, 'dp': 42, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 25, 'source_start': 175, 'destination_start': 556, 'sources': [175, 208, 241], 'destinations': [556, 598, 640], 'descriptor_addresses': [904, 928, 952], 'next_pointers': [928, 952, 0], 'terminal_flags': [False, False, True], 'head': 904, 'descriptors': [[175, 556, 25, 928, False], [208, 598, 25, 952, False], [241, 640, 25, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 5, 'src': 104, 'dst': 504, 'sp': 38, 'dp': 47, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 185, 'destination_start': 561, 'sources': [185, 223, 261, 299], 'destinations': [561, 608, 655, 702], 'descriptor_addresses': [904, 928, 952, 976], 'next_pointers': [928, 952, 976, 0], 'terminal_flags': [False, False, False, True], 'head': 904, 'descriptors': [[185, 561, 30, 928, False], [223, 608, 30, 952, False], [261, 655, 30, 976, False], [299, 702, 30, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 5, 'src': 104, 'dst': 504, 'sp': 43, 'dp': 52, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 35, 'source_start': 195, 'destination_start': 566, 'sources': [195, 238, 281, 324, 367], 'destinations': [566, 618, 670, 722, 774], 'descriptor_addresses': [904, 928, 952, 976, 1000], 'next_pointers': [928, 952, 976, 1000, 0], 'terminal_flags': [False, False, False, False, True], 'head': 904, 'descriptors': [[195, 566, 35, 928, False], [238, 618, 35, 952, False], [281, 670, 35, 976, False], [324, 722, 35, 1000, False], [367, 774, 35, 0, True]]})], 5: [({'rows': 0, 'width': 2, 'b': 6, 'src': 105, 'dst': 505, 'sp': 21, 'dp': 31, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 153, 'destination_start': 548, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 6, 'src': 105, 'dst': 505, 'sp': 27, 'dp': 37, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 165, 'destination_start': 554, 'sources': [165], 'destinations': [554], 'descriptor_addresses': [905], 'next_pointers': [0], 'terminal_flags': [True], 'head': 905, 'descriptors': [[165, 554, 18, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 6, 'src': 105, 'dst': 505, 'sp': 33, 'dp': 43, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 177, 'destination_start': 560, 'sources': [177, 210], 'destinations': [560, 603], 'descriptor_addresses': [905, 929], 'next_pointers': [929, 0], 'terminal_flags': [False, True], 'head': 905, 'descriptors': [[177, 560, 24, 929, False], [210, 603, 24, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 6, 'src': 105, 'dst': 505, 'sp': 39, 'dp': 49, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 189, 'destination_start': 566, 'sources': [189, 228, 267], 'destinations': [566, 615, 664], 'descriptor_addresses': [905, 929, 953], 'next_pointers': [929, 953, 0], 'terminal_flags': [False, False, True], 'head': 905, 'descriptors': [[189, 566, 30, 929, False], [228, 615, 30, 953, False], [267, 664, 30, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 6, 'src': 105, 'dst': 505, 'sp': 45, 'dp': 55, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 36, 'source_start': 201, 'destination_start': 572, 'sources': [201, 246, 291, 336], 'destinations': [572, 627, 682, 737], 'descriptor_addresses': [905, 929, 953, 977], 'next_pointers': [929, 953, 977, 0], 'terminal_flags': [False, False, False, True], 'head': 905, 'descriptors': [[201, 572, 36, 929, False], [246, 627, 36, 953, False], [291, 682, 36, 977, False], [336, 737, 36, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 6, 'src': 105, 'dst': 505, 'sp': 51, 'dp': 61, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 42, 'source_start': 213, 'destination_start': 578, 'sources': [213, 264, 315, 366, 417], 'destinations': [578, 639, 700, 761, 822], 'descriptor_addresses': [905, 929, 953, 977, 1001], 'next_pointers': [929, 953, 977, 1001, 0], 'terminal_flags': [False, False, False, False, True], 'head': 905, 'descriptors': [[213, 578, 42, 929, False], [264, 639, 42, 953, False], [315, 700, 42, 977, False], [366, 761, 42, 1001, False], [417, 822, 42, 0, True]]})]}
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)
    copy_bytes = p["width"]*p["b"]
    source_start = p["src"]+p["sy"]*p["sp"]+p["sx"]*p["b"]
    destination_start = p["dst"]+p["dy"]*p["dp"]+p["dx"]*p["b"]
    sources = [source_start+i*p["sp"] for i in range(p["rows"])]
    destinations = [destination_start+i*copy_bytes for i in range(p["rows"])]
    descriptor_addresses = [p["desc"]+24*i for i in range(p["rows"])]
    next_pointers = [p["desc"]+24*(i+1) if i+1<p["rows"] else 0 for i in range(p["rows"])]
    terminal_flags = [i==p["rows"]-1 for i in range(p["rows"])]
    head = p["desc"] if p["rows"] else 0
    descriptors = [[sources[i],destinations[i],copy_bytes,next_pointers[i],terminal_flags[i]] for i in range(p["rows"])]
    return {'copy_bytes': copy_bytes, 'source_start': source_start, 'destination_start': destination_start, 'sources': sources, 'destinations': destinations, 'descriptor_addresses': descriptor_addresses, 'next_pointers': next_pointers, 'terminal_flags': terminal_flags, 'head': head, 'descriptors': descriptors}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'rows': 0, 'width': 2, 'b': 2, 'src': 101, 'dst': 501, 'sp': 9, 'dp': 15, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 4, 'source_start': 121, 'destination_start': 520, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 2, 'src': 101, 'dst': 501, 'sp': 11, 'dp': 17, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 125, 'destination_start': 522, 'sources': [125], 'destinations': [522], 'descriptor_addresses': [901], 'next_pointers': [0], 'terminal_flags': [True], 'head': 901, 'descriptors': [[125, 522, 6, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 2, 'src': 101, 'dst': 501, 'sp': 13, 'dp': 19, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 129, 'destination_start': 524, 'sources': [129, 142], 'destinations': [524, 543], 'descriptor_addresses': [901, 925], 'next_pointers': [925, 0], 'terminal_flags': [False, True], 'head': 901, 'descriptors': [[129, 524, 8, 925, False], [142, 543, 8, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 2, 'src': 101, 'dst': 501, 'sp': 15, 'dp': 21, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 133, 'destination_start': 526, 'sources': [133, 148, 163], 'destinations': [526, 547, 568], 'descriptor_addresses': [901, 925, 949], 'next_pointers': [925, 949, 0], 'terminal_flags': [False, False, True], 'head': 901, 'descriptors': [[133, 526, 10, 925, False], [148, 547, 10, 949, False], [163, 568, 10, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 2, 'src': 101, 'dst': 501, 'sp': 17, 'dp': 23, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 137, 'destination_start': 528, 'sources': [137, 154, 171, 188], 'destinations': [528, 551, 574, 597], 'descriptor_addresses': [901, 925, 949, 973], 'next_pointers': [925, 949, 973, 0], 'terminal_flags': [False, False, False, True], 'head': 901, 'descriptors': [[137, 528, 12, 925, False], [154, 551, 12, 949, False], [171, 574, 12, 973, False], [188, 597, 12, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 2, 'src': 101, 'dst': 501, 'sp': 19, 'dp': 25, 'desc': 901, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 14, 'source_start': 141, 'destination_start': 530, 'sources': [141, 160, 179, 198, 217], 'destinations': [530, 555, 580, 605, 630], 'descriptor_addresses': [901, 925, 949, 973, 997], 'next_pointers': [925, 949, 973, 997, 0], 'terminal_flags': [False, False, False, False, True], 'head': 901, 'descriptors': [[141, 530, 14, 925, False], [160, 555, 14, 949, False], [179, 580, 14, 973, False], [198, 605, 14, 997, False], [217, 630, 14, 0, True]]})], 2: [({'rows': 0, 'width': 2, 'b': 3, 'src': 102, 'dst': 502, 'sp': 12, 'dp': 19, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 6, 'source_start': 129, 'destination_start': 527, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 3, 'src': 102, 'dst': 502, 'sp': 15, 'dp': 22, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 9, 'source_start': 135, 'destination_start': 530, 'sources': [135], 'destinations': [530], 'descriptor_addresses': [902], 'next_pointers': [0], 'terminal_flags': [True], 'head': 902, 'descriptors': [[135, 530, 9, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 3, 'src': 102, 'dst': 502, 'sp': 18, 'dp': 25, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 141, 'destination_start': 533, 'sources': [141, 159], 'destinations': [533, 558], 'descriptor_addresses': [902, 926], 'next_pointers': [926, 0], 'terminal_flags': [False, True], 'head': 902, 'descriptors': [[141, 533, 12, 926, False], [159, 558, 12, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 3, 'src': 102, 'dst': 502, 'sp': 21, 'dp': 28, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 147, 'destination_start': 536, 'sources': [147, 168, 189], 'destinations': [536, 564, 592], 'descriptor_addresses': [902, 926, 950], 'next_pointers': [926, 950, 0], 'terminal_flags': [False, False, True], 'head': 902, 'descriptors': [[147, 536, 15, 926, False], [168, 564, 15, 950, False], [189, 592, 15, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 3, 'src': 102, 'dst': 502, 'sp': 24, 'dp': 31, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 153, 'destination_start': 539, 'sources': [153, 177, 201, 225], 'destinations': [539, 570, 601, 632], 'descriptor_addresses': [902, 926, 950, 974], 'next_pointers': [926, 950, 974, 0], 'terminal_flags': [False, False, False, True], 'head': 902, 'descriptors': [[153, 539, 18, 926, False], [177, 570, 18, 950, False], [201, 601, 18, 974, False], [225, 632, 18, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 3, 'src': 102, 'dst': 502, 'sp': 27, 'dp': 34, 'desc': 902, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 21, 'source_start': 159, 'destination_start': 542, 'sources': [159, 186, 213, 240, 267], 'destinations': [542, 576, 610, 644, 678], 'descriptor_addresses': [902, 926, 950, 974, 998], 'next_pointers': [926, 950, 974, 998, 0], 'terminal_flags': [False, False, False, False, True], 'head': 902, 'descriptors': [[159, 542, 21, 926, False], [186, 576, 21, 950, False], [213, 610, 21, 974, False], [240, 644, 21, 998, False], [267, 678, 21, 0, True]]})], 3: [({'rows': 0, 'width': 2, 'b': 4, 'src': 103, 'dst': 503, 'sp': 15, 'dp': 23, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 8, 'source_start': 137, 'destination_start': 534, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 4, 'src': 103, 'dst': 503, 'sp': 19, 'dp': 27, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 145, 'destination_start': 538, 'sources': [145], 'destinations': [538], 'descriptor_addresses': [903], 'next_pointers': [0], 'terminal_flags': [True], 'head': 903, 'descriptors': [[145, 538, 12, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 4, 'src': 103, 'dst': 503, 'sp': 23, 'dp': 31, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 16, 'source_start': 153, 'destination_start': 542, 'sources': [153, 176], 'destinations': [542, 573], 'descriptor_addresses': [903, 927], 'next_pointers': [927, 0], 'terminal_flags': [False, True], 'head': 903, 'descriptors': [[153, 542, 16, 927, False], [176, 573, 16, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 4, 'src': 103, 'dst': 503, 'sp': 27, 'dp': 35, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 161, 'destination_start': 546, 'sources': [161, 188, 215], 'destinations': [546, 581, 616], 'descriptor_addresses': [903, 927, 951], 'next_pointers': [927, 951, 0], 'terminal_flags': [False, False, True], 'head': 903, 'descriptors': [[161, 546, 20, 927, False], [188, 581, 20, 951, False], [215, 616, 20, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 4, 'src': 103, 'dst': 503, 'sp': 31, 'dp': 39, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 169, 'destination_start': 550, 'sources': [169, 200, 231, 262], 'destinations': [550, 589, 628, 667], 'descriptor_addresses': [903, 927, 951, 975], 'next_pointers': [927, 951, 975, 0], 'terminal_flags': [False, False, False, True], 'head': 903, 'descriptors': [[169, 550, 24, 927, False], [200, 589, 24, 951, False], [231, 628, 24, 975, False], [262, 667, 24, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 4, 'src': 103, 'dst': 503, 'sp': 35, 'dp': 43, 'desc': 903, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 28, 'source_start': 177, 'destination_start': 554, 'sources': [177, 212, 247, 282, 317], 'destinations': [554, 597, 640, 683, 726], 'descriptor_addresses': [903, 927, 951, 975, 999], 'next_pointers': [927, 951, 975, 999, 0], 'terminal_flags': [False, False, False, False, True], 'head': 903, 'descriptors': [[177, 554, 28, 927, False], [212, 597, 28, 951, False], [247, 640, 28, 975, False], [282, 683, 28, 999, False], [317, 726, 28, 0, True]]})], 4: [({'rows': 0, 'width': 2, 'b': 5, 'src': 104, 'dst': 504, 'sp': 18, 'dp': 27, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 10, 'source_start': 145, 'destination_start': 541, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 5, 'src': 104, 'dst': 504, 'sp': 23, 'dp': 32, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 15, 'source_start': 155, 'destination_start': 546, 'sources': [155], 'destinations': [546], 'descriptor_addresses': [904], 'next_pointers': [0], 'terminal_flags': [True], 'head': 904, 'descriptors': [[155, 546, 15, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 5, 'src': 104, 'dst': 504, 'sp': 28, 'dp': 37, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 20, 'source_start': 165, 'destination_start': 551, 'sources': [165, 193], 'destinations': [551, 588], 'descriptor_addresses': [904, 928], 'next_pointers': [928, 0], 'terminal_flags': [False, True], 'head': 904, 'descriptors': [[165, 551, 20, 928, False], [193, 588, 20, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 5, 'src': 104, 'dst': 504, 'sp': 33, 'dp': 42, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 25, 'source_start': 175, 'destination_start': 556, 'sources': [175, 208, 241], 'destinations': [556, 598, 640], 'descriptor_addresses': [904, 928, 952], 'next_pointers': [928, 952, 0], 'terminal_flags': [False, False, True], 'head': 904, 'descriptors': [[175, 556, 25, 928, False], [208, 598, 25, 952, False], [241, 640, 25, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 5, 'src': 104, 'dst': 504, 'sp': 38, 'dp': 47, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 185, 'destination_start': 561, 'sources': [185, 223, 261, 299], 'destinations': [561, 608, 655, 702], 'descriptor_addresses': [904, 928, 952, 976], 'next_pointers': [928, 952, 976, 0], 'terminal_flags': [False, False, False, True], 'head': 904, 'descriptors': [[185, 561, 30, 928, False], [223, 608, 30, 952, False], [261, 655, 30, 976, False], [299, 702, 30, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 5, 'src': 104, 'dst': 504, 'sp': 43, 'dp': 52, 'desc': 904, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 35, 'source_start': 195, 'destination_start': 566, 'sources': [195, 238, 281, 324, 367], 'destinations': [566, 618, 670, 722, 774], 'descriptor_addresses': [904, 928, 952, 976, 1000], 'next_pointers': [928, 952, 976, 1000, 0], 'terminal_flags': [False, False, False, False, True], 'head': 904, 'descriptors': [[195, 566, 35, 928, False], [238, 618, 35, 952, False], [281, 670, 35, 976, False], [324, 722, 35, 1000, False], [367, 774, 35, 0, True]]})], 5: [({'rows': 0, 'width': 2, 'b': 6, 'src': 105, 'dst': 505, 'sp': 21, 'dp': 31, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 12, 'source_start': 153, 'destination_start': 548, 'sources': [], 'destinations': [], 'descriptor_addresses': [], 'next_pointers': [], 'terminal_flags': [], 'head': 0, 'descriptors': []}), ({'rows': 1, 'width': 3, 'b': 6, 'src': 105, 'dst': 505, 'sp': 27, 'dp': 37, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 18, 'source_start': 165, 'destination_start': 554, 'sources': [165], 'destinations': [554], 'descriptor_addresses': [905], 'next_pointers': [0], 'terminal_flags': [True], 'head': 905, 'descriptors': [[165, 554, 18, 0, True]]}), ({'rows': 2, 'width': 4, 'b': 6, 'src': 105, 'dst': 505, 'sp': 33, 'dp': 43, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 24, 'source_start': 177, 'destination_start': 560, 'sources': [177, 210], 'destinations': [560, 603], 'descriptor_addresses': [905, 929], 'next_pointers': [929, 0], 'terminal_flags': [False, True], 'head': 905, 'descriptors': [[177, 560, 24, 929, False], [210, 603, 24, 0, True]]}), ({'rows': 3, 'width': 5, 'b': 6, 'src': 105, 'dst': 505, 'sp': 39, 'dp': 49, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 30, 'source_start': 189, 'destination_start': 566, 'sources': [189, 228, 267], 'destinations': [566, 615, 664], 'descriptor_addresses': [905, 929, 953], 'next_pointers': [929, 953, 0], 'terminal_flags': [False, False, True], 'head': 905, 'descriptors': [[189, 566, 30, 929, False], [228, 615, 30, 953, False], [267, 664, 30, 0, True]]}), ({'rows': 4, 'width': 6, 'b': 6, 'src': 105, 'dst': 505, 'sp': 45, 'dp': 55, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 36, 'source_start': 201, 'destination_start': 572, 'sources': [201, 246, 291, 336], 'destinations': [572, 627, 682, 737], 'descriptor_addresses': [905, 929, 953, 977], 'next_pointers': [929, 953, 977, 0], 'terminal_flags': [False, False, False, True], 'head': 905, 'descriptors': [[201, 572, 36, 929, False], [246, 627, 36, 953, False], [291, 682, 36, 977, False], [336, 737, 36, 0, True]]}), ({'rows': 5, 'width': 7, 'b': 6, 'src': 105, 'dst': 505, 'sp': 51, 'dp': 61, 'desc': 905, 'sx': 1, 'sy': 2, 'dx': 2, 'dy': 1}, {'copy_bytes': 42, 'source_start': 213, 'destination_start': 578, 'sources': [213, 264, 315, 366, 417], 'destinations': [578, 639, 700, 761, 822], 'descriptor_addresses': [905, 929, 953, 977, 1001], 'next_pointers': [929, 953, 977, 1001, 0], 'terminal_flags': [False, False, False, False, True], 'head': 905, 'descriptors': [[213, 578, 42, 929, False], [264, 639, 42, 953, False], [315, 700, 42, 977, False], [366, 761, 42, 1001, False], [417, 822, 42, 0, True]]})]}
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 destinations.

Each raster row copies a valid contiguous byte region from pitched source to pitched destination. Hardware descriptors hold absolute source, destination, length, next-pointer, and terminal flag; descriptors are 24 bytes and begin at a separate base. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access