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

N = 1
observations = []
def solve(p):
    p = dict(p)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = p["x"]%16
    mask = 1<<bit_index
    address = plane_origin+p["y"]*row_bytes+word_column*2
    last_word_mask = ((1<<(p["w"]%16))-1)<<(16-p["w"]%16) if p["w"]%16 else 65535
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = 7-p["x"]%8
    mask = 1<<bit_index
    address = plane_origin+p["y"]*row_bytes+word_column*2
    last_word_mask = ((1<<(p["w"]%16))-1)<<(16-p["w"]%16) if p["w"]%16 else 65535
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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 bit_index.

A four-plane bitmap uses sixteen-bit words, most-significant-bit-first pixels, independent plane headers, and plane-major storage. Each row contains an extra sentinel word. Return word location and update mask without decoding colors. 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)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = 15-p["x"]%16
    mask = bit_index
    address = plane_origin+p["y"]*row_bytes+word_column*2
    last_word_mask = ((1<<(p["w"]%16))-1)<<(16-p["w"]%16) if p["w"]%16 else 65535
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = 15-p["x"]%16
    mask = (1<<(bit_index+1))-1
    address = plane_origin+p["y"]*row_bytes+word_column*2
    last_word_mask = ((1<<(p["w"]%16))-1)<<(16-p["w"]%16) if p["w"]%16 else 65535
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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 mask.

A four-plane bitmap uses sixteen-bit words, most-significant-bit-first pixels, independent plane headers, and plane-major storage. Each row contains an extra sentinel word. Return word location and update mask without decoding colors. 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)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = 15-p["x"]%16
    mask = 1<<bit_index
    address = plane_origin+p["y"]*row_bytes+word_column
    last_word_mask = ((1<<(p["w"]%16))-1)<<(16-p["w"]%16) if p["w"]%16 else 65535
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = 15-p["x"]%16
    mask = 1<<bit_index
    address = plane_origin+(p["h"]-1-p["y"])*row_bytes+word_column*2
    last_word_mask = ((1<<(p["w"]%16))-1)<<(16-p["w"]%16) if p["w"]%16 else 65535
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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 address.

