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

N = 1
observations = []
def solve(p):
    p = dict(p)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]
    payload_end = payload_start+p["lengths"][p["row"]]
    terminator = payload_end
    allocation_end = p["base"]+directory_bytes+sum(packet_sizes)
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]+3
    payload_end = payload_start+p["lengths"][p["row"]]
    terminator = payload_end
    allocation_end = p["base"]+directory_bytes+sum(packet_sizes)
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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 payload_start.

Each scanline is a packet with a two-byte tag, a four-byte absolute-offset directory entry, and a caller-specified encoded payload length. The directory precedes packet bytes; a trailing one-byte terminator follows each packet. 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)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]+2
    payload_end = payload_start+packet_sizes[p["row"]]
    terminator = payload_end
    allocation_end = p["base"]+directory_bytes+sum(packet_sizes)
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]+2
    payload_end = payload_start+max(p["lengths"])
    terminator = payload_end
    allocation_end = p["base"]+directory_bytes+sum(packet_sizes)
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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 payload_end.

Each scanline is a packet with a two-byte tag, a four-byte absolute-offset directory entry, and a caller-specified encoded payload length. The directory precedes packet bytes; a trailing one-byte terminator follows each packet. 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)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]+2
    payload_end = payload_start+p["lengths"][p["row"]]
    terminator = payload_end-1
    allocation_end = p["base"]+directory_bytes+sum(packet_sizes)
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]+2
    payload_end = payload_start+p["lengths"][p["row"]]
    terminator = payload_end+1
    allocation_end = p["base"]+directory_bytes+sum(packet_sizes)
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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 terminator.

