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

N = 1
observations = []
def solve(d):
    n=d['size']; internal=list(range(n//2-1,-1,-1)); levels=[]; start=0; width=1
    while start<n:
        levels.append([start,min(n-1,start+width-1)]); start+=width; width*=2
    return {'schedule': internal,
    'leaves': list(range(n//2,n)),
    'levels': levels,
    'unpaired_parent': n//2-1 if n>0 and n%2==0 else None,
    'dependencies': [[i,(i-1)//2] for i in range(1,n)],
    'internal_count': n//2}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 16}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 15]], 'unpaired_parent': 7, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 17}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15, 16], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 16]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 18}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 17]], 'unpaired_parent': 8, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 19}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 18]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 20}, {'schedule': [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 19]], 'unpaired_parent': 9, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4]], 'internal_count': 10})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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(d):
    n=d['size']; internal=list(range(n//2-1,-1,-1)); levels=[]; start=0; width=1
    while start<n:
        levels.append([start,min(n-1,start+width-1)]); start+=width; width*=2
    return {'schedule': internal,
    'leaves': list(range(n//2,n)),
    'levels': levels,
    'unpaired_parent': n//2-1 if n>0 and n%2==0 else None,
    'dependencies': [[i,i//2] for i in range(1,n//2)],
    'internal_count': n//2}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 16}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 15]], 'unpaired_parent': 7, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 17}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15, 16], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 16]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 18}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 17]], 'unpaired_parent': 8, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 19}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 18]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 20}, {'schedule': [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 19]], 'unpaired_parent': 9, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4]], 'internal_count': 10})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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 bounded bottomup schedule certificate reports an incorrect dependencies.

For building a complete zero-based binary heap of n nodes, report descending internal-node repair schedule, leaf indices, level spans as inclusive [start,end], right-child-less internal node, parent dependency edges [child,parent], and number of internal nodes. This describes the build work graph, not sorted output.

split: open-access


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

N = 1
observations = []
def solve(d):
    n=d['size']; internal=list(range(n//2-1,-1,-1)); levels=[]; start=0; width=1
    while start<n:
        levels.append([start,min(n-1,start+width-1)]); start+=width; width*=2
    return {'schedule': internal,
    'leaves': list(range(n//2,n)),
    'levels': levels,
    'unpaired_parent': n//2-1 if n>0 and n%2==0 else None,
    'dependencies': [[i,(i-1)//2] for i in range(1,n//2)],
    'internal_count': (n+1)//2}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 16}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 15]], 'unpaired_parent': 7, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 17}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15, 16], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 16]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 18}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 17]], 'unpaired_parent': 8, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 19}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 18]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 20}, {'schedule': [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 19]], 'unpaired_parent': 9, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4]], 'internal_count': 10})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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(d):
    n=d['size']; internal=list(range(n//2-1,-1,-1)); levels=[]; start=0; width=1
    while start<n:
        levels.append([start,min(n-1,start+width-1)]); start+=width; width*=2
    return {'schedule': internal,
    'leaves': list(range(n//2,n)),
    'levels': levels,
    'unpaired_parent': n//2-1 if n>0 and n%2==0 else None,
    'dependencies': [[i,(i-1)//2] for i in range(1,n//2)],
    'internal_count': max(0,n-1)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 16}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 15]], 'unpaired_parent': 7, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 17}, {'schedule': [7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [8, 9, 10, 11, 12, 13, 14, 15, 16], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 16]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3]], 'internal_count': 8})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 18}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 17]], 'unpaired_parent': 8, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 19}, {'schedule': [8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 18]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3]], 'internal_count': 9})], [({'size': 0}, {'schedule': [], 'leaves': [], 'levels': [], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 1}, {'schedule': [], 'leaves': [0], 'levels': [[0, 0]], 'unpaired_parent': None, 'dependencies': [], 'internal_count': 0}), ({'size': 2}, {'schedule': [0], 'leaves': [1], 'levels': [[0, 0], [1, 1]], 'unpaired_parent': 0, 'dependencies': [], 'internal_count': 1}), ({'size': 5}, {'schedule': [1, 0], 'leaves': [2, 3, 4], 'levels': [[0, 0], [1, 2], [3, 4]], 'unpaired_parent': None, 'dependencies': [[1, 0]], 'internal_count': 2}), ({'size': 8}, {'schedule': [3, 2, 1, 0], 'leaves': [4, 5, 6, 7], 'levels': [[0, 0], [1, 2], [3, 6], [7, 7]], 'unpaired_parent': 3, 'dependencies': [[1, 0], [2, 0], [3, 1]], 'internal_count': 4}), ({'size': 15}, {'schedule': [6, 5, 4, 3, 2, 1, 0], 'leaves': [7, 8, 9, 10, 11, 12, 13, 14], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14]], 'unpaired_parent': None, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]], 'internal_count': 7}), ({'size': 20}, {'schedule': [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], 'leaves': [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], 'levels': [[0, 0], [1, 2], [3, 6], [7, 14], [15, 19]], 'unpaired_parent': 9, 'dependencies': [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4]], 'internal_count': 10})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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 bounded bottomup schedule certificate reports an incorrect internal count.

For building a complete zero-based binary heap of n nodes, report descending internal-node repair schedule, leaf indices, level spans as inclusive [start,end], right-child-less internal node, parent dependency edges [child,parent], and number of internal nodes. This describes the build work graph, not sorted output.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': path[1:],
    'moved_keys': moved,
    'leaf_slot': i,
    'displaced': a[start],
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': list(reversed(path)),
    'moved_keys': moved,
    'leaf_slot': i,
    'displaced': a[start],
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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 bounded hole descent certificate reports an incorrect path.

A binary heap hole descent receives array keys and starting internal or leaf index. Repeatedly choose smaller existing child (left on ties), move that child into the hole, and stop at a leaf; the displaced root value is returned separately for later upward placement. Return path, moved keys, leaf slot, displaced value, remaining untouched slots, and comparison count between sibling pairs.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': path,
    'moved_keys': [a[x] for x in path[:-1]],
    'leaf_slot': i,
    'displaced': a[start],
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': path,
    'moved_keys': sorted(moved),
    'leaf_slot': i,
    'displaced': a[start],
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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 bounded hole descent certificate reports an incorrect moved keys.

A binary heap hole descent receives array keys and starting internal or leaf index. Repeatedly choose smaller existing child (left on ties), move that child into the hole, and stop at a leaf; the displaced root value is returned separately for later upward placement. Return path, moved keys, leaf slot, displaced value, remaining untouched slots, and comparison count between sibling pairs.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': path,
    'moved_keys': moved,
    'leaf_slot': len(a)-1,
    'displaced': a[start],
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': path,
    'moved_keys': moved,
    'leaf_slot': start,
    'displaced': a[start],
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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 bounded hole descent certificate reports an incorrect leaf slot.

A binary heap hole descent receives array keys and starting internal or leaf index. Repeatedly choose smaller existing child (left on ties), move that child into the hole, and stop at a leaf; the displaced root value is returned separately for later upward placement. Return path, moved keys, leaf slot, displaced value, remaining untouched slots, and comparison count between sibling pairs.

split: open-access


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

N = 1
observations = []
def solve(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': path,
    'moved_keys': moved,
    'leaf_slot': i,
    'displaced': a[i],
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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(d):
    a=d['keys']; start=d['start']; path=[start]; moved=[]; compares=0; i=start
    while 2*i+1<len(a):
        l=2*i+1; r=l+1; j=l
        if r<len(a):
            compares+=1
            if a[r]<a[l]: j=r
        moved.append(a[j]); path.append(j); i=j
    return {'path': path,
    'moved_keys': moved,
    'leaf_slot': i,
    'displaced': min(a),
    'untouched': [j for j in range(len(a)) if j not in path],
    'comparisons': compares}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [2, 4, 2, 5, 6, 7, 8], 'start': 1}, {'path': [1, 3], 'moved_keys': [5], 'leaf_slot': 3, 'displaced': 4, 'untouched': [0, 2, 4, 5, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [3, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [4, 4, 2, 5, 6, 7, 8], 'start': 3}, {'path': [3], 'moved_keys': [], 'leaf_slot': 3, 'displaced': 5, 'untouched': [0, 1, 2, 4, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [5, 4, 2, 5, 6, 7, 8], 'start': 4}, {'path': [4], 'moved_keys': [], 'leaf_slot': 4, 'displaced': 6, 'untouched': [0, 1, 2, 3, 5, 6], 'comparisons': 0})], [({'keys': [5], 'start': 0}, {'path': [0], 'moved_keys': [], 'leaf_slot': 0, 'displaced': 5, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 2], 'start': 0}, {'path': [0, 1], 'moved_keys': [2], 'leaf_slot': 1, 'displaced': 9, 'untouched': [], 'comparisons': 0}), ({'keys': [9, 5, 8, 2, 7, 6, 4], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [5, 2], 'leaf_slot': 3, 'displaced': 9, 'untouched': [2, 4, 5, 6], 'comparisons': 2}), ({'keys': [8, 2, 2, 5, 6, 7], 'start': 0}, {'path': [0, 1, 3], 'moved_keys': [2, 5], 'leaf_slot': 3, 'displaced': 8, 'untouched': [2, 4, 5], 'comparisons': 2}), ({'keys': [0, 9, 3, 4, 2, 8, 6, 7, 8, 5], 'start': 1}, {'path': [1, 4, 9], 'moved_keys': [2, 5], 'leaf_slot': 9, 'displaced': 9, 'untouched': [0, 2, 3, 5, 6, 7, 8], 'comparisons': 1}), ({'keys': [1, 4, 2, 5, 6, 7, 8], 'start': 2}, {'path': [2, 5], 'moved_keys': [7], 'leaf_slot': 5, 'displaced': 2, 'untouched': [0, 1, 3, 4, 6], 'comparisons': 1}), ({'keys': [6, 4, 2, 5, 6, 7, 8], 'start': 5}, {'path': [5], 'moved_keys': [], 'leaf_slot': 5, 'displaced': 7, 'untouched': [0, 1, 2, 3, 4, 6], 'comparisons': 0})]][N-1]
check('regression certificate 1', solve(cases[0][0]), cases[0][1])
check('regression certificate 2', solve(cases[1][0]), cases[1][1])
check('regression certificate 3', solve(cases[2][0]), cases[2][1])
check('regression certificate 4', solve(cases[3][0]), cases[3][1])
check('regression certificate 5', solve(cases[4][0]), cases[4][1])
check('regression certificate 6', solve(cases[5][0]), cases[5][1])
check('variant-dependent certificate', solve(cases[6][0]), cases[6][1])
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 bounded hole descent certificate reports an incorrect displaced.

A binary heap hole descent receives array keys and starting internal or leaf index. Repeatedly choose smaller existing child (left on ties), move that child into the hole, and stop at a leaf; the displaced root value is returned separately for later upward placement. Return path, moved keys, leaf slot, displaced value, remaining untouched slots, and comparison count between sibling pairs.

split: open-access