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

N = 1
observations = []
def solve(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if False: return order
    remaining=[c for c in order if c not in block]
    index=(remaining.index(target) if target in remaining else 0)+(side=='after')
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target==visible[0] if visible else True: return order
    remaining=[c for c in order if c not in block]
    index=(remaining.index(target) if target in remaining else 0)+(side=='after')
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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 table hidden target refusal result violates the stipulated table column drag transaction contract.

Move selected columns as a schema-ordered block relative to a visible nonmoving target, preserve hidden columns, reject any locked or pane-incompatible member, and compute insertion after removing the whole source block.

split: open-access


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

N = 1
observations = []
def solve(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c!=block[0]]
    index=(remaining.index(target) if target in remaining else 0)+(side=='after')
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c not in moving[:1]]
    index=(remaining.index(target) if target in remaining else 0)+(side=='after')
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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 table remove entire block result violates the stipulated table column drag transaction contract.

Move selected columns as a schema-ordered block relative to a visible nonmoving target, preserve hidden columns, reject any locked or pane-incompatible member, and compute insertion after removing the whole source block.

split: open-access


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

N = 1
observations = []
def solve(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c not in block]
    index=(order.index(target) if target in remaining else 0)+(side=='after')
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c not in block]
    index=(max(0,remaining.index(target)-1) if target in remaining else 0)+(side=='after')
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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 table post removal insertion result violates the stipulated table column drag transaction contract.

Move selected columns as a schema-ordered block relative to a visible nonmoving target, preserve hidden columns, reject any locked or pane-incompatible member, and compute insertion after removing the whole source block.

split: open-access


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

N = 1
observations = []
def solve(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c not in block]
    index=(remaining.index(target) if target in remaining else 0)+0
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c not in block]
    index=(remaining.index(target) if target in remaining else 0)+1
    return remaining[:index]+block+remaining[index:]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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 table drop side result violates the stipulated table column drag transaction contract.

Move selected columns as a schema-ordered block relative to a visible nonmoving target, preserve hidden columns, reject any locked or pane-incompatible member, and compute insertion after removing the whole source block.

split: open-access


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

N = 1
observations = []
def solve(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c not in block]
    index=(remaining.index(target) if target in remaining else 0)+(side=='after')
    return remaining[:index]+block
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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(order, moving, target, side, hidden, pinned, locked):
    block=[c for c in order if c in moving]
    if not block or target in block: return order
    if any(c in locked for c in block): return order
    if any(pinned.get(c,'center')!=pinned.get(target,'center') for c in block): return order
    visible=[c for c in order if c not in hidden]
    if target not in visible: return order
    remaining=[c for c in order if c not in block]
    index=(remaining.index(target) if target in remaining else 0)+(side=='after')
    return block+remaining
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(1)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e1'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 2:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(2)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e2'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 3:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(3)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e3'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 4:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(4)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e4'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

