FA-37776 / Table interactions / Open access
Printed table page partition: final page flush · case 01
The table final page flush result violates the stipulated printed table page partition contract.
ROOT CAUSE
The final page flush decision uses 'if False: pages.append(page)' instead of 'if page: pages.append(page)'.
VERIFIED REPAIR
Apply the complete final page flush rule: if page: pages.append(page).
Unsuccessful approach: The attempted repair 'pages.append(page)' still loses a required part of the table contract.
Case contract
Print pages reserve header/footer height, pack whole row/detail blocks in order, allow exact fits, place oversized rows alone with an overflow marker, never generate empty pages, number from one, and repeat headers only when requested.
Why this case matters
An offline table UI model isolates printed table page partition, including adversarial row/column relationships.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rows, header, footer, page_height, repeat, keep_detail):
capacity=page_height-header-footer
if capacity<=0: return {'error':'no-body-space','pages':[]}
pages=[]; page=[]; used=0
for row in rows:
h=row['height']+(row.get('detail_height',0) if keep_detail else 0)
if page and used+h>capacity:
pages.append(page); page=[]; used=0
page.append({'id':row['id'],'height':h,'overflow':h>capacity})
used+=h
if False: pages.append(page)
return {'error':None,'pages':[{'number':i+1,'header':repeat or i==0,'footer':True,'rows':p,'used':sum(r['height'] for r in p),'body_limit':capacity} for i,p in enumerate(pages)]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':1+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 2, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 4, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 2:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':2+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 3, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 5, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 3:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':3+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 4, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 4:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':4+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 5, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 5:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 6, 'overflow': False}], 'used': 6, 'body_limit': 7}, {'number': 3, 'header': False, 'footer': True, 'rows': [{'id': 'd', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| exactly filled body | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 4, 'id': 'b', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 4, 'id': 'b', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 2, 'id': 'c', 'overflow': False}, {'height': 2, 'id': 'd', 'overflow': False}], 'used': 4}]} | Failed |
| oversized row | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 11, 'id': 'a', 'overflow': True}], 'used': 11}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 11, 'id': 'a', 'overflow': True}], 'used': 11}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 2, 'id': 'b', 'overflow': False}], 'used': 2}]} | Failed |
| detail blocks | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 7, 'id': 'a', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 7, 'id': 'a', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 7, 'id': 'b', 'overflow': False}], 'used': 7}]} | Failed |
| detail excluded | {'error': None, 'pages': []} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 3, 'id': 'b', 'overflow': False}], 'used': 6}]} | Failed |
| zero body | {'error': 'no-body-space', 'pages': []} | {'error': 'no-body-space', 'pages': []} | Passed |
| negative body | {'error': 'no-body-space', 'pages': []} | {'error': 'no-body-space', 'pages': []} | Passed |
| nonexact overflow | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 4, 'id': 'a', 'overflow': False}], 'used': 4}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 4, 'id': 'a', 'overflow': False}], 'used': 4}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 4, 'id': 'b', 'overflow': False}, {'height': 3, 'id': 'c', 'overflow': False}], 'used': 7}]} | Failed |
| reset capacity | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}], 'used': 3}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}], 'used': 3}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 5, 'id': 'b', 'overflow': False}, {'height': 2, 'id': 'c', 'overflow': False}], 'used': 7}]} | Failed |
| empty print | {'error': None, 'pages': []} | {'error': None, 'pages': []} | Passed |
SHA-256 / 10c1aa55e6963e1e04475c0e69066b04b2c2984de9c257dca0d28f88c43df3d0
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rows, header, footer, page_height, repeat, keep_detail):
capacity=page_height-header-footer
if capacity<=0: return {'error':'no-body-space','pages':[]}
pages=[]; page=[]; used=0
for row in rows:
h=row['height']+(row.get('detail_height',0) if keep_detail else 0)
if page and used+h>capacity:
pages.append(page); page=[]; used=0
page.append({'id':row['id'],'height':h,'overflow':h>capacity})
used+=h
pages.append(page)
return {'error':None,'pages':[{'number':i+1,'header':repeat or i==0,'footer':True,'rows':p,'used':sum(r['height'] for r in p),'body_limit':capacity} for i,p in enumerate(pages)]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':1+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 2, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 4, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 2:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':2+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 3, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 5, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 3:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':3+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 4, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 4:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':4+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 5, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 5:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 6, 'overflow': False}], 'used': 6, 'body_limit': 7}, {'number': 3, 'header': False, 'footer': True, 'rows': [{'id': 'd', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| exactly filled body | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 4, 'id': 'b', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 2, 'id': 'c', 'overflow': False}, {'height': 2, 'id': 'd', 'overflow': False}], 'used': 4}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 4, 'id': 'b', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 2, 'id': 'c', 'overflow': False}, {'height': 2, 'id': 'd', 'overflow': False}], 'used': 4}]} | Passed |
| oversized row | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 11, 'id': 'a', 'overflow': True}], 'used': 11}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 2, 'id': 'b', 'overflow': False}], 'used': 2}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 11, 'id': 'a', 'overflow': True}], 'used': 11}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 2, 'id': 'b', 'overflow': False}], 'used': 2}]} | Passed |
| detail blocks | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 7, 'id': 'a', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 7, 'id': 'b', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 7, 'id': 'a', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 7, 'id': 'b', 'overflow': False}], 'used': 7}]} | Passed |
| detail excluded | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 3, 'id': 'b', 'overflow': False}], 'used': 6}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 3, 'id': 'b', 'overflow': False}], 'used': 6}]} | Passed |
| zero body | {'error': 'no-body-space', 'pages': []} | {'error': 'no-body-space', 'pages': []} | Passed |
| negative body | {'error': 'no-body-space', 'pages': []} | {'error': 'no-body-space', 'pages': []} | Passed |
| nonexact overflow | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 4, 'id': 'a', 'overflow': False}], 'used': 4}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 4, 'id': 'b', 'overflow': False}, {'height': 3, 'id': 'c', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 4, 'id': 'a', 'overflow': False}], 'used': 4}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 4, 'id': 'b', 'overflow': False}, {'height': 3, 'id': 'c', 'overflow': False}], 'used': 7}]} | Passed |
| reset capacity | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}], 'used': 3}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 5, 'id': 'b', 'overflow': False}, {'height': 2, 'id': 'c', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}], 'used': 3}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 5, 'id': 'b', 'overflow': False}, {'height': 2, 'id': 'c', 'overflow': False}], 'used': 7}]} | Passed |
| empty print | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [], 'used': 0}]} | {'error': None, 'pages': []} | Failed |
SHA-256 / fe15a9e3978945c6fd190e4a8aa08a189269024b251ba26789ad4d631dd2b606
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rows, header, footer, page_height, repeat, keep_detail):
capacity=page_height-header-footer
if capacity<=0: return {'error':'no-body-space','pages':[]}
pages=[]; page=[]; used=0
for row in rows:
h=row['height']+(row.get('detail_height',0) if keep_detail else 0)
if page and used+h>capacity:
pages.append(page); page=[]; used=0
page.append({'id':row['id'],'height':h,'overflow':h>capacity})
used+=h
if page: pages.append(page)
return {'error':None,'pages':[{'number':i+1,'header':repeat or i==0,'footer':True,'rows':p,'used':sum(r['height'] for r in p),'body_limit':capacity} for i,p in enumerate(pages)]}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':1+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 2, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 4, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 2:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':2+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 3, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 5, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 3:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':3+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 4, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 4:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':4+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 5, 'overflow': False}, {'id': 'd', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
if N == 5:
check('exactly filled body', solve([{'id':'a','height':3},{'id':'b','height':4},{'id':'c','height':5+1},{'id':'d','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 4, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'c', 'height': 6, 'overflow': False}], 'used': 6, 'body_limit': 7}, {'number': 3, 'header': False, 'footer': True, 'rows': [{'id': 'd', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('oversized row', solve([{'id':'a','height':11},{'id':'b','height':2}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 11, 'overflow': True}], 'used': 11, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 2, 'overflow': False}], 'used': 2, 'body_limit': 7}]})
check('detail blocks', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, True), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}, {'number': 2, 'header': True, 'footer': True, 'rows': [{'id': 'b', 'height': 7, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('detail excluded', solve([{'id':'a','height':3,'detail_height':4},{'id':'b','height':3,'detail_height':4}], 2, 1, 10, True, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}, {'id': 'b', 'height': 3, 'overflow': False}], 'used': 6, 'body_limit': 7}]})
check('zero body', solve([{'id':'a','height':1}], 2, 1, 3, True, False), {'error': 'no-body-space', 'pages': []})
check('negative body', solve([], 2, 2, 3, False, False), {'error': 'no-body-space', 'pages': []})
check('nonexact overflow', solve([{'id':'a','height':4},{'id':'b','height':4},{'id':'c','height':3}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 4, 'overflow': False}], 'used': 4, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 4, 'overflow': False}, {'id': 'c', 'height': 3, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('reset capacity', solve([{'id':'a','height':3},{'id':'b','height':5},{'id':'c','height':2}], 2, 1, 10, False, False), {'error': None, 'pages': [{'number': 1, 'header': True, 'footer': True, 'rows': [{'id': 'a', 'height': 3, 'overflow': False}], 'used': 3, 'body_limit': 7}, {'number': 2, 'header': False, 'footer': True, 'rows': [{'id': 'b', 'height': 5, 'overflow': False}, {'id': 'c', 'height': 2, 'overflow': False}], 'used': 7, 'body_limit': 7}]})
check('empty print', solve([], 2, 1, 10, False, False), {'error': None, 'pages': []})
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| exactly filled body | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 4, 'id': 'b', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 2, 'id': 'c', 'overflow': False}, {'height': 2, 'id': 'd', 'overflow': False}], 'used': 4}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 4, 'id': 'b', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 2, 'id': 'c', 'overflow': False}, {'height': 2, 'id': 'd', 'overflow': False}], 'used': 4}]} | Passed |
| oversized row | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 11, 'id': 'a', 'overflow': True}], 'used': 11}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 2, 'id': 'b', 'overflow': False}], 'used': 2}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 11, 'id': 'a', 'overflow': True}], 'used': 11}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 2, 'id': 'b', 'overflow': False}], 'used': 2}]} | Passed |
| detail blocks | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 7, 'id': 'a', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 7, 'id': 'b', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 7, 'id': 'a', 'overflow': False}], 'used': 7}, {'body_limit': 7, 'footer': True, 'header': True, 'number': 2, 'rows': [{'height': 7, 'id': 'b', 'overflow': False}], 'used': 7}]} | Passed |
| detail excluded | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 3, 'id': 'b', 'overflow': False}], 'used': 6}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}, {'height': 3, 'id': 'b', 'overflow': False}], 'used': 6}]} | Passed |
| zero body | {'error': 'no-body-space', 'pages': []} | {'error': 'no-body-space', 'pages': []} | Passed |
| negative body | {'error': 'no-body-space', 'pages': []} | {'error': 'no-body-space', 'pages': []} | Passed |
| nonexact overflow | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 4, 'id': 'a', 'overflow': False}], 'used': 4}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 4, 'id': 'b', 'overflow': False}, {'height': 3, 'id': 'c', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 4, 'id': 'a', 'overflow': False}], 'used': 4}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 4, 'id': 'b', 'overflow': False}, {'height': 3, 'id': 'c', 'overflow': False}], 'used': 7}]} | Passed |
| reset capacity | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}], 'used': 3}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 5, 'id': 'b', 'overflow': False}, {'height': 2, 'id': 'c', 'overflow': False}], 'used': 7}]} | {'error': None, 'pages': [{'body_limit': 7, 'footer': True, 'header': True, 'number': 1, 'rows': [{'height': 3, 'id': 'a', 'overflow': False}], 'used': 3}, {'body_limit': 7, 'footer': True, 'header': False, 'number': 2, 'rows': [{'height': 5, 'id': 'b', 'overflow': False}, {'height': 2, 'id': 'c', 'overflow': False}], 'used': 7}]} | Passed |
| empty print | {'error': None, 'pages': []} | {'error': None, 'pages': []} | Passed |
SHA-256 / ca703d66fc1a115725eb026e4211d98d776e806d5b96fd1eda3dc8f378f645dd
Verification & scope
Row blocks have positive finite heights and header/footer heights are nonnegative; actual print layout is outside scope. Deterministic offline table UI model; no browser, DOM, framework, or standards conformance is claimed. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:43:04.517141+00:00.
Case digest / 364596cc0c4ac48a47711fb9bde4ea7438e46ad554ef24528038ad67aa623bbd