Each scanline is a packet with a two-byte tag, a four-byte absolute-offset directory entry, and a caller-specified encoded payload length. The directory precedes packet bytes; a trailing one-byte terminator follows each packet. 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)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]+2
    payload_end = payload_start+p["lengths"][p["row"]]
    terminator = payload_end
    allocation_end = p["base"]+directory_bytes+sum(p["lengths"])
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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)
    rows = len(p["lengths"])
    directory_bytes = rows*4
    packet_sizes = [x+3 for x in p["lengths"]]
    relative_offsets = [sum(packet_sizes[:i]) for i in range(rows)]
    packet_origins = [p["base"]+directory_bytes+x for x in relative_offsets]
    directory_entry = p["base"]+p["row"]*4
    payload_start = packet_origins[p["row"]]+2
    payload_end = payload_start+p["lengths"][p["row"]]
    terminator = payload_end
    allocation_end = p["base"]+sum(packet_sizes)
    return {'rows': rows, 'directory_bytes': directory_bytes, 'packet_sizes': packet_sizes, 'relative_offsets': relative_offsets, 'packet_origins': packet_origins, 'directory_entry': directory_entry, 'payload_start': payload_start, 'payload_end': payload_end, 'terminator': terminator, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'lengths': [1, 0, 3, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [4, 3, 6, 4, 5], 'relative_offsets': [0, 4, 7, 13, 17], 'packet_origins': [29, 33, 36, 42, 46], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 32, 'terminator': 32, 'allocation_end': 51}), ({'lengths': [2, 0, 4, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 7, 4, 5], 'relative_offsets': [0, 5, 8, 15, 19], 'packet_origins': [29, 34, 37, 44, 48], 'directory_entry': 13, 'payload_start': 36, 'payload_end': 36, 'terminator': 36, 'allocation_end': 53}), ({'lengths': [3, 0, 5, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 8, 4, 5], 'relative_offsets': [0, 6, 9, 17, 21], 'packet_origins': [29, 35, 38, 46, 50], 'directory_entry': 17, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 55}), ({'lengths': [4, 0, 6, 1, 2], 'row': 0, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 9, 4, 5], 'relative_offsets': [0, 7, 10, 19, 23], 'packet_origins': [29, 36, 39, 48, 52], 'directory_entry': 9, 'payload_start': 31, 'payload_end': 35, 'terminator': 35, 'allocation_end': 57}), ({'lengths': [5, 0, 7, 1, 2], 'row': 1, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 10, 4, 5], 'relative_offsets': [0, 8, 11, 21, 25], 'packet_origins': [29, 37, 40, 50, 54], 'directory_entry': 13, 'payload_start': 39, 'payload_end': 39, 'terminator': 39, 'allocation_end': 59}), ({'lengths': [6, 0, 8, 1, 2], 'row': 2, 'base': 9}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 11, 4, 5], 'relative_offsets': [0, 9, 12, 23, 27], 'packet_origins': [29, 38, 41, 52, 56], 'directory_entry': 17, 'payload_start': 43, 'payload_end': 51, 'terminator': 51, 'allocation_end': 61})], 2: [({'lengths': [2, 0, 3, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [5, 3, 6, 4, 7], 'relative_offsets': [0, 5, 8, 14, 18], 'packet_origins': [38, 43, 46, 52, 56], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 42, 'terminator': 42, 'allocation_end': 63}), ({'lengths': [3, 0, 4, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 7, 4, 7], 'relative_offsets': [0, 6, 9, 16, 20], 'packet_origins': [38, 44, 47, 54, 58], 'directory_entry': 22, 'payload_start': 46, 'payload_end': 46, 'terminator': 46, 'allocation_end': 65}), ({'lengths': [4, 0, 5, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 8, 4, 7], 'relative_offsets': [0, 7, 10, 18, 22], 'packet_origins': [38, 45, 48, 56, 60], 'directory_entry': 26, 'payload_start': 50, 'payload_end': 55, 'terminator': 55, 'allocation_end': 67}), ({'lengths': [5, 0, 6, 1, 4], 'row': 0, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 9, 4, 7], 'relative_offsets': [0, 8, 11, 20, 24], 'packet_origins': [38, 46, 49, 58, 62], 'directory_entry': 18, 'payload_start': 40, 'payload_end': 45, 'terminator': 45, 'allocation_end': 69}), ({'lengths': [6, 0, 7, 1, 4], 'row': 1, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 10, 4, 7], 'relative_offsets': [0, 9, 12, 22, 26], 'packet_origins': [38, 47, 50, 60, 64], 'directory_entry': 22, 'payload_start': 49, 'payload_end': 49, 'terminator': 49, 'allocation_end': 71}), ({'lengths': [7, 0, 8, 1, 4], 'row': 2, 'base': 18}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 11, 4, 7], 'relative_offsets': [0, 10, 13, 24, 28], 'packet_origins': [38, 48, 51, 62, 66], 'directory_entry': 26, 'payload_start': 53, 'payload_end': 61, 'terminator': 61, 'allocation_end': 73})], 3: [({'lengths': [3, 0, 3, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [6, 3, 6, 4, 9], 'relative_offsets': [0, 6, 9, 15, 19], 'packet_origins': [47, 53, 56, 62, 66], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 52, 'terminator': 52, 'allocation_end': 75}), ({'lengths': [4, 0, 4, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 7, 4, 9], 'relative_offsets': [0, 7, 10, 17, 21], 'packet_origins': [47, 54, 57, 64, 68], 'directory_entry': 31, 'payload_start': 56, 'payload_end': 56, 'terminator': 56, 'allocation_end': 77}), ({'lengths': [5, 0, 5, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 8, 4, 9], 'relative_offsets': [0, 8, 11, 19, 23], 'packet_origins': [47, 55, 58, 66, 70], 'directory_entry': 35, 'payload_start': 60, 'payload_end': 65, 'terminator': 65, 'allocation_end': 79}), ({'lengths': [6, 0, 6, 1, 6], 'row': 0, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 9, 4, 9], 'relative_offsets': [0, 9, 12, 21, 25], 'packet_origins': [47, 56, 59, 68, 72], 'directory_entry': 27, 'payload_start': 49, 'payload_end': 55, 'terminator': 55, 'allocation_end': 81}), ({'lengths': [7, 0, 7, 1, 6], 'row': 1, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 10, 4, 9], 'relative_offsets': [0, 10, 13, 23, 27], 'packet_origins': [47, 57, 60, 70, 74], 'directory_entry': 31, 'payload_start': 59, 'payload_end': 59, 'terminator': 59, 'allocation_end': 83}), ({'lengths': [8, 0, 8, 1, 6], 'row': 2, 'base': 27}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 11, 4, 9], 'relative_offsets': [0, 11, 14, 25, 29], 'packet_origins': [47, 58, 61, 72, 76], 'directory_entry': 35, 'payload_start': 63, 'payload_end': 71, 'terminator': 71, 'allocation_end': 85})], 4: [({'lengths': [4, 0, 3, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [7, 3, 6, 4, 11], 'relative_offsets': [0, 7, 10, 16, 20], 'packet_origins': [56, 63, 66, 72, 76], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 62, 'terminator': 62, 'allocation_end': 87}), ({'lengths': [5, 0, 4, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 7, 4, 11], 'relative_offsets': [0, 8, 11, 18, 22], 'packet_origins': [56, 64, 67, 74, 78], 'directory_entry': 40, 'payload_start': 66, 'payload_end': 66, 'terminator': 66, 'allocation_end': 89}), ({'lengths': [6, 0, 5, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 8, 4, 11], 'relative_offsets': [0, 9, 12, 20, 24], 'packet_origins': [56, 65, 68, 76, 80], 'directory_entry': 44, 'payload_start': 70, 'payload_end': 75, 'terminator': 75, 'allocation_end': 91}), ({'lengths': [7, 0, 6, 1, 8], 'row': 0, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 9, 4, 11], 'relative_offsets': [0, 10, 13, 22, 26], 'packet_origins': [56, 66, 69, 78, 82], 'directory_entry': 36, 'payload_start': 58, 'payload_end': 65, 'terminator': 65, 'allocation_end': 93}), ({'lengths': [8, 0, 7, 1, 8], 'row': 1, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 10, 4, 11], 'relative_offsets': [0, 11, 14, 24, 28], 'packet_origins': [56, 67, 70, 80, 84], 'directory_entry': 40, 'payload_start': 69, 'payload_end': 69, 'terminator': 69, 'allocation_end': 95}), ({'lengths': [9, 0, 8, 1, 8], 'row': 2, 'base': 36}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 11, 4, 11], 'relative_offsets': [0, 12, 15, 26, 30], 'packet_origins': [56, 68, 71, 82, 86], 'directory_entry': 44, 'payload_start': 73, 'payload_end': 81, 'terminator': 81, 'allocation_end': 97})], 5: [({'lengths': [5, 0, 3, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [8, 3, 6, 4, 13], 'relative_offsets': [0, 8, 11, 17, 21], 'packet_origins': [65, 73, 76, 82, 86], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 72, 'terminator': 72, 'allocation_end': 99}), ({'lengths': [6, 0, 4, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [9, 3, 7, 4, 13], 'relative_offsets': [0, 9, 12, 19, 23], 'packet_origins': [65, 74, 77, 84, 88], 'directory_entry': 49, 'payload_start': 76, 'payload_end': 76, 'terminator': 76, 'allocation_end': 101}), ({'lengths': [7, 0, 5, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [10, 3, 8, 4, 13], 'relative_offsets': [0, 10, 13, 21, 25], 'packet_origins': [65, 75, 78, 86, 90], 'directory_entry': 53, 'payload_start': 80, 'payload_end': 85, 'terminator': 85, 'allocation_end': 103}), ({'lengths': [8, 0, 6, 1, 10], 'row': 0, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [11, 3, 9, 4, 13], 'relative_offsets': [0, 11, 14, 23, 27], 'packet_origins': [65, 76, 79, 88, 92], 'directory_entry': 45, 'payload_start': 67, 'payload_end': 75, 'terminator': 75, 'allocation_end': 105}), ({'lengths': [9, 0, 7, 1, 10], 'row': 1, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [12, 3, 10, 4, 13], 'relative_offsets': [0, 12, 15, 25, 29], 'packet_origins': [65, 77, 80, 90, 94], 'directory_entry': 49, 'payload_start': 79, 'payload_end': 79, 'terminator': 79, 'allocation_end': 107}), ({'lengths': [10, 0, 8, 1, 10], 'row': 2, 'base': 45}, {'rows': 5, 'directory_bytes': 20, 'packet_sizes': [13, 3, 11, 4, 13], 'relative_offsets': [0, 13, 16, 27, 31], 'packet_origins': [65, 78, 81, 92, 96], 'directory_entry': 53, 'payload_start': 83, 'payload_end': 91, 'terminator': 91, 'allocation_end': 109})]}
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 allocation_end.

Each scanline is a packet with a two-byte tag, a four-byte absolute-offset directory entry, and a caller-specified encoded payload length. The directory precedes packet bytes; a trailing one-byte terminator follows each packet. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access