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

N = 1
observations = []
def solve(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']=x['width']
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':len(r['leaves']), 'width':r['width'], 'first':r['leaves'][0], 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':r['key'][0] is None, 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']=max(runs[-1]['width'],x['width'])
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':len(r['leaves']), 'width':r['width'], 'first':r['leaves'][0], 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':r['key'][0] is None, 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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 group width result violates the stipulated grouped table header runs contract.

Construct contiguous visible leaf runs keyed by exact group and pane, retaining leaf order and width sums. A missing group is a blank placeholder; an empty group string is an actual named group. Group resize handles require at least two visible leaves.

split: open-access


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

N = 1
observations = []
def solve(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']+=x['width']
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':1, 'width':r['width'], 'first':r['leaves'][0], 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':r['key'][0] is None, 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']+=x['width']
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':max(1,len(r['leaves'])-1), 'width':r['width'], 'first':r['leaves'][0], 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':r['key'][0] is None, 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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 span cardinality result violates the stipulated grouped table header runs contract.

Construct contiguous visible leaf runs keyed by exact group and pane, retaining leaf order and width sums. A missing group is a blank placeholder; an empty group string is an actual named group. Group resize handles require at least two visible leaves.

split: open-access


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

N = 1
observations = []
def solve(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']+=x['width']
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':len(r['leaves']), 'width':r['width'], 'first':r['leaves'][-1], 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':r['key'][0] is None, 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']+=x['width']
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':len(r['leaves']), 'width':r['width'], 'first':r['leaves'][1] if len(r['leaves'])>1 else None, 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':r['key'][0] is None, 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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 group leading leaf result violates the stipulated grouped table header runs contract.

Construct contiguous visible leaf runs keyed by exact group and pane, retaining leaf order and width sums. A missing group is a blank placeholder; an empty group string is an actual named group. Group resize handles require at least two visible leaves.

split: open-access


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

N = 1
observations = []
def solve(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']+=x['width']
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':len(r['leaves']), 'width':r['width'], 'first':r['leaves'][0], 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':not r['key'][0], 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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(leaves, hidden, pins):
    v = [x for x in leaves if x['id'] not in hidden]
    runs=[]
    for x in v:
        pane=pins.get(x['id'], 'center')
        key=(x.get('group'),pane)
        if runs and runs[-1]['key']==key:
            runs[-1]['leaves'].append(x['id'])
            runs[-1]['width']+=x['width']
        else: runs.append({'key':key,'leaves':[x['id']],'width':x['width']})
    return [{'group':r['key'][0], 'pane':r['key'][1], 'span':len(r['leaves']), 'width':r['width'], 'first':r['leaves'][0], 'last':r['leaves'][-1], 'leaf_ids':r['leaves'], 'blank':False, 'resizable':len(r['leaves'])>1} for r in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*1},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 5, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 2:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*2},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 3:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*3},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 9, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 4:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*4},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 11, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

if N == 5:
    check('contiguous group', solve([{'id':'a','group':'G','width':2*5},{'id':'b','group':'G','width':3},{'id':'c','group':'H','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 2, 'width': 13, 'first': 'a', 'last': 'b', 'leaf_ids': ['a', 'b'], 'blank': False, 'resizable': True}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('pin splits group', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], [], {'a':'left'}), [{'group': 'G', 'pane': 'left', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 2, 'width': 7, 'first': 'b', 'last': 'c', 'leaf_ids': ['b', 'c'], 'blank': False, 'resizable': True}])
    check('hidden leaves', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'G','width':3},{'id':'c','group':'G','width':4}], ['a','b'], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('blank versus empty', solve([{'id':'a','width':2},{'id':'b','group':'','width':3}], [], {}), [{'group': None, 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': True, 'resizable': False}, {'group': '', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}])
    check('separated groups', solve([{'id':'a','group':'G','width':2},{'id':'b','group':'H','width':3},{'id':'c','group':'G','width':4}], [], {}), [{'group': 'G', 'pane': 'center', 'span': 1, 'width': 2, 'first': 'a', 'last': 'a', 'leaf_ids': ['a'], 'blank': False, 'resizable': False}, {'group': 'H', 'pane': 'center', 'span': 1, 'width': 3, 'first': 'b', 'last': 'b', 'leaf_ids': ['b'], 'blank': False, 'resizable': False}, {'group': 'G', 'pane': 'center', 'span': 1, 'width': 4, 'first': 'c', 'last': 'c', 'leaf_ids': ['c'], 'blank': False, 'resizable': False}])
    check('empty header', solve([], [], {}), [])

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 placeholder class result violates the stipulated grouped table header runs contract.

Construct contiguous visible leaf runs keyed by exact group and pane, retaining leaf order and width sums. A missing group is a blank placeholder; an empty group string is an actual named group. Group resize handles require at least two visible leaves.

split: open-access