A four-plane bitmap uses sixteen-bit words, most-significant-bit-first pixels, independent plane headers, and plane-major storage. Each row contains an extra sentinel word. Return word location and update mask without decoding colors. 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)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = 15-p["x"]%16
    mask = 1<<bit_index
    address = plane_origin+p["y"]*row_bytes+word_column*2
    last_word_mask = (1<<(p["w"]%16))-1
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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)
    words = (p["w"]+15)//16
    row_words = words+1
    row_bytes = row_words*2
    plane_bytes = p["h"]*row_bytes+4
    plane_origin = p["base"]+p["plane"]*plane_bytes+4
    word_column = p["x"]//16
    bit_index = 15-p["x"]%16
    mask = 1<<bit_index
    address = plane_origin+p["y"]*row_bytes+word_column*2
    last_word_mask = 65535
    return {'words': words, 'row_words': row_words, 'row_bytes': row_bytes, 'plane_bytes': plane_bytes, 'plane_origin': plane_origin, 'word_column': word_column, 'bit_index': bit_index, 'mask': mask, 'address': address, 'last_word_mask': last_word_mask}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 18, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 15, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 15, 'last_word_mask': 49152}), ({'w': 19, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 37, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 43, 'last_word_mask': 57344}), ({'w': 20, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 71, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 83, 'last_word_mask': 61440}), ({'w': 21, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 117, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 137, 'last_word_mask': 63488}), ({'w': 22, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 15, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 41, 'last_word_mask': 64512}), ({'w': 23, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 11}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 61, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 93, 'last_word_mask': 65024})], 2: [({'w': 19, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 26, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 26, 'last_word_mask': 57344}), ({'w': 20, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 48, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 54, 'last_word_mask': 61440}), ({'w': 21, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 82, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 94, 'last_word_mask': 63488}), ({'w': 22, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 128, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 148, 'last_word_mask': 64512}), ({'w': 23, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 26, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 52, 'last_word_mask': 65024}), ({'w': 24, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 22}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 72, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 104, 'last_word_mask': 65280})], 3: [({'w': 20, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 37, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 37, 'last_word_mask': 61440}), ({'w': 21, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 59, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 65, 'last_word_mask': 63488}), ({'w': 22, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 93, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 105, 'last_word_mask': 64512}), ({'w': 23, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 139, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 159, 'last_word_mask': 65024}), ({'w': 24, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 37, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 63, 'last_word_mask': 65280}), ({'w': 25, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 33}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 83, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 115, 'last_word_mask': 65408})], 4: [({'w': 21, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 48, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 48, 'last_word_mask': 63488}), ({'w': 22, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 70, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 76, 'last_word_mask': 64512}), ({'w': 23, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 104, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 116, 'last_word_mask': 65024}), ({'w': 24, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 150, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 170, 'last_word_mask': 65280}), ({'w': 25, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 48, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 74, 'last_word_mask': 65408}), ({'w': 26, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 44}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 94, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 126, 'last_word_mask': 65472})], 5: [({'w': 22, 'h': 2, 'x': 0, 'y': 0, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 16, 'plane_origin': 59, 'word_column': 0, 'bit_index': 15, 'mask': 32768, 'address': 59, 'last_word_mask': 64512}), ({'w': 23, 'h': 3, 'x': 1, 'y': 1, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 22, 'plane_origin': 81, 'word_column': 0, 'bit_index': 14, 'mask': 16384, 'address': 87, 'last_word_mask': 65024}), ({'w': 24, 'h': 4, 'x': 15, 'y': 2, 'plane': 2, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 28, 'plane_origin': 115, 'word_column': 0, 'bit_index': 0, 'mask': 1, 'address': 127, 'last_word_mask': 65280}), ({'w': 25, 'h': 5, 'x': 16, 'y': 3, 'plane': 3, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 34, 'plane_origin': 161, 'word_column': 1, 'bit_index': 15, 'mask': 32768, 'address': 181, 'last_word_mask': 65408}), ({'w': 26, 'h': 6, 'x': 17, 'y': 4, 'plane': 0, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 40, 'plane_origin': 59, 'word_column': 1, 'bit_index': 14, 'mask': 16384, 'address': 85, 'last_word_mask': 65472}), ({'w': 27, 'h': 7, 'x': 18, 'y': 5, 'plane': 1, 'base': 55}, {'words': 2, 'row_words': 3, 'row_bytes': 6, 'plane_bytes': 46, 'plane_origin': 105, 'word_column': 1, 'bit_index': 13, 'mask': 8192, 'address': 137, 'last_word_mask': 65504})]}
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 last_word_mask.

