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

N = 1
observations = []
def solve(p):
    p = dict(p)
    virtual_start = p["base"]+p["y"]*p["pitch"]+p["x"]*6
    first_page = virtual_start//16
    page_offset = virtual_start%16
    first_bytes = min(6,16-page_offset)
    remaining = 6
    first_physical = p["pages"][first_page%len(p["pages"])]*16+page_offset
    second_physical = p["pages"][(first_page+1)%len(p["pages"])]*16
    spans = [[first_physical,first_bytes]]+([[second_physical,remaining]] if remaining else [])
    destination_offsets = [0,first_bytes] if remaining else [0]
    byte_addresses = [a+i for a,count in spans for i in range(count)]
    return {'virtual_start': virtual_start, 'first_page': first_page, 'page_offset': page_offset, 'first_bytes': first_bytes, 'remaining': remaining, 'first_physical': first_physical, 'second_physical': second_physical, 'spans': spans, 'destination_offsets': destination_offsets, 'byte_addresses': byte_addresses}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'x': 0, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 13, 'first_page': 0, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 61, 'second_physical': 112, 'spans': [[61, 3], [112, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [61, 62, 63, 112, 113, 114]}), ({'w': 8, 'x': 1, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 68, 'first_page': 4, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 36, 'second_physical': 160, 'spans': [[36, 6]], 'destination_offsets': [0], 'byte_addresses': [36, 37, 38, 39, 40, 41]}), ({'w': 8, 'x': 2, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 123, 'first_page': 7, 'page_offset': 11, 'first_bytes': 5, 'remaining': 1, 'first_physical': 155, 'second_physical': 96, 'spans': [[155, 5], [96, 1]], 'destination_offsets': [0, 5], 'byte_addresses': [155, 156, 157, 158, 159, 96]}), ({'w': 8, 'x': 3, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 31, 'first_page': 1, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 127, 'second_physical': 16, 'spans': [[127, 1], [16, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [127, 16, 17, 18, 19, 20]}), ({'w': 8, 'x': 4, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 86, 'first_page': 5, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 166, 'second_physical': 64, 'spans': [[166, 6]], 'destination_offsets': [0], 'byte_addresses': [166, 167, 168, 169, 170, 171]}), ({'w': 8, 'x': 5, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 141, 'first_page': 8, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 109, 'second_physical': 176, 'spans': [[109, 3], [176, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [109, 110, 111, 176, 177, 178]})], 2: [({'w': 9, 'x': 0, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 26, 'first_page': 1, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 122, 'second_physical': 16, 'spans': [[122, 6]], 'destination_offsets': [0], 'byte_addresses': [122, 123, 124, 125, 126, 127]}), ({'w': 9, 'x': 1, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 87, 'first_page': 5, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 167, 'second_physical': 64, 'spans': [[167, 6]], 'destination_offsets': [0], 'byte_addresses': [167, 168, 169, 170, 171, 172]}), ({'w': 9, 'x': 2, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 148, 'first_page': 9, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 180, 'second_physical': 80, 'spans': [[180, 6]], 'destination_offsets': [0], 'byte_addresses': [180, 181, 182, 183, 184, 185]}), ({'w': 9, 'x': 3, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 44, 'first_page': 2, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 28, 'second_physical': 128, 'spans': [[28, 4], [128, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [28, 29, 30, 31, 128, 129]}), ({'w': 9, 'x': 4, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 105, 'first_page': 6, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 73, 'second_physical': 144, 'spans': [[73, 6]], 'destination_offsets': [0], 'byte_addresses': [73, 74, 75, 76, 77, 78]}), ({'w': 9, 'x': 5, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 166, 'first_page': 10, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 86, 'second_physical': 192, 'spans': [[86, 6]], 'destination_offsets': [0], 'byte_addresses': [86, 87, 88, 89, 90, 91]})], 3: [({'w': 10, 'x': 0, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 39, 'first_page': 2, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 23, 'second_physical': 128, 'spans': [[23, 6]], 'destination_offsets': [0], 'byte_addresses': [23, 24, 25, 26, 27, 28]}), ({'w': 10, 'x': 1, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 106, 'first_page': 6, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 74, 'second_physical': 144, 'spans': [[74, 6]], 'destination_offsets': [0], 'byte_addresses': [74, 75, 76, 77, 78, 79]}), ({'w': 10, 'x': 2, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 173, 'first_page': 10, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 93, 'second_physical': 192, 'spans': [[93, 3], [192, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [93, 94, 95, 192, 193, 194]}), ({'w': 10, 'x': 3, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 57, 'first_page': 3, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 137, 'second_physical': 32, 'spans': [[137, 6]], 'destination_offsets': [0], 'byte_addresses': [137, 138, 139, 140, 141, 142]}), ({'w': 10, 'x': 4, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 124, 'first_page': 7, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 156, 'second_physical': 96, 'spans': [[156, 4], [96, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [156, 157, 158, 159, 96, 97]}), ({'w': 10, 'x': 5, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 191, 'first_page': 11, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 207, 'second_physical': 224, 'spans': [[207, 1], [224, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [207, 224, 225, 226, 227, 228]})], 4: [({'w': 11, 'x': 0, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 52, 'first_page': 3, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 132, 'second_physical': 32, 'spans': [[132, 6]], 'destination_offsets': [0], 'byte_addresses': [132, 133, 134, 135, 136, 137]}), ({'w': 11, 'x': 1, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 125, 'first_page': 7, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 157, 'second_physical': 96, 'spans': [[157, 3], [96, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [157, 158, 159, 96, 97, 98]}), ({'w': 11, 'x': 2, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 198, 'first_page': 12, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 230, 'second_physical': 208, 'spans': [[230, 6]], 'destination_offsets': [0], 'byte_addresses': [230, 231, 232, 233, 234, 235]}), ({'w': 11, 'x': 3, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 70, 'first_page': 4, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 38, 'second_physical': 160, 'spans': [[38, 6]], 'destination_offsets': [0], 'byte_addresses': [38, 39, 40, 41, 42, 43]}), ({'w': 11, 'x': 4, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 143, 'first_page': 8, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 111, 'second_physical': 176, 'spans': [[111, 1], [176, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [111, 176, 177, 178, 179, 180]}), ({'w': 11, 'x': 5, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 216, 'first_page': 13, 'page_offset': 8, 'first_bytes': 6, 'remaining': 0, 'first_physical': 216, 'second_physical': 240, 'spans': [[216, 6]], 'destination_offsets': [0], 'byte_addresses': [216, 217, 218, 219, 220, 221]})], 5: [({'w': 12, 'x': 0, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 65, 'first_page': 4, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 33, 'second_physical': 160, 'spans': [[33, 6]], 'destination_offsets': [0], 'byte_addresses': [33, 34, 35, 36, 37, 38]}), ({'w': 12, 'x': 1, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 144, 'first_page': 9, 'page_offset': 0, 'first_bytes': 6, 'remaining': 0, 'first_physical': 176, 'second_physical': 80, 'spans': [[176, 6]], 'destination_offsets': [0], 'byte_addresses': [176, 177, 178, 179, 180, 181]}), ({'w': 12, 'x': 2, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 223, 'first_page': 13, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 223, 'second_physical': 240, 'spans': [[223, 1], [240, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [223, 240, 241, 242, 243, 244]}), ({'w': 12, 'x': 3, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 83, 'first_page': 5, 'page_offset': 3, 'first_bytes': 6, 'remaining': 0, 'first_physical': 163, 'second_physical': 64, 'spans': [[163, 6]], 'destination_offsets': [0], 'byte_addresses': [163, 164, 165, 166, 167, 168]}), ({'w': 12, 'x': 4, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 162, 'first_page': 10, 'page_offset': 2, 'first_bytes': 6, 'remaining': 0, 'first_physical': 82, 'second_physical': 192, 'spans': [[82, 6]], 'destination_offsets': [0], 'byte_addresses': [82, 83, 84, 85, 86, 87]}), ({'w': 12, 'x': 5, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 241, 'first_page': 15, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 257, 'second_physical': 272, 'spans': [[257, 6]], 'destination_offsets': [0], 'byte_addresses': [257, 258, 259, 260, 261, 262]})]}
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)
    virtual_start = p["base"]+p["y"]*p["pitch"]+p["x"]*6
    first_page = virtual_start//16
    page_offset = virtual_start%16
    first_bytes = min(6,16-page_offset)
    remaining = max(0,first_bytes-6)
    first_physical = p["pages"][first_page%len(p["pages"])]*16+page_offset
    second_physical = p["pages"][(first_page+1)%len(p["pages"])]*16
    spans = [[first_physical,first_bytes]]+([[second_physical,remaining]] if remaining else [])
    destination_offsets = [0,first_bytes] if remaining else [0]
    byte_addresses = [a+i for a,count in spans for i in range(count)]
    return {'virtual_start': virtual_start, 'first_page': first_page, 'page_offset': page_offset, 'first_bytes': first_bytes, 'remaining': remaining, 'first_physical': first_physical, 'second_physical': second_physical, 'spans': spans, 'destination_offsets': destination_offsets, 'byte_addresses': byte_addresses}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'x': 0, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 13, 'first_page': 0, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 61, 'second_physical': 112, 'spans': [[61, 3], [112, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [61, 62, 63, 112, 113, 114]}), ({'w': 8, 'x': 1, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 68, 'first_page': 4, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 36, 'second_physical': 160, 'spans': [[36, 6]], 'destination_offsets': [0], 'byte_addresses': [36, 37, 38, 39, 40, 41]}), ({'w': 8, 'x': 2, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 123, 'first_page': 7, 'page_offset': 11, 'first_bytes': 5, 'remaining': 1, 'first_physical': 155, 'second_physical': 96, 'spans': [[155, 5], [96, 1]], 'destination_offsets': [0, 5], 'byte_addresses': [155, 156, 157, 158, 159, 96]}), ({'w': 8, 'x': 3, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 31, 'first_page': 1, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 127, 'second_physical': 16, 'spans': [[127, 1], [16, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [127, 16, 17, 18, 19, 20]}), ({'w': 8, 'x': 4, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 86, 'first_page': 5, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 166, 'second_physical': 64, 'spans': [[166, 6]], 'destination_offsets': [0], 'byte_addresses': [166, 167, 168, 169, 170, 171]}), ({'w': 8, 'x': 5, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 141, 'first_page': 8, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 109, 'second_physical': 176, 'spans': [[109, 3], [176, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [109, 110, 111, 176, 177, 178]})], 2: [({'w': 9, 'x': 0, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 26, 'first_page': 1, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 122, 'second_physical': 16, 'spans': [[122, 6]], 'destination_offsets': [0], 'byte_addresses': [122, 123, 124, 125, 126, 127]}), ({'w': 9, 'x': 1, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 87, 'first_page': 5, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 167, 'second_physical': 64, 'spans': [[167, 6]], 'destination_offsets': [0], 'byte_addresses': [167, 168, 169, 170, 171, 172]}), ({'w': 9, 'x': 2, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 148, 'first_page': 9, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 180, 'second_physical': 80, 'spans': [[180, 6]], 'destination_offsets': [0], 'byte_addresses': [180, 181, 182, 183, 184, 185]}), ({'w': 9, 'x': 3, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 44, 'first_page': 2, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 28, 'second_physical': 128, 'spans': [[28, 4], [128, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [28, 29, 30, 31, 128, 129]}), ({'w': 9, 'x': 4, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 105, 'first_page': 6, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 73, 'second_physical': 144, 'spans': [[73, 6]], 'destination_offsets': [0], 'byte_addresses': [73, 74, 75, 76, 77, 78]}), ({'w': 9, 'x': 5, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 166, 'first_page': 10, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 86, 'second_physical': 192, 'spans': [[86, 6]], 'destination_offsets': [0], 'byte_addresses': [86, 87, 88, 89, 90, 91]})], 3: [({'w': 10, 'x': 0, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 39, 'first_page': 2, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 23, 'second_physical': 128, 'spans': [[23, 6]], 'destination_offsets': [0], 'byte_addresses': [23, 24, 25, 26, 27, 28]}), ({'w': 10, 'x': 1, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 106, 'first_page': 6, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 74, 'second_physical': 144, 'spans': [[74, 6]], 'destination_offsets': [0], 'byte_addresses': [74, 75, 76, 77, 78, 79]}), ({'w': 10, 'x': 2, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 173, 'first_page': 10, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 93, 'second_physical': 192, 'spans': [[93, 3], [192, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [93, 94, 95, 192, 193, 194]}), ({'w': 10, 'x': 3, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 57, 'first_page': 3, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 137, 'second_physical': 32, 'spans': [[137, 6]], 'destination_offsets': [0], 'byte_addresses': [137, 138, 139, 140, 141, 142]}), ({'w': 10, 'x': 4, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 124, 'first_page': 7, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 156, 'second_physical': 96, 'spans': [[156, 4], [96, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [156, 157, 158, 159, 96, 97]}), ({'w': 10, 'x': 5, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 191, 'first_page': 11, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 207, 'second_physical': 224, 'spans': [[207, 1], [224, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [207, 224, 225, 226, 227, 228]})], 4: [({'w': 11, 'x': 0, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 52, 'first_page': 3, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 132, 'second_physical': 32, 'spans': [[132, 6]], 'destination_offsets': [0], 'byte_addresses': [132, 133, 134, 135, 136, 137]}), ({'w': 11, 'x': 1, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 125, 'first_page': 7, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 157, 'second_physical': 96, 'spans': [[157, 3], [96, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [157, 158, 159, 96, 97, 98]}), ({'w': 11, 'x': 2, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 198, 'first_page': 12, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 230, 'second_physical': 208, 'spans': [[230, 6]], 'destination_offsets': [0], 'byte_addresses': [230, 231, 232, 233, 234, 235]}), ({'w': 11, 'x': 3, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 70, 'first_page': 4, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 38, 'second_physical': 160, 'spans': [[38, 6]], 'destination_offsets': [0], 'byte_addresses': [38, 39, 40, 41, 42, 43]}), ({'w': 11, 'x': 4, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 143, 'first_page': 8, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 111, 'second_physical': 176, 'spans': [[111, 1], [176, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [111, 176, 177, 178, 179, 180]}), ({'w': 11, 'x': 5, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 216, 'first_page': 13, 'page_offset': 8, 'first_bytes': 6, 'remaining': 0, 'first_physical': 216, 'second_physical': 240, 'spans': [[216, 6]], 'destination_offsets': [0], 'byte_addresses': [216, 217, 218, 219, 220, 221]})], 5: [({'w': 12, 'x': 0, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 65, 'first_page': 4, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 33, 'second_physical': 160, 'spans': [[33, 6]], 'destination_offsets': [0], 'byte_addresses': [33, 34, 35, 36, 37, 38]}), ({'w': 12, 'x': 1, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 144, 'first_page': 9, 'page_offset': 0, 'first_bytes': 6, 'remaining': 0, 'first_physical': 176, 'second_physical': 80, 'spans': [[176, 6]], 'destination_offsets': [0], 'byte_addresses': [176, 177, 178, 179, 180, 181]}), ({'w': 12, 'x': 2, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 223, 'first_page': 13, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 223, 'second_physical': 240, 'spans': [[223, 1], [240, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [223, 240, 241, 242, 243, 244]}), ({'w': 12, 'x': 3, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 83, 'first_page': 5, 'page_offset': 3, 'first_bytes': 6, 'remaining': 0, 'first_physical': 163, 'second_physical': 64, 'spans': [[163, 6]], 'destination_offsets': [0], 'byte_addresses': [163, 164, 165, 166, 167, 168]}), ({'w': 12, 'x': 4, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 162, 'first_page': 10, 'page_offset': 2, 'first_bytes': 6, 'remaining': 0, 'first_physical': 82, 'second_physical': 192, 'spans': [[82, 6]], 'destination_offsets': [0], 'byte_addresses': [82, 83, 84, 85, 86, 87]}), ({'w': 12, 'x': 5, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 241, 'first_page': 15, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 257, 'second_physical': 272, 'spans': [[257, 6]], 'destination_offsets': [0], 'byte_addresses': [257, 258, 259, 260, 261, 262]})]}
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 remaining.

Raster texels contain six bytes and may straddle 16-byte virtual pages. A virtual byte span maps through a noncontiguous physical page directory; output contains source spans and offsets for reassembling one texel. 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)
    virtual_start = p["base"]+p["y"]*p["pitch"]+p["x"]*6
    first_page = virtual_start//16
    page_offset = virtual_start%16
    first_bytes = min(6,16-page_offset)
    remaining = 6-first_bytes
    first_physical = first_page*16+page_offset
    second_physical = p["pages"][(first_page+1)%len(p["pages"])]*16
    spans = [[first_physical,first_bytes]]+([[second_physical,remaining]] if remaining else [])
    destination_offsets = [0,first_bytes] if remaining else [0]
    byte_addresses = [a+i for a,count in spans for i in range(count)]
    return {'virtual_start': virtual_start, 'first_page': first_page, 'page_offset': page_offset, 'first_bytes': first_bytes, 'remaining': remaining, 'first_physical': first_physical, 'second_physical': second_physical, 'spans': spans, 'destination_offsets': destination_offsets, 'byte_addresses': byte_addresses}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'x': 0, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 13, 'first_page': 0, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 61, 'second_physical': 112, 'spans': [[61, 3], [112, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [61, 62, 63, 112, 113, 114]}), ({'w': 8, 'x': 1, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 68, 'first_page': 4, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 36, 'second_physical': 160, 'spans': [[36, 6]], 'destination_offsets': [0], 'byte_addresses': [36, 37, 38, 39, 40, 41]}), ({'w': 8, 'x': 2, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 123, 'first_page': 7, 'page_offset': 11, 'first_bytes': 5, 'remaining': 1, 'first_physical': 155, 'second_physical': 96, 'spans': [[155, 5], [96, 1]], 'destination_offsets': [0, 5], 'byte_addresses': [155, 156, 157, 158, 159, 96]}), ({'w': 8, 'x': 3, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 31, 'first_page': 1, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 127, 'second_physical': 16, 'spans': [[127, 1], [16, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [127, 16, 17, 18, 19, 20]}), ({'w': 8, 'x': 4, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 86, 'first_page': 5, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 166, 'second_physical': 64, 'spans': [[166, 6]], 'destination_offsets': [0], 'byte_addresses': [166, 167, 168, 169, 170, 171]}), ({'w': 8, 'x': 5, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 141, 'first_page': 8, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 109, 'second_physical': 176, 'spans': [[109, 3], [176, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [109, 110, 111, 176, 177, 178]})], 2: [({'w': 9, 'x': 0, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 26, 'first_page': 1, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 122, 'second_physical': 16, 'spans': [[122, 6]], 'destination_offsets': [0], 'byte_addresses': [122, 123, 124, 125, 126, 127]}), ({'w': 9, 'x': 1, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 87, 'first_page': 5, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 167, 'second_physical': 64, 'spans': [[167, 6]], 'destination_offsets': [0], 'byte_addresses': [167, 168, 169, 170, 171, 172]}), ({'w': 9, 'x': 2, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 148, 'first_page': 9, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 180, 'second_physical': 80, 'spans': [[180, 6]], 'destination_offsets': [0], 'byte_addresses': [180, 181, 182, 183, 184, 185]}), ({'w': 9, 'x': 3, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 44, 'first_page': 2, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 28, 'second_physical': 128, 'spans': [[28, 4], [128, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [28, 29, 30, 31, 128, 129]}), ({'w': 9, 'x': 4, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 105, 'first_page': 6, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 73, 'second_physical': 144, 'spans': [[73, 6]], 'destination_offsets': [0], 'byte_addresses': [73, 74, 75, 76, 77, 78]}), ({'w': 9, 'x': 5, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 166, 'first_page': 10, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 86, 'second_physical': 192, 'spans': [[86, 6]], 'destination_offsets': [0], 'byte_addresses': [86, 87, 88, 89, 90, 91]})], 3: [({'w': 10, 'x': 0, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 39, 'first_page': 2, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 23, 'second_physical': 128, 'spans': [[23, 6]], 'destination_offsets': [0], 'byte_addresses': [23, 24, 25, 26, 27, 28]}), ({'w': 10, 'x': 1, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 106, 'first_page': 6, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 74, 'second_physical': 144, 'spans': [[74, 6]], 'destination_offsets': [0], 'byte_addresses': [74, 75, 76, 77, 78, 79]}), ({'w': 10, 'x': 2, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 173, 'first_page': 10, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 93, 'second_physical': 192, 'spans': [[93, 3], [192, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [93, 94, 95, 192, 193, 194]}), ({'w': 10, 'x': 3, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 57, 'first_page': 3, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 137, 'second_physical': 32, 'spans': [[137, 6]], 'destination_offsets': [0], 'byte_addresses': [137, 138, 139, 140, 141, 142]}), ({'w': 10, 'x': 4, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 124, 'first_page': 7, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 156, 'second_physical': 96, 'spans': [[156, 4], [96, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [156, 157, 158, 159, 96, 97]}), ({'w': 10, 'x': 5, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 191, 'first_page': 11, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 207, 'second_physical': 224, 'spans': [[207, 1], [224, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [207, 224, 225, 226, 227, 228]})], 4: [({'w': 11, 'x': 0, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 52, 'first_page': 3, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 132, 'second_physical': 32, 'spans': [[132, 6]], 'destination_offsets': [0], 'byte_addresses': [132, 133, 134, 135, 136, 137]}), ({'w': 11, 'x': 1, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 125, 'first_page': 7, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 157, 'second_physical': 96, 'spans': [[157, 3], [96, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [157, 158, 159, 96, 97, 98]}), ({'w': 11, 'x': 2, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 198, 'first_page': 12, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 230, 'second_physical': 208, 'spans': [[230, 6]], 'destination_offsets': [0], 'byte_addresses': [230, 231, 232, 233, 234, 235]}), ({'w': 11, 'x': 3, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 70, 'first_page': 4, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 38, 'second_physical': 160, 'spans': [[38, 6]], 'destination_offsets': [0], 'byte_addresses': [38, 39, 40, 41, 42, 43]}), ({'w': 11, 'x': 4, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 143, 'first_page': 8, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 111, 'second_physical': 176, 'spans': [[111, 1], [176, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [111, 176, 177, 178, 179, 180]}), ({'w': 11, 'x': 5, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 216, 'first_page': 13, 'page_offset': 8, 'first_bytes': 6, 'remaining': 0, 'first_physical': 216, 'second_physical': 240, 'spans': [[216, 6]], 'destination_offsets': [0], 'byte_addresses': [216, 217, 218, 219, 220, 221]})], 5: [({'w': 12, 'x': 0, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 65, 'first_page': 4, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 33, 'second_physical': 160, 'spans': [[33, 6]], 'destination_offsets': [0], 'byte_addresses': [33, 34, 35, 36, 37, 38]}), ({'w': 12, 'x': 1, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 144, 'first_page': 9, 'page_offset': 0, 'first_bytes': 6, 'remaining': 0, 'first_physical': 176, 'second_physical': 80, 'spans': [[176, 6]], 'destination_offsets': [0], 'byte_addresses': [176, 177, 178, 179, 180, 181]}), ({'w': 12, 'x': 2, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 223, 'first_page': 13, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 223, 'second_physical': 240, 'spans': [[223, 1], [240, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [223, 240, 241, 242, 243, 244]}), ({'w': 12, 'x': 3, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 83, 'first_page': 5, 'page_offset': 3, 'first_bytes': 6, 'remaining': 0, 'first_physical': 163, 'second_physical': 64, 'spans': [[163, 6]], 'destination_offsets': [0], 'byte_addresses': [163, 164, 165, 166, 167, 168]}), ({'w': 12, 'x': 4, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 162, 'first_page': 10, 'page_offset': 2, 'first_bytes': 6, 'remaining': 0, 'first_physical': 82, 'second_physical': 192, 'spans': [[82, 6]], 'destination_offsets': [0], 'byte_addresses': [82, 83, 84, 85, 86, 87]}), ({'w': 12, 'x': 5, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 241, 'first_page': 15, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 257, 'second_physical': 272, 'spans': [[257, 6]], 'destination_offsets': [0], 'byte_addresses': [257, 258, 259, 260, 261, 262]})]}
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)
    virtual_start = p["base"]+p["y"]*p["pitch"]+p["x"]*6
    first_page = virtual_start//16
    page_offset = virtual_start%16
    first_bytes = min(6,16-page_offset)
    remaining = 6-first_bytes
    first_physical = p["pages"][first_page%len(p["pages"])]+page_offset
    second_physical = p["pages"][(first_page+1)%len(p["pages"])]*16
    spans = [[first_physical,first_bytes]]+([[second_physical,remaining]] if remaining else [])
    destination_offsets = [0,first_bytes] if remaining else [0]
    byte_addresses = [a+i for a,count in spans for i in range(count)]
    return {'virtual_start': virtual_start, 'first_page': first_page, 'page_offset': page_offset, 'first_bytes': first_bytes, 'remaining': remaining, 'first_physical': first_physical, 'second_physical': second_physical, 'spans': spans, 'destination_offsets': destination_offsets, 'byte_addresses': byte_addresses}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'x': 0, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 13, 'first_page': 0, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 61, 'second_physical': 112, 'spans': [[61, 3], [112, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [61, 62, 63, 112, 113, 114]}), ({'w': 8, 'x': 1, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 68, 'first_page': 4, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 36, 'second_physical': 160, 'spans': [[36, 6]], 'destination_offsets': [0], 'byte_addresses': [36, 37, 38, 39, 40, 41]}), ({'w': 8, 'x': 2, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 123, 'first_page': 7, 'page_offset': 11, 'first_bytes': 5, 'remaining': 1, 'first_physical': 155, 'second_physical': 96, 'spans': [[155, 5], [96, 1]], 'destination_offsets': [0, 5], 'byte_addresses': [155, 156, 157, 158, 159, 96]}), ({'w': 8, 'x': 3, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 31, 'first_page': 1, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 127, 'second_physical': 16, 'spans': [[127, 1], [16, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [127, 16, 17, 18, 19, 20]}), ({'w': 8, 'x': 4, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 86, 'first_page': 5, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 166, 'second_physical': 64, 'spans': [[166, 6]], 'destination_offsets': [0], 'byte_addresses': [166, 167, 168, 169, 170, 171]}), ({'w': 8, 'x': 5, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 141, 'first_page': 8, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 109, 'second_physical': 176, 'spans': [[109, 3], [176, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [109, 110, 111, 176, 177, 178]})], 2: [({'w': 9, 'x': 0, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 26, 'first_page': 1, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 122, 'second_physical': 16, 'spans': [[122, 6]], 'destination_offsets': [0], 'byte_addresses': [122, 123, 124, 125, 126, 127]}), ({'w': 9, 'x': 1, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 87, 'first_page': 5, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 167, 'second_physical': 64, 'spans': [[167, 6]], 'destination_offsets': [0], 'byte_addresses': [167, 168, 169, 170, 171, 172]}), ({'w': 9, 'x': 2, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 148, 'first_page': 9, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 180, 'second_physical': 80, 'spans': [[180, 6]], 'destination_offsets': [0], 'byte_addresses': [180, 181, 182, 183, 184, 185]}), ({'w': 9, 'x': 3, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 44, 'first_page': 2, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 28, 'second_physical': 128, 'spans': [[28, 4], [128, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [28, 29, 30, 31, 128, 129]}), ({'w': 9, 'x': 4, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 105, 'first_page': 6, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 73, 'second_physical': 144, 'spans': [[73, 6]], 'destination_offsets': [0], 'byte_addresses': [73, 74, 75, 76, 77, 78]}), ({'w': 9, 'x': 5, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 166, 'first_page': 10, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 86, 'second_physical': 192, 'spans': [[86, 6]], 'destination_offsets': [0], 'byte_addresses': [86, 87, 88, 89, 90, 91]})], 3: [({'w': 10, 'x': 0, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 39, 'first_page': 2, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 23, 'second_physical': 128, 'spans': [[23, 6]], 'destination_offsets': [0], 'byte_addresses': [23, 24, 25, 26, 27, 28]}), ({'w': 10, 'x': 1, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 106, 'first_page': 6, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 74, 'second_physical': 144, 'spans': [[74, 6]], 'destination_offsets': [0], 'byte_addresses': [74, 75, 76, 77, 78, 79]}), ({'w': 10, 'x': 2, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 173, 'first_page': 10, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 93, 'second_physical': 192, 'spans': [[93, 3], [192, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [93, 94, 95, 192, 193, 194]}), ({'w': 10, 'x': 3, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 57, 'first_page': 3, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 137, 'second_physical': 32, 'spans': [[137, 6]], 'destination_offsets': [0], 'byte_addresses': [137, 138, 139, 140, 141, 142]}), ({'w': 10, 'x': 4, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 124, 'first_page': 7, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 156, 'second_physical': 96, 'spans': [[156, 4], [96, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [156, 157, 158, 159, 96, 97]}), ({'w': 10, 'x': 5, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 191, 'first_page': 11, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 207, 'second_physical': 224, 'spans': [[207, 1], [224, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [207, 224, 225, 226, 227, 228]})], 4: [({'w': 11, 'x': 0, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 52, 'first_page': 3, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 132, 'second_physical': 32, 'spans': [[132, 6]], 'destination_offsets': [0], 'byte_addresses': [132, 133, 134, 135, 136, 137]}), ({'w': 11, 'x': 1, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 125, 'first_page': 7, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 157, 'second_physical': 96, 'spans': [[157, 3], [96, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [157, 158, 159, 96, 97, 98]}), ({'w': 11, 'x': 2, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 198, 'first_page': 12, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 230, 'second_physical': 208, 'spans': [[230, 6]], 'destination_offsets': [0], 'byte_addresses': [230, 231, 232, 233, 234, 235]}), ({'w': 11, 'x': 3, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 70, 'first_page': 4, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 38, 'second_physical': 160, 'spans': [[38, 6]], 'destination_offsets': [0], 'byte_addresses': [38, 39, 40, 41, 42, 43]}), ({'w': 11, 'x': 4, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 143, 'first_page': 8, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 111, 'second_physical': 176, 'spans': [[111, 1], [176, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [111, 176, 177, 178, 179, 180]}), ({'w': 11, 'x': 5, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 216, 'first_page': 13, 'page_offset': 8, 'first_bytes': 6, 'remaining': 0, 'first_physical': 216, 'second_physical': 240, 'spans': [[216, 6]], 'destination_offsets': [0], 'byte_addresses': [216, 217, 218, 219, 220, 221]})], 5: [({'w': 12, 'x': 0, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 65, 'first_page': 4, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 33, 'second_physical': 160, 'spans': [[33, 6]], 'destination_offsets': [0], 'byte_addresses': [33, 34, 35, 36, 37, 38]}), ({'w': 12, 'x': 1, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 144, 'first_page': 9, 'page_offset': 0, 'first_bytes': 6, 'remaining': 0, 'first_physical': 176, 'second_physical': 80, 'spans': [[176, 6]], 'destination_offsets': [0], 'byte_addresses': [176, 177, 178, 179, 180, 181]}), ({'w': 12, 'x': 2, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 223, 'first_page': 13, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 223, 'second_physical': 240, 'spans': [[223, 1], [240, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [223, 240, 241, 242, 243, 244]}), ({'w': 12, 'x': 3, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 83, 'first_page': 5, 'page_offset': 3, 'first_bytes': 6, 'remaining': 0, 'first_physical': 163, 'second_physical': 64, 'spans': [[163, 6]], 'destination_offsets': [0], 'byte_addresses': [163, 164, 165, 166, 167, 168]}), ({'w': 12, 'x': 4, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 162, 'first_page': 10, 'page_offset': 2, 'first_bytes': 6, 'remaining': 0, 'first_physical': 82, 'second_physical': 192, 'spans': [[82, 6]], 'destination_offsets': [0], 'byte_addresses': [82, 83, 84, 85, 86, 87]}), ({'w': 12, 'x': 5, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 241, 'first_page': 15, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 257, 'second_physical': 272, 'spans': [[257, 6]], 'destination_offsets': [0], 'byte_addresses': [257, 258, 259, 260, 261, 262]})]}
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 first_physical.

Raster texels contain six bytes and may straddle 16-byte virtual pages. A virtual byte span maps through a noncontiguous physical page directory; output contains source spans and offsets for reassembling one texel. 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)
    virtual_start = p["base"]+p["y"]*p["pitch"]+p["x"]*6
    first_page = virtual_start//16
    page_offset = virtual_start%16
    first_bytes = min(6,16-page_offset)
    remaining = 6-first_bytes
    first_physical = p["pages"][first_page%len(p["pages"])]*16+page_offset
    second_physical = first_physical+first_bytes
    spans = [[first_physical,first_bytes]]+([[second_physical,remaining]] if remaining else [])
    destination_offsets = [0,first_bytes] if remaining else [0]
    byte_addresses = [a+i for a,count in spans for i in range(count)]
    return {'virtual_start': virtual_start, 'first_page': first_page, 'page_offset': page_offset, 'first_bytes': first_bytes, 'remaining': remaining, 'first_physical': first_physical, 'second_physical': second_physical, 'spans': spans, 'destination_offsets': destination_offsets, 'byte_addresses': byte_addresses}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'x': 0, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 13, 'first_page': 0, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 61, 'second_physical': 112, 'spans': [[61, 3], [112, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [61, 62, 63, 112, 113, 114]}), ({'w': 8, 'x': 1, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 68, 'first_page': 4, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 36, 'second_physical': 160, 'spans': [[36, 6]], 'destination_offsets': [0], 'byte_addresses': [36, 37, 38, 39, 40, 41]}), ({'w': 8, 'x': 2, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 123, 'first_page': 7, 'page_offset': 11, 'first_bytes': 5, 'remaining': 1, 'first_physical': 155, 'second_physical': 96, 'spans': [[155, 5], [96, 1]], 'destination_offsets': [0, 5], 'byte_addresses': [155, 156, 157, 158, 159, 96]}), ({'w': 8, 'x': 3, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 31, 'first_page': 1, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 127, 'second_physical': 16, 'spans': [[127, 1], [16, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [127, 16, 17, 18, 19, 20]}), ({'w': 8, 'x': 4, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 86, 'first_page': 5, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 166, 'second_physical': 64, 'spans': [[166, 6]], 'destination_offsets': [0], 'byte_addresses': [166, 167, 168, 169, 170, 171]}), ({'w': 8, 'x': 5, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 141, 'first_page': 8, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 109, 'second_physical': 176, 'spans': [[109, 3], [176, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [109, 110, 111, 176, 177, 178]})], 2: [({'w': 9, 'x': 0, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 26, 'first_page': 1, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 122, 'second_physical': 16, 'spans': [[122, 6]], 'destination_offsets': [0], 'byte_addresses': [122, 123, 124, 125, 126, 127]}), ({'w': 9, 'x': 1, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 87, 'first_page': 5, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 167, 'second_physical': 64, 'spans': [[167, 6]], 'destination_offsets': [0], 'byte_addresses': [167, 168, 169, 170, 171, 172]}), ({'w': 9, 'x': 2, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 148, 'first_page': 9, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 180, 'second_physical': 80, 'spans': [[180, 6]], 'destination_offsets': [0], 'byte_addresses': [180, 181, 182, 183, 184, 185]}), ({'w': 9, 'x': 3, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 44, 'first_page': 2, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 28, 'second_physical': 128, 'spans': [[28, 4], [128, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [28, 29, 30, 31, 128, 129]}), ({'w': 9, 'x': 4, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 105, 'first_page': 6, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 73, 'second_physical': 144, 'spans': [[73, 6]], 'destination_offsets': [0], 'byte_addresses': [73, 74, 75, 76, 77, 78]}), ({'w': 9, 'x': 5, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 166, 'first_page': 10, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 86, 'second_physical': 192, 'spans': [[86, 6]], 'destination_offsets': [0], 'byte_addresses': [86, 87, 88, 89, 90, 91]})], 3: [({'w': 10, 'x': 0, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 39, 'first_page': 2, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 23, 'second_physical': 128, 'spans': [[23, 6]], 'destination_offsets': [0], 'byte_addresses': [23, 24, 25, 26, 27, 28]}), ({'w': 10, 'x': 1, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 106, 'first_page': 6, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 74, 'second_physical': 144, 'spans': [[74, 6]], 'destination_offsets': [0], 'byte_addresses': [74, 75, 76, 77, 78, 79]}), ({'w': 10, 'x': 2, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 173, 'first_page': 10, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 93, 'second_physical': 192, 'spans': [[93, 3], [192, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [93, 94, 95, 192, 193, 194]}), ({'w': 10, 'x': 3, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 57, 'first_page': 3, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 137, 'second_physical': 32, 'spans': [[137, 6]], 'destination_offsets': [0], 'byte_addresses': [137, 138, 139, 140, 141, 142]}), ({'w': 10, 'x': 4, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 124, 'first_page': 7, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 156, 'second_physical': 96, 'spans': [[156, 4], [96, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [156, 157, 158, 159, 96, 97]}), ({'w': 10, 'x': 5, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 191, 'first_page': 11, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 207, 'second_physical': 224, 'spans': [[207, 1], [224, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [207, 224, 225, 226, 227, 228]})], 4: [({'w': 11, 'x': 0, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 52, 'first_page': 3, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 132, 'second_physical': 32, 'spans': [[132, 6]], 'destination_offsets': [0], 'byte_addresses': [132, 133, 134, 135, 136, 137]}), ({'w': 11, 'x': 1, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 125, 'first_page': 7, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 157, 'second_physical': 96, 'spans': [[157, 3], [96, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [157, 158, 159, 96, 97, 98]}), ({'w': 11, 'x': 2, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 198, 'first_page': 12, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 230, 'second_physical': 208, 'spans': [[230, 6]], 'destination_offsets': [0], 'byte_addresses': [230, 231, 232, 233, 234, 235]}), ({'w': 11, 'x': 3, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 70, 'first_page': 4, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 38, 'second_physical': 160, 'spans': [[38, 6]], 'destination_offsets': [0], 'byte_addresses': [38, 39, 40, 41, 42, 43]}), ({'w': 11, 'x': 4, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 143, 'first_page': 8, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 111, 'second_physical': 176, 'spans': [[111, 1], [176, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [111, 176, 177, 178, 179, 180]}), ({'w': 11, 'x': 5, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 216, 'first_page': 13, 'page_offset': 8, 'first_bytes': 6, 'remaining': 0, 'first_physical': 216, 'second_physical': 240, 'spans': [[216, 6]], 'destination_offsets': [0], 'byte_addresses': [216, 217, 218, 219, 220, 221]})], 5: [({'w': 12, 'x': 0, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 65, 'first_page': 4, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 33, 'second_physical': 160, 'spans': [[33, 6]], 'destination_offsets': [0], 'byte_addresses': [33, 34, 35, 36, 37, 38]}), ({'w': 12, 'x': 1, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 144, 'first_page': 9, 'page_offset': 0, 'first_bytes': 6, 'remaining': 0, 'first_physical': 176, 'second_physical': 80, 'spans': [[176, 6]], 'destination_offsets': [0], 'byte_addresses': [176, 177, 178, 179, 180, 181]}), ({'w': 12, 'x': 2, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 223, 'first_page': 13, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 223, 'second_physical': 240, 'spans': [[223, 1], [240, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [223, 240, 241, 242, 243, 244]}), ({'w': 12, 'x': 3, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 83, 'first_page': 5, 'page_offset': 3, 'first_bytes': 6, 'remaining': 0, 'first_physical': 163, 'second_physical': 64, 'spans': [[163, 6]], 'destination_offsets': [0], 'byte_addresses': [163, 164, 165, 166, 167, 168]}), ({'w': 12, 'x': 4, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 162, 'first_page': 10, 'page_offset': 2, 'first_bytes': 6, 'remaining': 0, 'first_physical': 82, 'second_physical': 192, 'spans': [[82, 6]], 'destination_offsets': [0], 'byte_addresses': [82, 83, 84, 85, 86, 87]}), ({'w': 12, 'x': 5, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 241, 'first_page': 15, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 257, 'second_physical': 272, 'spans': [[257, 6]], 'destination_offsets': [0], 'byte_addresses': [257, 258, 259, 260, 261, 262]})]}
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)
    virtual_start = p["base"]+p["y"]*p["pitch"]+p["x"]*6
    first_page = virtual_start//16
    page_offset = virtual_start%16
    first_bytes = min(6,16-page_offset)
    remaining = 6-first_bytes
    first_physical = p["pages"][first_page%len(p["pages"])]*16+page_offset
    second_physical = p["pages"][first_page%len(p["pages"]) ]*16
    spans = [[first_physical,first_bytes]]+([[second_physical,remaining]] if remaining else [])
    destination_offsets = [0,first_bytes] if remaining else [0]
    byte_addresses = [a+i for a,count in spans for i in range(count)]
    return {'virtual_start': virtual_start, 'first_page': first_page, 'page_offset': page_offset, 'first_bytes': first_bytes, 'remaining': remaining, 'first_physical': first_physical, 'second_physical': second_physical, 'spans': spans, 'destination_offsets': destination_offsets, 'byte_addresses': byte_addresses}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 8, 'x': 0, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 13, 'first_page': 0, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 61, 'second_physical': 112, 'spans': [[61, 3], [112, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [61, 62, 63, 112, 113, 114]}), ({'w': 8, 'x': 1, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 68, 'first_page': 4, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 36, 'second_physical': 160, 'spans': [[36, 6]], 'destination_offsets': [0], 'byte_addresses': [36, 37, 38, 39, 40, 41]}), ({'w': 8, 'x': 2, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 123, 'first_page': 7, 'page_offset': 11, 'first_bytes': 5, 'remaining': 1, 'first_physical': 155, 'second_physical': 96, 'spans': [[155, 5], [96, 1]], 'destination_offsets': [0, 5], 'byte_addresses': [155, 156, 157, 158, 159, 96]}), ({'w': 8, 'x': 3, 'y': 0, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 31, 'first_page': 1, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 127, 'second_physical': 16, 'spans': [[127, 1], [16, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [127, 16, 17, 18, 19, 20]}), ({'w': 8, 'x': 4, 'y': 1, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 86, 'first_page': 5, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 166, 'second_physical': 64, 'spans': [[166, 6]], 'destination_offsets': [0], 'byte_addresses': [166, 167, 168, 169, 170, 171]}), ({'w': 8, 'x': 5, 'y': 2, 'pitch': 49, 'base': 13, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 141, 'first_page': 8, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 109, 'second_physical': 176, 'spans': [[109, 3], [176, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [109, 110, 111, 176, 177, 178]})], 2: [({'w': 9, 'x': 0, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 26, 'first_page': 1, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 122, 'second_physical': 16, 'spans': [[122, 6]], 'destination_offsets': [0], 'byte_addresses': [122, 123, 124, 125, 126, 127]}), ({'w': 9, 'x': 1, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 87, 'first_page': 5, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 167, 'second_physical': 64, 'spans': [[167, 6]], 'destination_offsets': [0], 'byte_addresses': [167, 168, 169, 170, 171, 172]}), ({'w': 9, 'x': 2, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 148, 'first_page': 9, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 180, 'second_physical': 80, 'spans': [[180, 6]], 'destination_offsets': [0], 'byte_addresses': [180, 181, 182, 183, 184, 185]}), ({'w': 9, 'x': 3, 'y': 0, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 44, 'first_page': 2, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 28, 'second_physical': 128, 'spans': [[28, 4], [128, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [28, 29, 30, 31, 128, 129]}), ({'w': 9, 'x': 4, 'y': 1, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 105, 'first_page': 6, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 73, 'second_physical': 144, 'spans': [[73, 6]], 'destination_offsets': [0], 'byte_addresses': [73, 74, 75, 76, 77, 78]}), ({'w': 9, 'x': 5, 'y': 2, 'pitch': 55, 'base': 26, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 166, 'first_page': 10, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 86, 'second_physical': 192, 'spans': [[86, 6]], 'destination_offsets': [0], 'byte_addresses': [86, 87, 88, 89, 90, 91]})], 3: [({'w': 10, 'x': 0, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 39, 'first_page': 2, 'page_offset': 7, 'first_bytes': 6, 'remaining': 0, 'first_physical': 23, 'second_physical': 128, 'spans': [[23, 6]], 'destination_offsets': [0], 'byte_addresses': [23, 24, 25, 26, 27, 28]}), ({'w': 10, 'x': 1, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 106, 'first_page': 6, 'page_offset': 10, 'first_bytes': 6, 'remaining': 0, 'first_physical': 74, 'second_physical': 144, 'spans': [[74, 6]], 'destination_offsets': [0], 'byte_addresses': [74, 75, 76, 77, 78, 79]}), ({'w': 10, 'x': 2, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 173, 'first_page': 10, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 93, 'second_physical': 192, 'spans': [[93, 3], [192, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [93, 94, 95, 192, 193, 194]}), ({'w': 10, 'x': 3, 'y': 0, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 57, 'first_page': 3, 'page_offset': 9, 'first_bytes': 6, 'remaining': 0, 'first_physical': 137, 'second_physical': 32, 'spans': [[137, 6]], 'destination_offsets': [0], 'byte_addresses': [137, 138, 139, 140, 141, 142]}), ({'w': 10, 'x': 4, 'y': 1, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 124, 'first_page': 7, 'page_offset': 12, 'first_bytes': 4, 'remaining': 2, 'first_physical': 156, 'second_physical': 96, 'spans': [[156, 4], [96, 2]], 'destination_offsets': [0, 4], 'byte_addresses': [156, 157, 158, 159, 96, 97]}), ({'w': 10, 'x': 5, 'y': 2, 'pitch': 61, 'base': 39, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 191, 'first_page': 11, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 207, 'second_physical': 224, 'spans': [[207, 1], [224, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [207, 224, 225, 226, 227, 228]})], 4: [({'w': 11, 'x': 0, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 52, 'first_page': 3, 'page_offset': 4, 'first_bytes': 6, 'remaining': 0, 'first_physical': 132, 'second_physical': 32, 'spans': [[132, 6]], 'destination_offsets': [0], 'byte_addresses': [132, 133, 134, 135, 136, 137]}), ({'w': 11, 'x': 1, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 125, 'first_page': 7, 'page_offset': 13, 'first_bytes': 3, 'remaining': 3, 'first_physical': 157, 'second_physical': 96, 'spans': [[157, 3], [96, 3]], 'destination_offsets': [0, 3], 'byte_addresses': [157, 158, 159, 96, 97, 98]}), ({'w': 11, 'x': 2, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 198, 'first_page': 12, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 230, 'second_physical': 208, 'spans': [[230, 6]], 'destination_offsets': [0], 'byte_addresses': [230, 231, 232, 233, 234, 235]}), ({'w': 11, 'x': 3, 'y': 0, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 70, 'first_page': 4, 'page_offset': 6, 'first_bytes': 6, 'remaining': 0, 'first_physical': 38, 'second_physical': 160, 'spans': [[38, 6]], 'destination_offsets': [0], 'byte_addresses': [38, 39, 40, 41, 42, 43]}), ({'w': 11, 'x': 4, 'y': 1, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 143, 'first_page': 8, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 111, 'second_physical': 176, 'spans': [[111, 1], [176, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [111, 176, 177, 178, 179, 180]}), ({'w': 11, 'x': 5, 'y': 2, 'pitch': 67, 'base': 52, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 216, 'first_page': 13, 'page_offset': 8, 'first_bytes': 6, 'remaining': 0, 'first_physical': 216, 'second_physical': 240, 'spans': [[216, 6]], 'destination_offsets': [0], 'byte_addresses': [216, 217, 218, 219, 220, 221]})], 5: [({'w': 12, 'x': 0, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 65, 'first_page': 4, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 33, 'second_physical': 160, 'spans': [[33, 6]], 'destination_offsets': [0], 'byte_addresses': [33, 34, 35, 36, 37, 38]}), ({'w': 12, 'x': 1, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 144, 'first_page': 9, 'page_offset': 0, 'first_bytes': 6, 'remaining': 0, 'first_physical': 176, 'second_physical': 80, 'spans': [[176, 6]], 'destination_offsets': [0], 'byte_addresses': [176, 177, 178, 179, 180, 181]}), ({'w': 12, 'x': 2, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 223, 'first_page': 13, 'page_offset': 15, 'first_bytes': 1, 'remaining': 5, 'first_physical': 223, 'second_physical': 240, 'spans': [[223, 1], [240, 5]], 'destination_offsets': [0, 1], 'byte_addresses': [223, 240, 241, 242, 243, 244]}), ({'w': 12, 'x': 3, 'y': 0, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 83, 'first_page': 5, 'page_offset': 3, 'first_bytes': 6, 'remaining': 0, 'first_physical': 163, 'second_physical': 64, 'spans': [[163, 6]], 'destination_offsets': [0], 'byte_addresses': [163, 164, 165, 166, 167, 168]}), ({'w': 12, 'x': 4, 'y': 1, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 162, 'first_page': 10, 'page_offset': 2, 'first_bytes': 6, 'remaining': 0, 'first_physical': 82, 'second_physical': 192, 'spans': [[82, 6]], 'destination_offsets': [0], 'byte_addresses': [82, 83, 84, 85, 86, 87]}), ({'w': 12, 'x': 5, 'y': 2, 'pitch': 73, 'base': 65, 'pages': [3, 7, 1, 8, 2, 10, 4, 9, 6, 11, 5, 12, 14, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'virtual_start': 241, 'first_page': 15, 'page_offset': 1, 'first_bytes': 6, 'remaining': 0, 'first_physical': 257, 'second_physical': 272, 'spans': [[257, 6]], 'destination_offsets': [0], 'byte_addresses': [257, 258, 259, 260, 261, 262]})]}
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 second_physical.

Raster texels contain six bytes and may straddle 16-byte virtual pages. A virtual byte span maps through a noncontiguous physical page directory; output contains source spans and offsets for reassembling one texel. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access