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

N = 1
observations = []
def solve(d):
    return {'operand-cost':(sum(len(x['operands']) for x in d['rows'] if not x['system'])), 'row-add-gate':(sum(not x['system'] for x in d['rows'])<=d['row_limit']), 'group-cost':(sum(x['kind']=='group' for x in d['nodes'])), 'set-cost':(len(set(d['values']))), 'replace-capacity':(len(set(d['replacement']))<=d['value_limit']), 'remaining-rows':(max(0,d['row_limit']-sum(not x['system'] for x in d['rows'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0})], 2: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 3: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0})], 4: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 5: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(d):
    return {'operand-cost':(sum(len(x['operands']) for x in d['rows'] if not x['system'])), 'row-add-gate':(len(d['rows'])<d['row_limit']), 'group-cost':(sum(x['kind']=='group' for x in d['nodes'])), 'set-cost':(len(set(d['values']))), 'replace-capacity':(len(set(d['replacement']))<=d['value_limit']), 'remaining-rows':(max(0,d['row_limit']-sum(not x['system'] for x in d['rows'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0})], 2: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 3: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0})], 4: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 5: [({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Adding a criterion requires capacity strictly below the user-row limit is violated by the widget projection.

Filter-builder quotas separately bound user rows, nested groups and set operands; disabled user rows still consume edit capacity but enforced rows are exempt. This example checks: Adding a criterion requires capacity strictly below the user-row limit.

split: open-access


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

N = 1
observations = []
def solve(d):
    return {'operand-cost':(sum(len(x['operands']) for x in d['rows'] if not x['system'])), 'row-add-gate':(sum(not x['system'] for x in d['rows'])<d['row_limit']), 'group-cost':(len(d['nodes'])), 'set-cost':(len(set(d['values']))), 'replace-capacity':(len(set(d['replacement']))<=d['value_limit']), 'remaining-rows':(max(0,d['row_limit']-sum(not x['system'] for x in d['rows'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0})], 2: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 3: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1})], 4: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 5: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(d):
    return {'operand-cost':(sum(len(x['operands']) for x in d['rows'] if not x['system'])), 'row-add-gate':(sum(not x['system'] for x in d['rows'])<d['row_limit']), 'group-cost':(sum(x['kind']=='leaf' for x in d['nodes'])), 'set-cost':(len(set(d['values']))), 'replace-capacity':(len(set(d['replacement']))<=d['value_limit']), 'remaining-rows':(max(0,d['row_limit']-sum(not x['system'] for x in d['rows'])))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0})], 2: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 3: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1})], 4: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0})], 5: [({'rows': [], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 1}), ({'rows': [], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 2, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 2}), ({'rows': [], 'row_limit': 3, 'nodes': [], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [], 'row_limit': 3, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 2}, {'operand-cost': 0, 'row-add-gate': True, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 3}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 0, 'replace-capacity': False, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 2, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': ['a', 'b'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'rows': [{'system': True, 'enabled': True, 'operands': ['s']}, {'system': False, 'enabled': False, 'operands': ['a', 'b']}, {'system': False, 'enabled': True, 'operands': ['c']}], 'row_limit': 3, 'nodes': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': True, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 1})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Group quota counts group nodes rather than all filter nodes is violated by the widget projection.

Filter-builder quotas separately bound user rows, nested groups and set operands; disabled user rows still consume edit capacity but enforced rows are exempt. This example checks: Group quota counts group nodes rather than all filter nodes.

split: open-access