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

N = 1
observations = []
def solve(p):
    p = dict(p)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]//3
    row_span = p["w"]*p["b"]+2
    directory_bytes = group_count*7
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]
    row_span = p["w"]*p["b"]+2
    directory_bytes = group_count*7
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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 group_row.

Rows are grouped in packets of three scanlines. Each group has a five-byte header and every full allocated row has a two-byte checksum. Last group stores only actual rows, with a seven-byte directory record per group. 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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*p["b"]
    directory_bytes = group_count*7
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*(p["b"]+2)
    directory_bytes = group_count*7
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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 row_span.

Rows are grouped in packets of three scanlines. Each group has a five-byte header and every full allocated row has a two-byte checksum. Last group stores only actual rows, with a seven-byte directory record per group. 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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*p["b"]+2
    directory_bytes = group_count*5
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*p["b"]+2
    directory_bytes = p["h"]*7
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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 directory_bytes.

Rows are grouped in packets of three scanlines. Each group has a five-byte header and every full allocated row has a two-byte checksum. Last group stores only actual rows, with a seven-byte directory record per group. 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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*p["b"]+2
    directory_bytes = group_count*7
    group_sizes = [5+3*row_span]*group_count
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*p["b"]+2
    directory_bytes = group_count*7
    group_sizes = [min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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 group_sizes.

Rows are grouped in packets of three scanlines. Each group has a five-byte header and every full allocated row has a two-byte checksum. Last group stores only actual rows, with a seven-byte directory record per group. 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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*p["b"]+2
    directory_bytes = group_count*7
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+directory_bytes+group_id*(3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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)
    group_count = (p["h"]+2)//3
    group_id = p["y"]//3
    group_row = p["y"]%3
    row_span = p["w"]*p["b"]+2
    directory_bytes = group_count*7
    group_sizes = [5+min(3,p["h"]-i*3)*row_span for i in range(group_count)]
    group_origin = p["base"]+group_id*(5+3*row_span)
    address = group_origin+5+group_row*row_span+p["x"]*p["b"]
    checksum = group_origin+5+group_row*row_span+p["w"]*p["b"]
    allocation_end = p["base"]+directory_bytes+sum(group_sizes)
    return {'group_count': group_count, 'group_id': group_id, 'group_row': group_row, 'row_span': row_span, 'directory_bytes': directory_bytes, 'group_sizes': group_sizes, 'group_origin': group_origin, 'address': address, 'checksum': checksum, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 2, 'base': 11}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 4, 'directory_bytes': 7, 'group_sizes': [9], 'group_origin': 18, 'address': 23, 'checksum': 25, 'allocation_end': 27}), ({'w': 6, 'h': 4, 'x': 1, 'y': 2, 'b': 2, 'base': 11}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 14, 'directory_bytes': 14, 'group_sizes': [47, 19], 'group_origin': 25, 'address': 60, 'checksum': 70, 'allocation_end': 91}), ({'w': 10, 'h': 8, 'x': 8, 'y': 6, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 22, 'directory_bytes': 21, 'group_sizes': [71, 71, 49], 'group_origin': 174, 'address': 195, 'checksum': 199, 'allocation_end': 223}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 2, 'base': 11}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 34, 'directory_bytes': 21, 'group_sizes': [107, 107, 73], 'group_origin': 246, 'address': 315, 'checksum': 317, 'allocation_end': 319}), ({'w': 18, 'h': 10, 'x': 16, 'y': 8, 'b': 2, 'base': 11}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 38, 'directory_bytes': 28, 'group_sizes': [119, 119, 119, 43], 'group_origin': 277, 'address': 390, 'checksum': 394, 'allocation_end': 439}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 2, 'base': 11}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 16, 'directory_bytes': 35, 'group_sizes': [53, 53, 53, 53, 21], 'group_origin': 258, 'address': 269, 'checksum': 277, 'allocation_end': 279})], 2: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 3, 'base': 22}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 5, 'directory_bytes': 7, 'group_sizes': [10], 'group_origin': 29, 'address': 34, 'checksum': 37, 'allocation_end': 39}), ({'w': 7, 'h': 5, 'x': 1, 'y': 2, 'b': 3, 'base': 22}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 23, 'directory_bytes': 14, 'group_sizes': [74, 51], 'group_origin': 36, 'address': 90, 'checksum': 108, 'allocation_end': 161}), ({'w': 11, 'h': 9, 'x': 8, 'y': 6, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 0, 'row_span': 35, 'directory_bytes': 21, 'group_sizes': [110, 110, 110], 'group_origin': 263, 'address': 292, 'checksum': 301, 'allocation_end': 373}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 3, 'base': 22}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 50, 'directory_bytes': 21, 'group_sizes': [155, 155, 105], 'group_origin': 353, 'address': 453, 'checksum': 456, 'allocation_end': 458}), ({'w': 19, 'h': 11, 'x': 16, 'y': 8, 'b': 3, 'base': 22}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 59, 'directory_bytes': 28, 'group_sizes': [182, 182, 182, 123], 'group_origin': 414, 'address': 585, 'checksum': 594, 'allocation_end': 719}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 3, 'base': 22}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 23, 'directory_bytes': 35, 'group_sizes': [74, 74, 74, 74, 28], 'group_origin': 353, 'address': 367, 'checksum': 379, 'allocation_end': 381})], 3: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 4, 'base': 33}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 6, 'directory_bytes': 7, 'group_sizes': [11], 'group_origin': 40, 'address': 45, 'checksum': 49, 'allocation_end': 51}), ({'w': 8, 'h': 6, 'x': 1, 'y': 2, 'b': 4, 'base': 33}, {'group_count': 2, 'group_id': 0, 'group_row': 2, 'row_span': 34, 'directory_bytes': 14, 'group_sizes': [107, 107], 'group_origin': 47, 'address': 124, 'checksum': 152, 'allocation_end': 261}), ({'w': 12, 'h': 10, 'x': 8, 'y': 6, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 50, 'directory_bytes': 28, 'group_sizes': [155, 155, 155, 55], 'group_origin': 371, 'address': 408, 'checksum': 424, 'allocation_end': 581}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 4, 'base': 33}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 66, 'directory_bytes': 21, 'group_sizes': [203, 203, 137], 'group_origin': 460, 'address': 591, 'checksum': 595, 'allocation_end': 597}), ({'w': 20, 'h': 12, 'x': 16, 'y': 8, 'b': 4, 'base': 33}, {'group_count': 4, 'group_id': 2, 'group_row': 2, 'row_span': 82, 'directory_bytes': 28, 'group_sizes': [251, 251, 251, 251], 'group_origin': 563, 'address': 796, 'checksum': 812, 'allocation_end': 1065}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 4, 'base': 33}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 30, 'directory_bytes': 35, 'group_sizes': [95, 95, 95, 95, 35], 'group_origin': 448, 'address': 465, 'checksum': 481, 'allocation_end': 483})], 4: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 5, 'base': 44}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 7, 'directory_bytes': 7, 'group_sizes': [12], 'group_origin': 51, 'address': 56, 'checksum': 61, 'allocation_end': 63}), ({'w': 9, 'h': 7, 'x': 1, 'y': 2, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 47, 'directory_bytes': 21, 'group_sizes': [146, 146, 52], 'group_origin': 65, 'address': 169, 'checksum': 209, 'allocation_end': 409}), ({'w': 13, 'h': 11, 'x': 8, 'y': 6, 'b': 5, 'base': 44}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 67, 'directory_bytes': 28, 'group_sizes': [206, 206, 206, 139], 'group_origin': 484, 'address': 529, 'checksum': 554, 'allocation_end': 829}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 5, 'base': 44}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 82, 'directory_bytes': 21, 'group_sizes': [251, 251, 169], 'group_origin': 567, 'address': 729, 'checksum': 734, 'allocation_end': 736}), ({'w': 21, 'h': 13, 'x': 16, 'y': 8, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 107, 'directory_bytes': 35, 'group_sizes': [326, 326, 326, 326, 112], 'group_origin': 731, 'address': 1030, 'checksum': 1055, 'allocation_end': 1495}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 5, 'base': 44}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 37, 'directory_bytes': 35, 'group_sizes': [116, 116, 116, 116, 42], 'group_origin': 543, 'address': 563, 'checksum': 583, 'allocation_end': 585})], 5: [({'w': 1, 'h': 1, 'x': 0, 'y': 0, 'b': 6, 'base': 55}, {'group_count': 1, 'group_id': 0, 'group_row': 0, 'row_span': 8, 'directory_bytes': 7, 'group_sizes': [13], 'group_origin': 62, 'address': 67, 'checksum': 73, 'allocation_end': 75}), ({'w': 10, 'h': 8, 'x': 1, 'y': 2, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 0, 'group_row': 2, 'row_span': 62, 'directory_bytes': 21, 'group_sizes': [191, 191, 129], 'group_origin': 76, 'address': 211, 'checksum': 265, 'allocation_end': 587}), ({'w': 14, 'h': 12, 'x': 8, 'y': 6, 'b': 6, 'base': 55}, {'group_count': 4, 'group_id': 2, 'group_row': 0, 'row_span': 86, 'directory_bytes': 28, 'group_sizes': [263, 263, 263, 263], 'group_origin': 609, 'address': 662, 'checksum': 698, 'allocation_end': 1135}), ({'w': 16, 'h': 8, 'x': 15, 'y': 7, 'b': 6, 'base': 55}, {'group_count': 3, 'group_id': 2, 'group_row': 1, 'row_span': 98, 'directory_bytes': 21, 'group_sizes': [299, 299, 201], 'group_origin': 674, 'address': 867, 'checksum': 873, 'allocation_end': 875}), ({'w': 22, 'h': 14, 'x': 16, 'y': 8, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 2, 'group_row': 2, 'row_span': 134, 'directory_bytes': 35, 'group_sizes': [407, 407, 407, 407, 273], 'group_origin': 904, 'address': 1273, 'checksum': 1309, 'allocation_end': 1991}), ({'w': 7, 'h': 13, 'x': 3, 'y': 12, 'b': 6, 'base': 55}, {'group_count': 5, 'group_id': 4, 'group_row': 0, 'row_span': 44, 'directory_bytes': 35, 'group_sizes': [137, 137, 137, 137, 49], 'group_origin': 638, 'address': 661, 'checksum': 685, 'allocation_end': 687})]}
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 group_origin.

Rows are grouped in packets of three scanlines. Each group has a five-byte header and every full allocated row has a two-byte checksum. Last group stores only actual rows, with a seven-byte directory record per group. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access