if N == 5:
    check('discontiguous selected columns', solve(['a','b','c','d','e'+str(5)], ['c','a'], 'd', 'after', [], {}, []), ['b', 'd', 'a', 'c', 'e5'])
    check('before target', solve(['a','b','c','d'], ['d'], 'b', 'before', [], {}, []), ['a', 'd', 'b', 'c'])
    check('self drop on second', solve(['a','b','c'], ['a','c'], 'c', 'before', [], {}, []), ['a', 'b', 'c'])
    check('mixed locked block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {}, ['b']), ['a', 'b', 'c'])
    check('mixed pane block', solve(['a','b','c'], ['a','b'], 'c', 'after', [], {'b':'left'}, []), ['a', 'b', 'c'])
    check('hidden target', solve(['a','b','c','d'], ['a'], 'c', 'after', ['b','c'], {}, []), ['a', 'b', 'c', 'd'])
    check('no drag', solve(['a'], [], 'a', 'before', [], {}, []), ['a'])

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 table insert block once result violates the stipulated table column drag transaction contract.

Move selected columns as a schema-ordered block relative to a visible nonmoving target, preserve hidden columns, reject any locked or pane-incompatible member, and compute insertion after removing the whole source block.

split: open-access


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

N = 1
observations = []
def solve(rows, expanded, hidden, can_expand, heights, default_height):
    out=[]
    for row in rows:
        key=row['id']
        if False: continue
        out.append({'key':('data',key),'kind':'data','owner':key,'height':row['height'],'selectable':True})
        if key not in expanded or key not in can_expand: continue
        out.append({'key':('detail',key),'kind':'detail','owner':key,'height':heights.get(key,default_height),'selectable':False})
    return {'items':out,'total':sum(x['height'] for x in out),'data_count':sum(x['kind']=='data' for x in out),'expanded': [r['id'] for r in rows if r['id'] in expanded and r['id'] in can_expand and r['id'] not in hidden]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':1+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 6, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 13, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 2:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':2+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 7, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 14, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 3:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':3+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 8, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 15, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 4:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':4+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 9, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 16, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 5:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':5+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 10, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 17, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

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(rows, expanded, hidden, can_expand, heights, default_height):
    out=[]
    for row in rows:
        key=row['id']
        if key in hidden[:1]: continue
        out.append({'key':('data',key),'kind':'data','owner':key,'height':row['height'],'selectable':True})
        if key not in expanded or key not in can_expand: continue
        out.append({'key':('detail',key),'kind':'detail','owner':key,'height':heights.get(key,default_height),'selectable':False})
    return {'items':out,'total':sum(x['height'] for x in out),'data_count':sum(x['kind']=='data' for x in out),'expanded': [r['id'] for r in rows if r['id'] in expanded and r['id'] in can_expand and r['id'] not in hidden]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':1+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 6, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 13, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 2:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':2+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 7, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 14, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 3:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':3+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 8, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 15, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 4:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':4+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 9, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 16, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 5:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':5+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 10, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 17, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

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 table hidden detail owner result violates the stipulated table expandable detail rows contract.

Detail rows have namespaced stable render keys, follow their visible expandable owner, never count as selectable data rows, use measured heights including zero, and contribute to total content height while expansion state output excludes hidden or ineligible rows.

split: open-access


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

N = 1
observations = []
def solve(rows, expanded, hidden, can_expand, heights, default_height):
    out=[]
    for row in rows:
        key=row['id']
        if key in hidden: continue
        out.append({'key':key,'kind':'data','owner':key,'height':row['height'],'selectable':True})
        if key not in expanded or key not in can_expand: continue
        out.append({'key':('detail',key),'kind':'detail','owner':key,'height':heights.get(key,default_height),'selectable':False})
    return {'items':out,'total':sum(x['height'] for x in out),'data_count':sum(x['kind']=='data' for x in out),'expanded': [r['id'] for r in rows if r['id'] in expanded and r['id'] in can_expand and r['id'] not in hidden]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':1+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 6, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 13, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 2:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':2+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 7, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 14, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 3:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':3+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 8, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 15, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 4:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':4+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 9, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 16, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 5:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':5+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 10, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 17, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

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(rows, expanded, hidden, can_expand, heights, default_height):
    out=[]
    for row in rows:
        key=row['id']
        if key in hidden: continue
        out.append({'key':('row',rows.index(row)),'kind':'data','owner':key,'height':row['height'],'selectable':True})
        if key not in expanded or key not in can_expand: continue
        out.append({'key':('detail',key),'kind':'detail','owner':key,'height':heights.get(key,default_height),'selectable':False})
    return {'items':out,'total':sum(x['height'] for x in out),'data_count':sum(x['kind']=='data' for x in out),'expanded': [r['id'] for r in rows if r['id'] in expanded and r['id'] in can_expand and r['id'] not in hidden]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':1+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 6, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 13, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 2:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':2+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 7, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 14, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 3:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':3+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 8, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 15, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 4:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':4+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 9, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 16, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

if N == 5:
    check('expanded detail', solve([{'id':'a','height':3},{'id':'b','height':4}], ['a'], [], ['a','b'], {'a':5+5}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 10, 'selectable': False}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 17, 'data_count': 2, 'expanded': ['a']})
    check('zero measured detail', solve([{'id':'a','height':3}], ['a'], [], ['a'], {'a':0}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('detail', 'a'), 'kind': 'detail', 'owner': 'a', 'height': 0, 'selectable': False}], 'total': 3, 'data_count': 1, 'expanded': ['a']})
    check('nonexpandable row', solve([{'id':'a','height':3}], ['a'], [], [], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}], 'total': 3, 'data_count': 1, 'expanded': []})
    check('hidden expanded owners', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5}], ['a','b'], ['a','b'], ['a','b','c'], {}, 9), {'items': [{'key': ('data', 'c'), 'kind': 'data', 'owner': 'c', 'height': 5, 'selectable': True}], 'total': 5, 'data_count': 1, 'expanded': []})
    check('collapsed rows', solve([{'id':'a','height':3},{'id':'b','height':4}], [], [], ['a','b'], {}, 9), {'items': [{'key': ('data', 'a'), 'kind': 'data', 'owner': 'a', 'height': 3, 'selectable': True}, {'key': ('data', 'b'), 'kind': 'data', 'owner': 'b', 'height': 4, 'selectable': True}], 'total': 7, 'data_count': 2, 'expanded': []})
    check('empty', solve([], ['missing'], [], [], {}, 9), {'items': [], 'total': 0, 'data_count': 0, 'expanded': []})

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 table data render key result violates the stipulated table expandable detail rows contract.

Detail rows have namespaced stable render keys, follow their visible expandable owner, never count as selectable data rows, use measured heights including zero, and contribute to total content height while expansion state output excludes hidden or ineligible rows.

split: open-access