FA-26161 / Filter interfaces / Open access
Disabled user operands consume operand quota while enforced operands are exempt · case 01
Disabled user operands consume operand quota while enforced operands are exempt is violated by the widget projection.
ROOT CAUSE
The operand-cost decision uses `sum(len(x['operands']) for x in d['rows'] if not x['system'] and x['enabled'])` instead of the stipulated criterion-quota projection.
VERIFIED REPAIR
Implement the declared operand-cost projection: `sum(len(x['operands']) for x in d['rows'] if not x['system'])`.
Unsuccessful approach: The attempted correction `sum(len(x['operands']) for x in d['rows'])` still violates the explicit contract fixtures.
Case contract
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: Disabled user operands consume operand quota while enforced operands are exempt.
Why this case matters
Filter-widget state and serialization must preserve user constraints while the view changes.
1 / The failure
Exit 1"""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'] and x['enabled'])), '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': 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': [], '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': [], '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': [{'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}), ({'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': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, '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': 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': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'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': 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': [], '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}), ({'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': 1, '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': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'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': 1, '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': 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': [], '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': 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}), ({'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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| contract fixture 0 | {'group-cost': 0, 'operand-cost': 1, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 1 | {'group-cost': 0, 'operand-cost': 1, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 2 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 3 | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 4 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 5 | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': False, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': False, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 6 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 3, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 3, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 7 | {'group-cost': 1, 'operand-cost': 1, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 8 | {'group-cost': 0, 'operand-cost': 1, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 9 | {'group-cost': 1, 'operand-cost': 1, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
SHA-256 / 69519d1deffd06680ed1e29dbe973294940f78bfb01bcfc156a3eebfc05d24c7
2 / The unsuccessful fix
Exit 1"""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'])), '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': 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': [], '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': [], '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': [{'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}), ({'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': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, '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': 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': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'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': 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': [], '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}), ({'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': 1, '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': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'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': 1, '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': 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': [], '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': 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}), ({'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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| contract fixture 0 | {'group-cost': 0, 'operand-cost': 4, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 1 | {'group-cost': 0, 'operand-cost': 4, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 2 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 3 | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 4 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 5 | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': False, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': False, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 6 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 3, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 3, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 7 | {'group-cost': 1, 'operand-cost': 4, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 8 | {'group-cost': 0, 'operand-cost': 4, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
| contract fixture 9 | {'group-cost': 1, 'operand-cost': 4, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Failed |
SHA-256 / de820edf1f5677e9e65878ffe293ce3d279a18d5085579f4b22442ab2274768d
3 / The verified repair
Exit 0"""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': 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': [], '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': [], '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': [{'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}), ({'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': ['c', 'c'], 'value_limit': 2}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, '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': 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': [], 'values': ['a', 'a', 'b'], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 0, 'set-cost': 2, 'replace-capacity': True, 'remaining-rows': 0}), ({'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': 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': [], '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}), ({'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': 1, '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': 1, 'nodes': [{'kind': 'group'}, {'kind': 'leaf'}, {'kind': 'leaf'}], 'values': [], 'replacement': [], 'value_limit': 1}, {'operand-cost': 3, 'row-add-gate': False, 'group-cost': 1, 'set-cost': 0, 'replace-capacity': True, 'remaining-rows': 0}), ({'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': 1, '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': 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': [], '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': 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}), ({'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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| contract fixture 0 | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Passed |
| contract fixture 1 | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Passed |
| contract fixture 2 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 3 | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 1, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 4 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 5 | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': False, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 1, 'operand-cost': 0, 'remaining-rows': 2, 'replace-capacity': False, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 6 | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 3, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | {'group-cost': 0, 'operand-cost': 0, 'remaining-rows': 3, 'replace-capacity': True, 'row-add-gate': True, 'set-cost': 2} | Passed |
| contract fixture 7 | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Passed |
| contract fixture 8 | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 0, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Passed |
| contract fixture 9 | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | {'group-cost': 1, 'operand-cost': 3, 'remaining-rows': 0, 'replace-capacity': True, 'row-add-gate': False, 'set-cost': 0} | Passed |
SHA-256 / 8ea34a9bd5e1fbfeeefdc52a5d367098f9bd1131efb32dde44901df6f781ed7c
Verification & scope
Deterministic bounded UI-state model only; no browser, query engine, network, or production-standard 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:41:13.472991+00:00.
Case digest / 2bdb0608b63737aabf00040f7dbe88968eeb4c75bf6caff3f290910c4472e67b