A four-plane bitmap uses sixteen-bit words, most-significant-bit-first pixels, independent plane headers, and plane-major storage. Each row contains an extra sentinel word. Return word location and update mask without decoding colors. 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)
    palette_bytes = p["colors"]*3
    packed_bytes = (p["w"]+1)//2
    row_pitch = packed_bytes+1
    image_origin = p["base"]+palette_bytes
    byte_address = image_origin+p["y"]*row_pitch+1+p["x"]//2
    shift = 4 if p["x"]%2==0 else 0
    keep_mask = 255 ^ (15<<shift)
    written_byte = (p["old"]&keep_mask)|((p["value"]&15)<<shift)
    tail_mask = 240 if p["w"]%2 else 255
    allocation_end = image_origin+p["h"]*row_pitch
    return {'palette_bytes': palette_bytes, 'packed_bytes': packed_bytes, 'row_pitch': row_pitch, 'image_origin': image_origin, 'byte_address': byte_address, 'shift': shift, 'keep_mask': keep_mask, 'written_byte': written_byte, 'tail_mask': tail_mask, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 4, 'h': 2, 'x': 0, 'y': 0, 'colors': 5, 'base': 17, 'value': 1, 'old': 35}, {'palette_bytes': 17, 'packed_bytes': 2, 'row_pitch': 3, 'image_origin': 34, 'byte_address': 35, 'shift': 4, 'keep_mask': 15, 'written_byte': 19, 'tail_mask': 255, 'allocation_end': 40}), ({'w': 5, 'h': 3, 'x': 1, 'y': 1, 'colors': 5, 'base': 17, 'value': 2, 'old': 36}, {'palette_bytes': 17, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 34, 'byte_address': 39, 'shift': 0, 'keep_mask': 240, 'written_byte': 34, 'tail_mask': 240, 'allocation_end': 46}), ({'w': 6, 'h': 4, 'x': 2, 'y': 2, 'colors': 5, 'base': 17, 'value': 3, 'old': 37}, {'palette_bytes': 17, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 34, 'byte_address': 44, 'shift': 4, 'keep_mask': 15, 'written_byte': 53, 'tail_mask': 255, 'allocation_end': 50}), ({'w': 7, 'h': 5, 'x': 3, 'y': 3, 'colors': 5, 'base': 17, 'value': 4, 'old': 38}, {'palette_bytes': 17, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 34, 'byte_address': 51, 'shift': 0, 'keep_mask': 240, 'written_byte': 36, 'tail_mask': 240, 'allocation_end': 59}), ({'w': 8, 'h': 6, 'x': 4, 'y': 4, 'colors': 5, 'base': 17, 'value': 5, 'old': 39}, {'palette_bytes': 17, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 34, 'byte_address': 57, 'shift': 4, 'keep_mask': 15, 'written_byte': 87, 'tail_mask': 255, 'allocation_end': 64}), ({'w': 9, 'h': 7, 'x': 5, 'y': 5, 'colors': 5, 'base': 17, 'value': 6, 'old': 40}, {'palette_bytes': 17, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 34, 'byte_address': 67, 'shift': 0, 'keep_mask': 240, 'written_byte': 38, 'tail_mask': 240, 'allocation_end': 76})], 2: [({'w': 5, 'h': 2, 'x': 0, 'y': 0, 'colors': 6, 'base': 34, 'value': 2, 'old': 35}, {'palette_bytes': 20, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 54, 'byte_address': 55, 'shift': 4, 'keep_mask': 15, 'written_byte': 35, 'tail_mask': 240, 'allocation_end': 62}), ({'w': 6, 'h': 3, 'x': 1, 'y': 1, 'colors': 6, 'base': 34, 'value': 3, 'old': 36}, {'palette_bytes': 20, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 54, 'byte_address': 59, 'shift': 0, 'keep_mask': 240, 'written_byte': 35, 'tail_mask': 255, 'allocation_end': 66}), ({'w': 7, 'h': 4, 'x': 2, 'y': 2, 'colors': 6, 'base': 34, 'value': 4, 'old': 37}, {'palette_bytes': 20, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 54, 'byte_address': 66, 'shift': 4, 'keep_mask': 15, 'written_byte': 69, 'tail_mask': 240, 'allocation_end': 74}), ({'w': 8, 'h': 5, 'x': 3, 'y': 3, 'colors': 6, 'base': 34, 'value': 5, 'old': 38}, {'palette_bytes': 20, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 54, 'byte_address': 71, 'shift': 0, 'keep_mask': 240, 'written_byte': 37, 'tail_mask': 255, 'allocation_end': 79}), ({'w': 9, 'h': 6, 'x': 4, 'y': 4, 'colors': 6, 'base': 34, 'value': 6, 'old': 39}, {'palette_bytes': 20, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 54, 'byte_address': 81, 'shift': 4, 'keep_mask': 15, 'written_byte': 103, 'tail_mask': 240, 'allocation_end': 90}), ({'w': 10, 'h': 7, 'x': 5, 'y': 5, 'colors': 6, 'base': 34, 'value': 7, 'old': 40}, {'palette_bytes': 20, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 54, 'byte_address': 87, 'shift': 0, 'keep_mask': 240, 'written_byte': 39, 'tail_mask': 255, 'allocation_end': 96})], 3: [({'w': 6, 'h': 2, 'x': 0, 'y': 0, 'colors': 7, 'base': 51, 'value': 3, 'old': 35}, {'palette_bytes': 23, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 74, 'byte_address': 75, 'shift': 4, 'keep_mask': 15, 'written_byte': 51, 'tail_mask': 255, 'allocation_end': 82}), ({'w': 7, 'h': 3, 'x': 1, 'y': 1, 'colors': 7, 'base': 51, 'value': 4, 'old': 36}, {'palette_bytes': 23, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 74, 'byte_address': 80, 'shift': 0, 'keep_mask': 240, 'written_byte': 36, 'tail_mask': 240, 'allocation_end': 89}), ({'w': 8, 'h': 4, 'x': 2, 'y': 2, 'colors': 7, 'base': 51, 'value': 5, 'old': 37}, {'palette_bytes': 23, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 74, 'byte_address': 86, 'shift': 4, 'keep_mask': 15, 'written_byte': 85, 'tail_mask': 255, 'allocation_end': 94}), ({'w': 9, 'h': 5, 'x': 3, 'y': 3, 'colors': 7, 'base': 51, 'value': 6, 'old': 38}, {'palette_bytes': 23, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 74, 'byte_address': 94, 'shift': 0, 'keep_mask': 240, 'written_byte': 38, 'tail_mask': 240, 'allocation_end': 104}), ({'w': 10, 'h': 6, 'x': 4, 'y': 4, 'colors': 7, 'base': 51, 'value': 7, 'old': 39}, {'palette_bytes': 23, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 74, 'byte_address': 101, 'shift': 4, 'keep_mask': 15, 'written_byte': 119, 'tail_mask': 255, 'allocation_end': 110}), ({'w': 11, 'h': 7, 'x': 5, 'y': 5, 'colors': 7, 'base': 51, 'value': 8, 'old': 40}, {'palette_bytes': 23, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 74, 'byte_address': 112, 'shift': 0, 'keep_mask': 240, 'written_byte': 40, 'tail_mask': 240, 'allocation_end': 123})], 4: [({'w': 7, 'h': 2, 'x': 0, 'y': 0, 'colors': 8, 'base': 68, 'value': 4, 'old': 35}, {'palette_bytes': 26, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 94, 'byte_address': 95, 'shift': 4, 'keep_mask': 15, 'written_byte': 67, 'tail_mask': 240, 'allocation_end': 104}), ({'w': 8, 'h': 3, 'x': 1, 'y': 1, 'colors': 8, 'base': 68, 'value': 5, 'old': 36}, {'palette_bytes': 26, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 94, 'byte_address': 100, 'shift': 0, 'keep_mask': 240, 'written_byte': 37, 'tail_mask': 255, 'allocation_end': 109}), ({'w': 9, 'h': 4, 'x': 2, 'y': 2, 'colors': 8, 'base': 68, 'value': 6, 'old': 37}, {'palette_bytes': 26, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 94, 'byte_address': 108, 'shift': 4, 'keep_mask': 15, 'written_byte': 101, 'tail_mask': 240, 'allocation_end': 118}), ({'w': 10, 'h': 5, 'x': 3, 'y': 3, 'colors': 8, 'base': 68, 'value': 7, 'old': 38}, {'palette_bytes': 26, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 94, 'byte_address': 114, 'shift': 0, 'keep_mask': 240, 'written_byte': 39, 'tail_mask': 255, 'allocation_end': 124}), ({'w': 11, 'h': 6, 'x': 4, 'y': 4, 'colors': 8, 'base': 68, 'value': 8, 'old': 39}, {'palette_bytes': 26, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 94, 'byte_address': 125, 'shift': 4, 'keep_mask': 15, 'written_byte': 135, 'tail_mask': 240, 'allocation_end': 136}), ({'w': 12, 'h': 7, 'x': 5, 'y': 5, 'colors': 8, 'base': 68, 'value': 9, 'old': 40}, {'palette_bytes': 26, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 94, 'byte_address': 132, 'shift': 0, 'keep_mask': 240, 'written_byte': 41, 'tail_mask': 255, 'allocation_end': 143})], 5: [({'w': 8, 'h': 2, 'x': 0, 'y': 0, 'colors': 9, 'base': 85, 'value': 5, 'old': 35}, {'palette_bytes': 29, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 114, 'byte_address': 115, 'shift': 4, 'keep_mask': 15, 'written_byte': 83, 'tail_mask': 255, 'allocation_end': 124}), ({'w': 9, 'h': 3, 'x': 1, 'y': 1, 'colors': 9, 'base': 85, 'value': 6, 'old': 36}, {'palette_bytes': 29, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 114, 'byte_address': 121, 'shift': 0, 'keep_mask': 240, 'written_byte': 38, 'tail_mask': 240, 'allocation_end': 132}), ({'w': 10, 'h': 4, 'x': 2, 'y': 2, 'colors': 9, 'base': 85, 'value': 7, 'old': 37}, {'palette_bytes': 29, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 114, 'byte_address': 128, 'shift': 4, 'keep_mask': 15, 'written_byte': 117, 'tail_mask': 255, 'allocation_end': 138}), ({'w': 11, 'h': 5, 'x': 3, 'y': 3, 'colors': 9, 'base': 85, 'value': 8, 'old': 38}, {'palette_bytes': 29, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 114, 'byte_address': 137, 'shift': 0, 'keep_mask': 240, 'written_byte': 40, 'tail_mask': 240, 'allocation_end': 149}), ({'w': 12, 'h': 6, 'x': 4, 'y': 4, 'colors': 9, 'base': 85, 'value': 9, 'old': 39}, {'palette_bytes': 29, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 114, 'byte_address': 145, 'shift': 4, 'keep_mask': 15, 'written_byte': 151, 'tail_mask': 255, 'allocation_end': 156}), ({'w': 13, 'h': 7, 'x': 5, 'y': 5, 'colors': 9, 'base': 85, 'value': 10, 'old': 40}, {'palette_bytes': 29, 'packed_bytes': 7, 'row_pitch': 8, 'image_origin': 114, 'byte_address': 157, 'shift': 0, 'keep_mask': 240, 'written_byte': 42, 'tail_mask': 240, 'allocation_end': 170})]}
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)
    palette_bytes = 2+p["colors"]*4
    packed_bytes = (p["w"]+1)//2
    row_pitch = packed_bytes+1
    image_origin = p["base"]+palette_bytes
    byte_address = image_origin+p["y"]*row_pitch+1+p["x"]//2
    shift = 4 if p["x"]%2==0 else 0
    keep_mask = 255 ^ (15<<shift)
    written_byte = (p["old"]&keep_mask)|((p["value"]&15)<<shift)
    tail_mask = 240 if p["w"]%2 else 255
    allocation_end = image_origin+p["h"]*row_pitch
    return {'palette_bytes': palette_bytes, 'packed_bytes': packed_bytes, 'row_pitch': row_pitch, 'image_origin': image_origin, 'byte_address': byte_address, 'shift': shift, 'keep_mask': keep_mask, 'written_byte': written_byte, 'tail_mask': tail_mask, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 4, 'h': 2, 'x': 0, 'y': 0, 'colors': 5, 'base': 17, 'value': 1, 'old': 35}, {'palette_bytes': 17, 'packed_bytes': 2, 'row_pitch': 3, 'image_origin': 34, 'byte_address': 35, 'shift': 4, 'keep_mask': 15, 'written_byte': 19, 'tail_mask': 255, 'allocation_end': 40}), ({'w': 5, 'h': 3, 'x': 1, 'y': 1, 'colors': 5, 'base': 17, 'value': 2, 'old': 36}, {'palette_bytes': 17, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 34, 'byte_address': 39, 'shift': 0, 'keep_mask': 240, 'written_byte': 34, 'tail_mask': 240, 'allocation_end': 46}), ({'w': 6, 'h': 4, 'x': 2, 'y': 2, 'colors': 5, 'base': 17, 'value': 3, 'old': 37}, {'palette_bytes': 17, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 34, 'byte_address': 44, 'shift': 4, 'keep_mask': 15, 'written_byte': 53, 'tail_mask': 255, 'allocation_end': 50}), ({'w': 7, 'h': 5, 'x': 3, 'y': 3, 'colors': 5, 'base': 17, 'value': 4, 'old': 38}, {'palette_bytes': 17, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 34, 'byte_address': 51, 'shift': 0, 'keep_mask': 240, 'written_byte': 36, 'tail_mask': 240, 'allocation_end': 59}), ({'w': 8, 'h': 6, 'x': 4, 'y': 4, 'colors': 5, 'base': 17, 'value': 5, 'old': 39}, {'palette_bytes': 17, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 34, 'byte_address': 57, 'shift': 4, 'keep_mask': 15, 'written_byte': 87, 'tail_mask': 255, 'allocation_end': 64}), ({'w': 9, 'h': 7, 'x': 5, 'y': 5, 'colors': 5, 'base': 17, 'value': 6, 'old': 40}, {'palette_bytes': 17, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 34, 'byte_address': 67, 'shift': 0, 'keep_mask': 240, 'written_byte': 38, 'tail_mask': 240, 'allocation_end': 76})], 2: [({'w': 5, 'h': 2, 'x': 0, 'y': 0, 'colors': 6, 'base': 34, 'value': 2, 'old': 35}, {'palette_bytes': 20, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 54, 'byte_address': 55, 'shift': 4, 'keep_mask': 15, 'written_byte': 35, 'tail_mask': 240, 'allocation_end': 62}), ({'w': 6, 'h': 3, 'x': 1, 'y': 1, 'colors': 6, 'base': 34, 'value': 3, 'old': 36}, {'palette_bytes': 20, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 54, 'byte_address': 59, 'shift': 0, 'keep_mask': 240, 'written_byte': 35, 'tail_mask': 255, 'allocation_end': 66}), ({'w': 7, 'h': 4, 'x': 2, 'y': 2, 'colors': 6, 'base': 34, 'value': 4, 'old': 37}, {'palette_bytes': 20, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 54, 'byte_address': 66, 'shift': 4, 'keep_mask': 15, 'written_byte': 69, 'tail_mask': 240, 'allocation_end': 74}), ({'w': 8, 'h': 5, 'x': 3, 'y': 3, 'colors': 6, 'base': 34, 'value': 5, 'old': 38}, {'palette_bytes': 20, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 54, 'byte_address': 71, 'shift': 0, 'keep_mask': 240, 'written_byte': 37, 'tail_mask': 255, 'allocation_end': 79}), ({'w': 9, 'h': 6, 'x': 4, 'y': 4, 'colors': 6, 'base': 34, 'value': 6, 'old': 39}, {'palette_bytes': 20, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 54, 'byte_address': 81, 'shift': 4, 'keep_mask': 15, 'written_byte': 103, 'tail_mask': 240, 'allocation_end': 90}), ({'w': 10, 'h': 7, 'x': 5, 'y': 5, 'colors': 6, 'base': 34, 'value': 7, 'old': 40}, {'palette_bytes': 20, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 54, 'byte_address': 87, 'shift': 0, 'keep_mask': 240, 'written_byte': 39, 'tail_mask': 255, 'allocation_end': 96})], 3: [({'w': 6, 'h': 2, 'x': 0, 'y': 0, 'colors': 7, 'base': 51, 'value': 3, 'old': 35}, {'palette_bytes': 23, 'packed_bytes': 3, 'row_pitch': 4, 'image_origin': 74, 'byte_address': 75, 'shift': 4, 'keep_mask': 15, 'written_byte': 51, 'tail_mask': 255, 'allocation_end': 82}), ({'w': 7, 'h': 3, 'x': 1, 'y': 1, 'colors': 7, 'base': 51, 'value': 4, 'old': 36}, {'palette_bytes': 23, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 74, 'byte_address': 80, 'shift': 0, 'keep_mask': 240, 'written_byte': 36, 'tail_mask': 240, 'allocation_end': 89}), ({'w': 8, 'h': 4, 'x': 2, 'y': 2, 'colors': 7, 'base': 51, 'value': 5, 'old': 37}, {'palette_bytes': 23, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 74, 'byte_address': 86, 'shift': 4, 'keep_mask': 15, 'written_byte': 85, 'tail_mask': 255, 'allocation_end': 94}), ({'w': 9, 'h': 5, 'x': 3, 'y': 3, 'colors': 7, 'base': 51, 'value': 6, 'old': 38}, {'palette_bytes': 23, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 74, 'byte_address': 94, 'shift': 0, 'keep_mask': 240, 'written_byte': 38, 'tail_mask': 240, 'allocation_end': 104}), ({'w': 10, 'h': 6, 'x': 4, 'y': 4, 'colors': 7, 'base': 51, 'value': 7, 'old': 39}, {'palette_bytes': 23, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 74, 'byte_address': 101, 'shift': 4, 'keep_mask': 15, 'written_byte': 119, 'tail_mask': 255, 'allocation_end': 110}), ({'w': 11, 'h': 7, 'x': 5, 'y': 5, 'colors': 7, 'base': 51, 'value': 8, 'old': 40}, {'palette_bytes': 23, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 74, 'byte_address': 112, 'shift': 0, 'keep_mask': 240, 'written_byte': 40, 'tail_mask': 240, 'allocation_end': 123})], 4: [({'w': 7, 'h': 2, 'x': 0, 'y': 0, 'colors': 8, 'base': 68, 'value': 4, 'old': 35}, {'palette_bytes': 26, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 94, 'byte_address': 95, 'shift': 4, 'keep_mask': 15, 'written_byte': 67, 'tail_mask': 240, 'allocation_end': 104}), ({'w': 8, 'h': 3, 'x': 1, 'y': 1, 'colors': 8, 'base': 68, 'value': 5, 'old': 36}, {'palette_bytes': 26, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 94, 'byte_address': 100, 'shift': 0, 'keep_mask': 240, 'written_byte': 37, 'tail_mask': 255, 'allocation_end': 109}), ({'w': 9, 'h': 4, 'x': 2, 'y': 2, 'colors': 8, 'base': 68, 'value': 6, 'old': 37}, {'palette_bytes': 26, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 94, 'byte_address': 108, 'shift': 4, 'keep_mask': 15, 'written_byte': 101, 'tail_mask': 240, 'allocation_end': 118}), ({'w': 10, 'h': 5, 'x': 3, 'y': 3, 'colors': 8, 'base': 68, 'value': 7, 'old': 38}, {'palette_bytes': 26, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 94, 'byte_address': 114, 'shift': 0, 'keep_mask': 240, 'written_byte': 39, 'tail_mask': 255, 'allocation_end': 124}), ({'w': 11, 'h': 6, 'x': 4, 'y': 4, 'colors': 8, 'base': 68, 'value': 8, 'old': 39}, {'palette_bytes': 26, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 94, 'byte_address': 125, 'shift': 4, 'keep_mask': 15, 'written_byte': 135, 'tail_mask': 240, 'allocation_end': 136}), ({'w': 12, 'h': 7, 'x': 5, 'y': 5, 'colors': 8, 'base': 68, 'value': 9, 'old': 40}, {'palette_bytes': 26, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 94, 'byte_address': 132, 'shift': 0, 'keep_mask': 240, 'written_byte': 41, 'tail_mask': 255, 'allocation_end': 143})], 5: [({'w': 8, 'h': 2, 'x': 0, 'y': 0, 'colors': 9, 'base': 85, 'value': 5, 'old': 35}, {'palette_bytes': 29, 'packed_bytes': 4, 'row_pitch': 5, 'image_origin': 114, 'byte_address': 115, 'shift': 4, 'keep_mask': 15, 'written_byte': 83, 'tail_mask': 255, 'allocation_end': 124}), ({'w': 9, 'h': 3, 'x': 1, 'y': 1, 'colors': 9, 'base': 85, 'value': 6, 'old': 36}, {'palette_bytes': 29, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 114, 'byte_address': 121, 'shift': 0, 'keep_mask': 240, 'written_byte': 38, 'tail_mask': 240, 'allocation_end': 132}), ({'w': 10, 'h': 4, 'x': 2, 'y': 2, 'colors': 9, 'base': 85, 'value': 7, 'old': 37}, {'palette_bytes': 29, 'packed_bytes': 5, 'row_pitch': 6, 'image_origin': 114, 'byte_address': 128, 'shift': 4, 'keep_mask': 15, 'written_byte': 117, 'tail_mask': 255, 'allocation_end': 138}), ({'w': 11, 'h': 5, 'x': 3, 'y': 3, 'colors': 9, 'base': 85, 'value': 8, 'old': 38}, {'palette_bytes': 29, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 114, 'byte_address': 137, 'shift': 0, 'keep_mask': 240, 'written_byte': 40, 'tail_mask': 240, 'allocation_end': 149}), ({'w': 12, 'h': 6, 'x': 4, 'y': 4, 'colors': 9, 'base': 85, 'value': 9, 'old': 39}, {'palette_bytes': 29, 'packed_bytes': 6, 'row_pitch': 7, 'image_origin': 114, 'byte_address': 145, 'shift': 4, 'keep_mask': 15, 'written_byte': 151, 'tail_mask': 255, 'allocation_end': 156}), ({'w': 13, 'h': 7, 'x': 5, 'y': 5, 'colors': 9, 'base': 85, 'value': 10, 'old': 40}, {'palette_bytes': 29, 'packed_bytes': 7, 'row_pitch': 8, 'image_origin': 114, 'byte_address': 157, 'shift': 0, 'keep_mask': 240, 'written_byte': 42, 'tail_mask': 240, 'allocation_end': 170})]}
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 palette_bytes.

An indexed image has a palette of three-byte entries, a two-byte palette-count field, and high-nibble-first pixels. Each scanline starts with a one-byte checksum. Odd final low nibbles are padding. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access