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

N = 1
observations = []
def solve(d):
    return {'wrapper-toggle':(not d['negated']), 'normal-form-mode':(('or' if d['mode']=='and' else 'and') if d['negated'] else d['mode']), 'complement-all':([d['complements'].get(x,x) for x in d['ops']] if d['negated'] else d['ops']), 'normalizable':(all(x in d['complements'] for x in d['ops'])), 'retain-wrapper':(d['negated'] and not all(x in d['complements'] for x in d['ops'])), 'negated-caption':('NOT '+d['caption'] if d['negated'] else d['caption'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'})], 2: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'})], 3: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'})], 4: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'})], 5: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'})]}
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 {'wrapper-toggle':(not d['negated']), 'normal-form-mode':(('or' if d['mode']=='and' else 'and') if d['negated'] else d['mode']), 'complement-all':([d['complements'].get(x,x) for x in d['ops']] if d['negated'] else d['ops']), 'normalizable':(all(x in d['complements'] for x in d['ops'])), 'retain-wrapper':(d['negated'] and not all(x in d['complements'] for x in d['ops'])), 'negated-caption':('NOT ('+d['caption']+')')}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'})], 2: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'})], 3: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (x)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'})], 4: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': True, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'a AND b'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'a AND b'})], 5: [({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'a AND b'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne', 'regex'], 'normalizable': False, 'retain-wrapper': True, 'negated-caption': 'NOT (a AND b)'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'and', 'complement-all': ['regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': False, 'mode': 'or', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq', 'regex'], 'caption': 'x'}, {'wrapper-toggle': True, 'normal-form-mode': 'or', 'complement-all': ['eq', 'regex'], 'normalizable': False, 'retain-wrapper': False, 'negated-caption': 'x'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': [], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': [], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'}), ({'negated': True, 'mode': 'and', 'complements': {'eq': 'ne', 'ne': 'eq', 'exists': 'missing', 'missing': 'exists'}, 'ops': ['eq'], 'caption': 'x'}, {'wrapper-toggle': False, 'normal-form-mode': 'or', 'complement-all': ['ne'], 'normalizable': True, 'retain-wrapper': False, 'negated-caption': 'NOT (x)'})]}
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:
Negation summary parentheses preserve whole-group scope is violated by the widget projection.

Negating a filter group preserves its explicit wrapper; converting a negated group to normal form flips conjunction and complements every supported child operator atomically. This example checks: Negation summary parentheses preserve whole-group scope.

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'] 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)

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'])), '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)

prompt:
Disabled user operands consume operand quota while enforced operands are exempt 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: Disabled user operands consume operand quota while enforced operands are exempt.

split: open-access