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

N = 1
observations = []
def solve(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en and not col:
            continue
        if len(col) > 1:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i + 1, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths < 27:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'R', True], [2, '', True], [3, 'R', True], [4, 'R', True], [5, 'RY', True]], 'compat': [[1, 5], [5, 2], [3, 5]], 'yellow_durations': [[1, 35], [2, 35], [3, 27]]}, ['multi:5', 'red-fail:2']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'R', True]], 'compat': [], 'yellow_durations': []}, []), ({'channels': [[1, 'RG', False], [2, 'R', True], [3, 'G', True], [4, 'Y', True]], 'compat': [[1, 3], [1, 4]], 'yellow_durations': [[2, 30], [4, 27]]}, ['conflict:3-4']), ({'channels': [[1, 'Y', True], [2, '', True], [3, 'R', True], [4, 'R', True], [5, 'Y', True]], 'compat': [[5, 1], [2, 4], [5, 2]], 'yellow_durations': [[3, 30], [4, 35], [5, 26]]}, ['red-fail:2', 'short-yellow:5']), ({'channels': [[1, 'RY', True], [2, 'R', True], [3, 'R', True], [4, 'RY', False], [5, 'Y', True]], 'compat': [[1, 4], [2, 5], [3, 4]], 'yellow_durations': []}, ['conflict:1-5', 'multi:1']), ({'channels': [[1, 'GY', True], [2, '', True], [3, '', True], [4, '', True], [5, '', True], [6, 'RY', True]], 'compat': [[4, 1], [1, 5], [4, 2], [6, 2]], 'yellow_durations': [[2, 35]]}, ['conflict:1-6', 'multi:1', 'multi:6', 'red-fail:2', 'red-fail:3', 'red-fail:4', 'red-fail:5'])], [({'channels': [[1, 'Y', True], [2, 'RG', True], [3, 'GY', True], [4, 'Y', True], [5, 'RG', True]], 'compat': [[1, 2], [4, 1], [5, 2], [3, 5]], 'yellow_durations': [[1, 26], [2, 27], [3, 25], [4, 27]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:2-3', 'conflict:2-4', 'conflict:3-4', 'conflict:4-5', 'multi:2', 'multi:3', 'multi:5', 'short-yellow:1', 'short-yellow:3']), ({'channels': [[1, 'RY', True], [2, 'R', True], [3, 'RY', True], [4, '', True], [5, '', True], [6, 'RG', True]], 'compat': [[2, 1], [1, 3], [4, 1], [5, 1], [2, 3], [4, 2], [2, 5], [4, 3], [6, 4], [6, 5]], 'yellow_durations': [[2, 26]]}, ['conflict:1-6', 'conflict:3-6', 'multi:1', 'multi:3', 'multi:6', 'red-fail:4', 'red-fail:5', 'short-yellow:2']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', False], [2, '', True], [3, '', True], [4, 'RY', False], [5, 'RY', True]], 'compat': [[1, 4], [1, 5]], 'yellow_durations': [[1, 26], [2, 28], [4, 26]]}, ['multi:5', 'red-fail:2', 'red-fail:3', 'short-yellow:1', 'short-yellow:4']), ({'channels': [[1, 'GY', True], [2, 'RY', True], [3, 'G', True]], 'compat': [[3, 2]], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'conflict:1-3', 'multi:1', 'multi:2', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'GY', True], [4, 'R', True], [5, 'RY', False]], 'compat': [[2, 3], [4, 2], [2, 5], [4, 3]], 'yellow_durations': [[5, 35]]}, ['multi:3']), ({'channels': [[1, 'R', True], [2, 'RY', True], [3, 'GY', True]], 'compat': [[1, 2]], 'yellow_durations': [[3, 30]]}, ['conflict:2-3', 'multi:2', 'multi:3']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1'])], [({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True]], 'compat': [], 'yellow_durations': [[3, 25]]}, ['short-yellow:3']), ({'channels': [[1, 'R', True], [2, 'RY', False], [3, 'R', True], [4, 'RG', True], [5, '', True]], 'compat': [[2, 3], [3, 4], [4, 5]], 'yellow_durations': [[1, 35], [2, 28], [3, 26], [4, 26], [5, 30]]}, ['multi:4', 'red-fail:5', 'short-yellow:3', 'short-yellow:4']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, 'RY', False], [3, 'RY', True], [4, 'RY', True]], 'compat': [[1, 2], [1, 4], [2, 3]], 'yellow_durations': [[1, 28], [3, 35]]}, ['conflict:1-3', 'conflict:3-4', 'multi:1', 'multi:3', 'multi:4']), ({'channels': [[1, 'R', False], [2, 'RY', True], [3, 'R', False], [4, 'GY', True], [5, 'GY', True], [6, 'R', True]], 'compat': [[3, 1], [5, 2], [6, 2], [3, 4], [5, 3], [4, 5]], 'yellow_durations': [[1, 25], [2, 28], [3, 27], [4, 28], [5, 35]]}, ['conflict:2-4', 'multi:2', 'multi:4', 'multi:5', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'Y', True], [2, '', True], [3, 'RY', True], [4, 'RG', True]], 'compat': [[2, 1], [3, 1], [1, 4], [4, 2]], 'yellow_durations': [[3, 26]]}, ['conflict:3-4', 'multi:3', 'multi:4', 'red-fail:2', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'RG', True]], 'compat': [[1, 2], [1, 3]], 'yellow_durations': [[1, 30]]}, ['multi:3', 'red-fail:2'])], [({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True]], 'compat': [], 'yellow_durations': [[1, 30]]}, []), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'R', True]], 'compat': [[1, 2]], 'yellow_durations': [[1, 27], [2, 25], [3, 26]]}, ['short-yellow:2', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'R', True], [4, 'RY', True]], 'compat': [[1, 3], [1, 4], [4, 2]], 'yellow_durations': [[3, 26]]}, ['multi:4', 'red-fail:2', 'short-yellow:3']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'Y', False], [2, 'RG', False], [3, 'R', True]], 'compat': [[3, 2]], 'yellow_durations': [[3, 26]]}, ['short-yellow:3']), ({'channels': [[1, 'RG', True], [2, 'RY', False], [3, 'RG', True], [4, 'R', True], [5, 'GY', True]], 'compat': [[1, 2], [4, 3], [5, 4]], 'yellow_durations': [[5, 27]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:3-5', 'multi:1', 'multi:3', 'multi:5']), ({'channels': [[1, 'RY', False], [2, 'R', True], [3, 'RY', True], [4, 'R', True], [5, 'G', True], [6, 'G', True]], 'compat': [[1, 2], [5, 1], [6, 2], [3, 4], [5, 4], [6, 4]], 'yellow_durations': [[3, 25], [5, 25]]}, ['conflict:3-5', 'conflict:3-6', 'conflict:5-6', 'multi:3', 'short-yellow:3', 'short-yellow:5'])], [({'channels': [[1, 'Y', True], [2, 'R', True], [3, 'R', True], [4, '', True], [5, 'RY', True], [6, 'G', True]], 'compat': [[6, 1], [3, 4], [3, 6], [4, 6], [6, 5]], 'yellow_durations': [[3, 30]]}, ['conflict:1-5', 'multi:5', 'red-fail:4']), ({'channels': [[1, 'Y', True], [2, 'RG', False], [3, 'G', True], [4, 'RG', True], [5, 'RY', True]], 'compat': [[1, 2], [1, 4], [5, 1], [3, 2], [4, 2], [3, 5]], 'yellow_durations': [[1, 30]]}, ['conflict:1-3', 'conflict:3-4', 'conflict:4-5', 'multi:4', 'multi:5']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'G', True], [4, 'GY', True]], 'compat': [[3, 2], [3, 4]], 'yellow_durations': [[4, 27]]}, ['multi:4']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'Y', True], [2, 'RG', False], [3, 'R', False], [4, 'GY', False], [5, 'RY', True]], 'compat': [[1, 2], [2, 4], [3, 4]], 'yellow_durations': [[3, 27]]}, ['conflict:1-5', 'multi:5']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'GY', True]], 'compat': [[2, 1]], 'yellow_durations': [[2, 28]]}, ['multi:3']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'RY', True], [3, 'R', True], [4, '', True]], 'compat': [[1, 2], [3, 1], [1, 4], [3, 4]], 'yellow_durations': [[3, 30]]}, ['multi:2', 'red-fail:4'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en and col in ('', 'R'):
            continue
        if len(col) > 1:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i + 1, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths < 27:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'R', True], [2, '', True], [3, 'R', True], [4, 'R', True], [5, 'RY', True]], 'compat': [[1, 5], [5, 2], [3, 5]], 'yellow_durations': [[1, 35], [2, 35], [3, 27]]}, ['multi:5', 'red-fail:2']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'R', True]], 'compat': [], 'yellow_durations': []}, []), ({'channels': [[1, 'RG', False], [2, 'R', True], [3, 'G', True], [4, 'Y', True]], 'compat': [[1, 3], [1, 4]], 'yellow_durations': [[2, 30], [4, 27]]}, ['conflict:3-4']), ({'channels': [[1, 'Y', True], [2, '', True], [3, 'R', True], [4, 'R', True], [5, 'Y', True]], 'compat': [[5, 1], [2, 4], [5, 2]], 'yellow_durations': [[3, 30], [4, 35], [5, 26]]}, ['red-fail:2', 'short-yellow:5']), ({'channels': [[1, 'RY', True], [2, 'R', True], [3, 'R', True], [4, 'RY', False], [5, 'Y', True]], 'compat': [[1, 4], [2, 5], [3, 4]], 'yellow_durations': []}, ['conflict:1-5', 'multi:1']), ({'channels': [[1, 'GY', True], [2, '', True], [3, '', True], [4, '', True], [5, '', True], [6, 'RY', True]], 'compat': [[4, 1], [1, 5], [4, 2], [6, 2]], 'yellow_durations': [[2, 35]]}, ['conflict:1-6', 'multi:1', 'multi:6', 'red-fail:2', 'red-fail:3', 'red-fail:4', 'red-fail:5'])], [({'channels': [[1, 'Y', True], [2, 'RG', True], [3, 'GY', True], [4, 'Y', True], [5, 'RG', True]], 'compat': [[1, 2], [4, 1], [5, 2], [3, 5]], 'yellow_durations': [[1, 26], [2, 27], [3, 25], [4, 27]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:2-3', 'conflict:2-4', 'conflict:3-4', 'conflict:4-5', 'multi:2', 'multi:3', 'multi:5', 'short-yellow:1', 'short-yellow:3']), ({'channels': [[1, 'RY', True], [2, 'R', True], [3, 'RY', True], [4, '', True], [5, '', True], [6, 'RG', True]], 'compat': [[2, 1], [1, 3], [4, 1], [5, 1], [2, 3], [4, 2], [2, 5], [4, 3], [6, 4], [6, 5]], 'yellow_durations': [[2, 26]]}, ['conflict:1-6', 'conflict:3-6', 'multi:1', 'multi:3', 'multi:6', 'red-fail:4', 'red-fail:5', 'short-yellow:2']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', False], [2, '', True], [3, '', True], [4, 'RY', False], [5, 'RY', True]], 'compat': [[1, 4], [1, 5]], 'yellow_durations': [[1, 26], [2, 28], [4, 26]]}, ['multi:5', 'red-fail:2', 'red-fail:3', 'short-yellow:1', 'short-yellow:4']), ({'channels': [[1, 'GY', True], [2, 'RY', True], [3, 'G', True]], 'compat': [[3, 2]], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'conflict:1-3', 'multi:1', 'multi:2', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'GY', True], [4, 'R', True], [5, 'RY', False]], 'compat': [[2, 3], [4, 2], [2, 5], [4, 3]], 'yellow_durations': [[5, 35]]}, ['multi:3']), ({'channels': [[1, 'R', True], [2, 'RY', True], [3, 'GY', True]], 'compat': [[1, 2]], 'yellow_durations': [[3, 30]]}, ['conflict:2-3', 'multi:2', 'multi:3']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1'])], [({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True]], 'compat': [], 'yellow_durations': [[3, 25]]}, ['short-yellow:3']), ({'channels': [[1, 'R', True], [2, 'RY', False], [3, 'R', True], [4, 'RG', True], [5, '', True]], 'compat': [[2, 3], [3, 4], [4, 5]], 'yellow_durations': [[1, 35], [2, 28], [3, 26], [4, 26], [5, 30]]}, ['multi:4', 'red-fail:5', 'short-yellow:3', 'short-yellow:4']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, 'RY', False], [3, 'RY', True], [4, 'RY', True]], 'compat': [[1, 2], [1, 4], [2, 3]], 'yellow_durations': [[1, 28], [3, 35]]}, ['conflict:1-3', 'conflict:3-4', 'multi:1', 'multi:3', 'multi:4']), ({'channels': [[1, 'R', False], [2, 'RY', True], [3, 'R', False], [4, 'GY', True], [5, 'GY', True], [6, 'R', True]], 'compat': [[3, 1], [5, 2], [6, 2], [3, 4], [5, 3], [4, 5]], 'yellow_durations': [[1, 25], [2, 28], [3, 27], [4, 28], [5, 35]]}, ['conflict:2-4', 'multi:2', 'multi:4', 'multi:5', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'Y', True], [2, '', True], [3, 'RY', True], [4, 'RG', True]], 'compat': [[2, 1], [3, 1], [1, 4], [4, 2]], 'yellow_durations': [[3, 26]]}, ['conflict:3-4', 'multi:3', 'multi:4', 'red-fail:2', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'RG', True]], 'compat': [[1, 2], [1, 3]], 'yellow_durations': [[1, 30]]}, ['multi:3', 'red-fail:2'])], [({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True]], 'compat': [], 'yellow_durations': [[1, 30]]}, []), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'R', True]], 'compat': [[1, 2]], 'yellow_durations': [[1, 27], [2, 25], [3, 26]]}, ['short-yellow:2', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'R', True], [4, 'RY', True]], 'compat': [[1, 3], [1, 4], [4, 2]], 'yellow_durations': [[3, 26]]}, ['multi:4', 'red-fail:2', 'short-yellow:3']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'Y', False], [2, 'RG', False], [3, 'R', True]], 'compat': [[3, 2]], 'yellow_durations': [[3, 26]]}, ['short-yellow:3']), ({'channels': [[1, 'RG', True], [2, 'RY', False], [3, 'RG', True], [4, 'R', True], [5, 'GY', True]], 'compat': [[1, 2], [4, 3], [5, 4]], 'yellow_durations': [[5, 27]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:3-5', 'multi:1', 'multi:3', 'multi:5']), ({'channels': [[1, 'RY', False], [2, 'R', True], [3, 'RY', True], [4, 'R', True], [5, 'G', True], [6, 'G', True]], 'compat': [[1, 2], [5, 1], [6, 2], [3, 4], [5, 4], [6, 4]], 'yellow_durations': [[3, 25], [5, 25]]}, ['conflict:3-5', 'conflict:3-6', 'conflict:5-6', 'multi:3', 'short-yellow:3', 'short-yellow:5'])], [({'channels': [[1, 'Y', True], [2, 'R', True], [3, 'R', True], [4, '', True], [5, 'RY', True], [6, 'G', True]], 'compat': [[6, 1], [3, 4], [3, 6], [4, 6], [6, 5]], 'yellow_durations': [[3, 30]]}, ['conflict:1-5', 'multi:5', 'red-fail:4']), ({'channels': [[1, 'Y', True], [2, 'RG', False], [3, 'G', True], [4, 'RG', True], [5, 'RY', True]], 'compat': [[1, 2], [1, 4], [5, 1], [3, 2], [4, 2], [3, 5]], 'yellow_durations': [[1, 30]]}, ['conflict:1-3', 'conflict:3-4', 'conflict:4-5', 'multi:4', 'multi:5']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'G', True], [4, 'GY', True]], 'compat': [[3, 2], [3, 4]], 'yellow_durations': [[4, 27]]}, ['multi:4']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'Y', True], [2, 'RG', False], [3, 'R', False], [4, 'GY', False], [5, 'RY', True]], 'compat': [[1, 2], [2, 4], [3, 4]], 'yellow_durations': [[3, 27]]}, ['conflict:1-5', 'multi:5']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'GY', True]], 'compat': [[2, 1]], 'yellow_durations': [[2, 28]]}, ['multi:3']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'RY', True], [3, 'R', True], [4, '', True]], 'compat': [[1, 2], [3, 1], [1, 4], [3, 4]], 'yellow_durations': [[3, 30]]}, ['multi:2', 'red-fail:4'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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:
Conflict monitor fault scan returns a wrong result when disabled channels showing green still enter the conflict check.

Input {channels: [[channel, lit colors string over R/Y/G, enabled]], compat: unordered compatible pairs, yellow_durations: [[channel, tenths]]}. Disabled channels are ignored entirely. A channel with more than one lit color is 'multi'; with none lit is 'red-fail'; any channel showing G or Y takes part in the conflict check, and every live pair not listed as compatible is 'conflict:a-b' (a<b). A completed yellow shorter than 2.7 s is 'short-yellow'. Return the sorted fault strings.

split: open-access


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

N = 1
observations = []
def solve(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en:
            continue
        if len(col) > 1:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i + 1, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths <= 27:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'RY', True], [2, 'RG', True], [3, '', False], [4, 'R', True], [5, 'RG', True], [6, 'GY', True]], 'compat': [[2, 3], [2, 5], [4, 6], [6, 5]], 'yellow_durations': [[2, 27], [4, 26]]}, ['conflict:1-2', 'conflict:1-5', 'conflict:1-6', 'conflict:2-6', 'multi:1', 'multi:2', 'multi:5', 'multi:6', 'short-yellow:4']), ({'channels': [[1, 'RG', False], [2, 'GY', True], [3, 'Y', True], [4, 'R', True]], 'compat': [[4, 1], [4, 2], [4, 3]], 'yellow_durations': [[1, 25], [2, 26], [4, 30]]}, ['conflict:2-3', 'multi:2', 'short-yellow:1', 'short-yellow:2']), ({'channels': [[1, 'G', True], [2, 'GY', True], [3, 'RY', True], [4, '', True], [5, 'R', True], [6, '', True]], 'compat': [[1, 3], [3, 4], [5, 4]], 'yellow_durations': []}, ['conflict:1-2', 'conflict:2-3', 'multi:2', 'multi:3', 'red-fail:4', 'red-fail:6']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'G', True], [2, 'R', True], [3, '', True], [4, 'RY', True], [5, 'R', True]], 'compat': [[1, 3]], 'yellow_durations': [[1, 28], [3, 27], [5, 27]]}, ['conflict:1-4', 'multi:4', 'red-fail:3']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'RG', True], [4, 'Y', True], [5, 'R', True]], 'compat': [[4, 2], [2, 5], [3, 4], [3, 5]], 'yellow_durations': []}, ['conflict:2-3', 'multi:3']), ({'channels': [[1, '', True], [2, 'G', False], [3, 'RY', True], [4, 'GY', False], [5, 'R', False]], 'compat': [[2, 3], [2, 5], [4, 3]], 'yellow_durations': [[5, 28]]}, ['multi:3', 'red-fail:1'])], [({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'RY', True], [2, 'Y', True], [3, 'R', True], [4, 'Y', True], [5, 'GY', True], [6, 'Y', True]], 'compat': [[4, 1], [5, 1], [4, 3]], 'yellow_durations': [[3, 27], [4, 26]]}, ['conflict:1-2', 'conflict:1-6', 'conflict:2-4', 'conflict:2-5', 'conflict:2-6', 'conflict:4-5', 'conflict:4-6', 'conflict:5-6', 'multi:1', 'multi:5', 'short-yellow:4']), ({'channels': [[1, '', True], [2, 'R', True], [3, 'G', True]], 'compat': [[3, 1], [2, 3]], 'yellow_durations': []}, ['red-fail:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'GY', True]], 'compat': [[1, 2], [2, 3]], 'yellow_durations': []}, ['multi:3']), ({'channels': [[1, '', True], [2, 'Y', False], [3, 'RY', True]], 'compat': [[2, 1], [3, 1]], 'yellow_durations': [[3, 35]]}, ['multi:3', 'red-fail:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, '', True], [2, 'G', False], [3, 'G', True], [4, 'GY', False]], 'compat': [[2, 1], [2, 4]], 'yellow_durations': [[4, 27]]}, ['red-fail:1']), ({'channels': [[1, 'GY', True], [2, '', True], [3, 'R', True]], 'compat': [[3, 1], [3, 2]], 'yellow_durations': [[1, 35], [3, 35]]}, ['multi:1', 'red-fail:2'])], [({'channels': [[1, 'RY', True], [2, 'RG', True], [3, 'R', False]], 'compat': [[2, 1]], 'yellow_durations': [[2, 27]]}, ['multi:1', 'multi:2']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', False], [2, 'R', True], [3, '', True], [4, 'R', True], [5, 'GY', True]], 'compat': [[1, 5], [2, 5], [3, 4]], 'yellow_durations': [[4, 28]]}, ['multi:5', 'red-fail:3']), ({'channels': [[1, 'R', True], [2, 'GY', True], [3, '', True], [4, 'GY', True], [5, 'R', True], [6, 'Y', False]], 'compat': [[1, 2], [3, 1], [5, 1], [4, 3], [5, 4]], 'yellow_durations': [[1, 35]]}, ['conflict:2-4', 'multi:2', 'multi:4', 'red-fail:3']), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'GY', True], [4, 'RG', False]], 'compat': [[4, 2]], 'yellow_durations': []}, ['conflict:2-3', 'multi:3']), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'R', True], [4, '', True], [5, 'RG', True], [6, '', True]], 'compat': [[6, 2], [4, 5]], 'yellow_durations': [[1, 25], [3, 27], [5, 35]]}, ['conflict:1-2', 'conflict:1-5', 'conflict:2-5', 'multi:5', 'red-fail:4', 'red-fail:6', 'short-yellow:1']), ({'channels': [[1, 'Y', True], [2, '', True], [3, 'GY', True], [4, 'Y', True]], 'compat': [[1, 2], [4, 3]], 'yellow_durations': []}, ['conflict:1-3', 'conflict:1-4', 'multi:3', 'red-fail:2'])], [({'channels': [[1, 'RG', False], [2, 'R', False], [3, 'G', True]], 'compat': [[1, 2]], 'yellow_durations': []}, []), ({'channels': [[1, '', True], [2, 'R', False], [3, 'RY', False], [4, '', True], [5, 'GY', True], [6, 'Y', True]], 'compat': [[1, 2], [4, 1], [1, 5], [1, 6], [5, 2], [3, 5], [3, 6]], 'yellow_durations': [[4, 27], [5, 26]]}, ['conflict:5-6', 'multi:5', 'red-fail:1', 'red-fail:4', 'short-yellow:5']), ({'channels': [[1, 'Y', True], [2, 'G', True], [3, 'GY', True], [4, 'R', True], [5, 'R', True], [6, 'G', False]], 'compat': [[2, 1], [6, 1], [3, 2], [2, 4], [3, 4], [3, 6], [6, 5]], 'yellow_durations': []}, ['conflict:1-3', 'multi:3']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, 'R', True], [4, 'RY', True]], 'compat': [[4, 1], [4, 2], [3, 4]], 'yellow_durations': [[3, 27]]}, ['conflict:1-2', 'multi:1', 'multi:4']), ({'channels': [[1, 'R', True], [2, 'R', False], [3, 'R', True], [4, 'R', True], [5, 'R', True], [6, 'R', True]], 'compat': [[4, 2], [2, 6], [3, 4], [5, 3], [6, 4]], 'yellow_durations': [[1, 26], [2, 35]]}, ['short-yellow:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'R', True], [4, 'R', True]], 'compat': [[1, 2], [1, 3], [4, 1], [3, 4]], 'yellow_durations': [[1, 28], [4, 27]]}, [])], [({'channels': [[1, 'G', True], [2, '', True], [3, 'R', True]], 'compat': [], 'yellow_durations': [[1, 25]]}, ['red-fail:2', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'G', False], [2, 'G', True], [3, 'R', False], [4, 'R', True], [5, 'Y', False]], 'compat': [[1, 2], [1, 3], [5, 1], [3, 2], [5, 2]], 'yellow_durations': [[3, 28]]}, []), ({'channels': [[1, 'Y', False], [2, 'R', False], [3, 'GY', True], [4, 'R', False], [5, 'R', True]], 'compat': [[2, 1], [3, 1], [4, 1], [2, 5], [3, 5], [4, 5]], 'yellow_durations': [[1, 25]]}, ['multi:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, 'R', True], [3, 'GY', True], [4, 'R', True], [5, 'GY', True], [6, 'GY', True]], 'compat': [[2, 1], [1, 4], [5, 1], [6, 1], [3, 2], [3, 5], [3, 6]], 'yellow_durations': [[2, 26], [3, 27], [4, 28]]}, ['conflict:1-3', 'conflict:5-6', 'multi:1', 'multi:3', 'multi:5', 'multi:6', 'short-yellow:2']), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'G', False]], 'compat': [], 'yellow_durations': []}, []), ({'channels': [[1, '', True], [2, 'G', True], [3, 'RG', True], [4, 'R', True]], 'compat': [[3, 2], [4, 2], [3, 4]], 'yellow_durations': [[1, 27]]}, ['multi:3', 'red-fail:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en:
            continue
        if len(col) > 1:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i + 1, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths < 30:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'RY', True], [2, 'RG', True], [3, '', False], [4, 'R', True], [5, 'RG', True], [6, 'GY', True]], 'compat': [[2, 3], [2, 5], [4, 6], [6, 5]], 'yellow_durations': [[2, 27], [4, 26]]}, ['conflict:1-2', 'conflict:1-5', 'conflict:1-6', 'conflict:2-6', 'multi:1', 'multi:2', 'multi:5', 'multi:6', 'short-yellow:4']), ({'channels': [[1, 'RG', False], [2, 'GY', True], [3, 'Y', True], [4, 'R', True]], 'compat': [[4, 1], [4, 2], [4, 3]], 'yellow_durations': [[1, 25], [2, 26], [4, 30]]}, ['conflict:2-3', 'multi:2', 'short-yellow:1', 'short-yellow:2']), ({'channels': [[1, 'G', True], [2, 'GY', True], [3, 'RY', True], [4, '', True], [5, 'R', True], [6, '', True]], 'compat': [[1, 3], [3, 4], [5, 4]], 'yellow_durations': []}, ['conflict:1-2', 'conflict:2-3', 'multi:2', 'multi:3', 'red-fail:4', 'red-fail:6']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'G', True], [2, 'R', True], [3, '', True], [4, 'RY', True], [5, 'R', True]], 'compat': [[1, 3]], 'yellow_durations': [[1, 28], [3, 27], [5, 27]]}, ['conflict:1-4', 'multi:4', 'red-fail:3']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'RG', True], [4, 'Y', True], [5, 'R', True]], 'compat': [[4, 2], [2, 5], [3, 4], [3, 5]], 'yellow_durations': []}, ['conflict:2-3', 'multi:3']), ({'channels': [[1, '', True], [2, 'G', False], [3, 'RY', True], [4, 'GY', False], [5, 'R', False]], 'compat': [[2, 3], [2, 5], [4, 3]], 'yellow_durations': [[5, 28]]}, ['multi:3', 'red-fail:1'])], [({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'RY', True], [2, 'Y', True], [3, 'R', True], [4, 'Y', True], [5, 'GY', True], [6, 'Y', True]], 'compat': [[4, 1], [5, 1], [4, 3]], 'yellow_durations': [[3, 27], [4, 26]]}, ['conflict:1-2', 'conflict:1-6', 'conflict:2-4', 'conflict:2-5', 'conflict:2-6', 'conflict:4-5', 'conflict:4-6', 'conflict:5-6', 'multi:1', 'multi:5', 'short-yellow:4']), ({'channels': [[1, '', True], [2, 'R', True], [3, 'G', True]], 'compat': [[3, 1], [2, 3]], 'yellow_durations': []}, ['red-fail:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'GY', True]], 'compat': [[1, 2], [2, 3]], 'yellow_durations': []}, ['multi:3']), ({'channels': [[1, '', True], [2, 'Y', False], [3, 'RY', True]], 'compat': [[2, 1], [3, 1]], 'yellow_durations': [[3, 35]]}, ['multi:3', 'red-fail:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, '', True], [2, 'G', False], [3, 'G', True], [4, 'GY', False]], 'compat': [[2, 1], [2, 4]], 'yellow_durations': [[4, 27]]}, ['red-fail:1']), ({'channels': [[1, 'GY', True], [2, '', True], [3, 'R', True]], 'compat': [[3, 1], [3, 2]], 'yellow_durations': [[1, 35], [3, 35]]}, ['multi:1', 'red-fail:2'])], [({'channels': [[1, 'RY', True], [2, 'RG', True], [3, 'R', False]], 'compat': [[2, 1]], 'yellow_durations': [[2, 27]]}, ['multi:1', 'multi:2']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', False], [2, 'R', True], [3, '', True], [4, 'R', True], [5, 'GY', True]], 'compat': [[1, 5], [2, 5], [3, 4]], 'yellow_durations': [[4, 28]]}, ['multi:5', 'red-fail:3']), ({'channels': [[1, 'R', True], [2, 'GY', True], [3, '', True], [4, 'GY', True], [5, 'R', True], [6, 'Y', False]], 'compat': [[1, 2], [3, 1], [5, 1], [4, 3], [5, 4]], 'yellow_durations': [[1, 35]]}, ['conflict:2-4', 'multi:2', 'multi:4', 'red-fail:3']), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'GY', True], [4, 'RG', False]], 'compat': [[4, 2]], 'yellow_durations': []}, ['conflict:2-3', 'multi:3']), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'R', True], [4, '', True], [5, 'RG', True], [6, '', True]], 'compat': [[6, 2], [4, 5]], 'yellow_durations': [[1, 25], [3, 27], [5, 35]]}, ['conflict:1-2', 'conflict:1-5', 'conflict:2-5', 'multi:5', 'red-fail:4', 'red-fail:6', 'short-yellow:1']), ({'channels': [[1, 'Y', True], [2, '', True], [3, 'GY', True], [4, 'Y', True]], 'compat': [[1, 2], [4, 3]], 'yellow_durations': []}, ['conflict:1-3', 'conflict:1-4', 'multi:3', 'red-fail:2'])], [({'channels': [[1, 'RG', False], [2, 'R', False], [3, 'G', True]], 'compat': [[1, 2]], 'yellow_durations': []}, []), ({'channels': [[1, '', True], [2, 'R', False], [3, 'RY', False], [4, '', True], [5, 'GY', True], [6, 'Y', True]], 'compat': [[1, 2], [4, 1], [1, 5], [1, 6], [5, 2], [3, 5], [3, 6]], 'yellow_durations': [[4, 27], [5, 26]]}, ['conflict:5-6', 'multi:5', 'red-fail:1', 'red-fail:4', 'short-yellow:5']), ({'channels': [[1, 'Y', True], [2, 'G', True], [3, 'GY', True], [4, 'R', True], [5, 'R', True], [6, 'G', False]], 'compat': [[2, 1], [6, 1], [3, 2], [2, 4], [3, 4], [3, 6], [6, 5]], 'yellow_durations': []}, ['conflict:1-3', 'multi:3']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, 'R', True], [4, 'RY', True]], 'compat': [[4, 1], [4, 2], [3, 4]], 'yellow_durations': [[3, 27]]}, ['conflict:1-2', 'multi:1', 'multi:4']), ({'channels': [[1, 'R', True], [2, 'R', False], [3, 'R', True], [4, 'R', True], [5, 'R', True], [6, 'R', True]], 'compat': [[4, 2], [2, 6], [3, 4], [5, 3], [6, 4]], 'yellow_durations': [[1, 26], [2, 35]]}, ['short-yellow:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'R', True], [4, 'R', True]], 'compat': [[1, 2], [1, 3], [4, 1], [3, 4]], 'yellow_durations': [[1, 28], [4, 27]]}, [])], [({'channels': [[1, 'G', True], [2, '', True], [3, 'R', True]], 'compat': [], 'yellow_durations': [[1, 25]]}, ['red-fail:2', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'G', False], [2, 'G', True], [3, 'R', False], [4, 'R', True], [5, 'Y', False]], 'compat': [[1, 2], [1, 3], [5, 1], [3, 2], [5, 2]], 'yellow_durations': [[3, 28]]}, []), ({'channels': [[1, 'Y', False], [2, 'R', False], [3, 'GY', True], [4, 'R', False], [5, 'R', True]], 'compat': [[2, 1], [3, 1], [4, 1], [2, 5], [3, 5], [4, 5]], 'yellow_durations': [[1, 25]]}, ['multi:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, 'R', True], [3, 'GY', True], [4, 'R', True], [5, 'GY', True], [6, 'GY', True]], 'compat': [[2, 1], [1, 4], [5, 1], [6, 1], [3, 2], [3, 5], [3, 6]], 'yellow_durations': [[2, 26], [3, 27], [4, 28]]}, ['conflict:1-3', 'conflict:5-6', 'multi:1', 'multi:3', 'multi:5', 'multi:6', 'short-yellow:2']), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'G', False]], 'compat': [], 'yellow_durations': []}, []), ({'channels': [[1, '', True], [2, 'G', True], [3, 'RG', True], [4, 'R', True]], 'compat': [[3, 2], [4, 2], [3, 4]], 'yellow_durations': [[1, 27]]}, ['multi:3', 'red-fail:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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:
Conflict monitor fault scan returns a wrong result when a yellow of exactly 2.7 s is flagged as short.

Input {channels: [[channel, lit colors string over R/Y/G, enabled]], compat: unordered compatible pairs, yellow_durations: [[channel, tenths]]}. Disabled channels are ignored entirely. A channel with more than one lit color is 'multi'; with none lit is 'red-fail'; any channel showing G or Y takes part in the conflict check, and every live pair not listed as compatible is 'conflict:a-b' (a<b). A completed yellow shorter than 2.7 s is 'short-yellow'. Return the sorted fault strings.

split: open-access


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

N = 1
observations = []
def solve(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en:
            continue
        if len(set(col)) > 2:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i + 1, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths < 27:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'RG', True], [2, 'RY', True], [3, '', True]], 'compat': [[2, 3]], 'yellow_durations': []}, ['conflict:1-2', 'multi:1', 'multi:2', 'red-fail:3']), ({'channels': [[1, 'G', True], [2, 'RG', True], [3, 'RG', True], [4, 'R', True], [5, 'Y', True], [6, 'G', True]], 'compat': [[2, 1], [2, 3], [2, 6], [3, 5], [4, 5], [6, 4]], 'yellow_durations': [[1, 35], [3, 25]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:1-6', 'conflict:2-5', 'conflict:3-6', 'conflict:5-6', 'multi:2', 'multi:3', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, '', False], [3, '', True]], 'compat': [[1, 2]], 'yellow_durations': [[1, 30]]}, ['red-fail:3']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'Y', True], [4, '', True]], 'compat': [[2, 1], [4, 1]], 'yellow_durations': []}, ['red-fail:4']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'Y', True], [2, 'Y', True], [3, '', True], [4, '', True], [5, '', True]], 'compat': [[1, 4], [3, 2], [5, 3]], 'yellow_durations': [[1, 27], [2, 25]]}, ['conflict:1-2', 'red-fail:3', 'red-fail:4', 'red-fail:5', 'short-yellow:2']), ({'channels': [[1, '', True], [2, 'RG', True], [3, 'RG', True], [4, 'Y', True], [5, 'RY', False], [6, 'R', True]], 'compat': [[5, 1], [2, 4], [2, 5], [2, 6], [4, 5]], 'yellow_durations': [[4, 30], [6, 27]]}, ['conflict:2-3', 'conflict:3-4', 'multi:2', 'multi:3', 'red-fail:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, [])], [({'channels': [[1, 'R', True], [2, 'Y', False], [3, 'R', True], [4, 'G', True]], 'compat': [[2, 3]], 'yellow_durations': [[1, 27], [3, 35]]}, []), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'RY', True], [5, 'R', True], [6, 'G', False]], 'compat': [[1, 5], [6, 2], [3, 4], [5, 4]], 'yellow_durations': [[1, 26], [6, 35]]}, ['multi:4', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, '', True], [4, 'G', False]], 'compat': [[4, 2], [4, 3]], 'yellow_durations': [[1, 35], [2, 27], [3, 28], [4, 25]]}, ['red-fail:3', 'short-yellow:4']), ({'channels': [[1, 'Y', True], [2, 'Y', True], [3, 'RY', True]], 'compat': [[1, 2], [1, 3]], 'yellow_durations': [[2, 35]]}, ['conflict:2-3', 'multi:3']), ({'channels': [[1, 'Y', True], [2, 'Y', True], [3, '', True]], 'compat': [[1, 3], [2, 3]], 'yellow_durations': [[1, 26], [2, 28]]}, ['conflict:1-2', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, '', True], [3, 'R', True], [4, 'G', True], [5, 'RG', True]], 'compat': [[1, 4], [5, 1], [5, 4]], 'yellow_durations': [[3, 25]]}, ['multi:1', 'multi:5', 'red-fail:2', 'short-yellow:3'])], [({'channels': [[1, 'RY', True], [2, 'RY', False], [3, 'RY', False], [4, 'RG', True], [5, 'GY', True], [6, '', True]], 'compat': [[1, 6], [4, 2], [2, 5], [4, 3], [5, 4]], 'yellow_durations': [[3, 30], [4, 28]]}, ['conflict:1-4', 'conflict:1-5', 'multi:1', 'multi:4', 'multi:5', 'red-fail:6']), ({'channels': [[1, '', False], [2, 'Y', True], [3, 'Y', True], [4, 'R', True]], 'compat': [[1, 2], [1, 3], [4, 1], [4, 2], [3, 4]], 'yellow_durations': [[1, 28], [3, 27], [4, 27]]}, ['conflict:2-3']), ({'channels': [[1, 'R', True], [2, 'R', False], [3, 'G', True], [4, 'RG', False], [5, 'G', True], [6, 'R', False]], 'compat': [[3, 1], [5, 1], [2, 4], [4, 3], [5, 3], [5, 6]], 'yellow_durations': [[1, 28]]}, []), ({'channels': [[1, 'R', True], [2, 'RG', True], [3, 'Y', True], [4, 'R', True], [5, 'RG', True], [6, 'R', True]], 'compat': [[5, 1], [4, 2], [4, 3], [5, 3], [4, 5]], 'yellow_durations': [[2, 28]]}, ['conflict:2-3', 'conflict:2-5', 'multi:2', 'multi:5']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, 'RY', True], [3, 'R', True], [4, 'GY', True]], 'compat': [[2, 1]], 'yellow_durations': [[1, 28]]}, ['conflict:1-4', 'conflict:2-4', 'multi:1', 'multi:2', 'multi:4']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'R', True], [4, 'R', True], [5, '', True]], 'compat': [[1, 3], [3, 2], [3, 5], [5, 4]], 'yellow_durations': [[3, 26], [4, 30]]}, ['conflict:1-2', 'red-fail:5', 'short-yellow:3'])], [({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'R', True], [4, 'GY', True]], 'compat': [[3, 1], [4, 1], [2, 3], [3, 4]], 'yellow_durations': [[1, 27]]}, ['conflict:2-4', 'multi:4']), ({'channels': [[1, 'R', True], [2, 'RG', True], [3, 'Y', True], [4, 'R', True], [5, 'RG', True], [6, 'Y', True]], 'compat': [], 'yellow_durations': [[4, 26], [5, 35], [6, 28]]}, ['conflict:2-3', 'conflict:2-5', 'conflict:2-6', 'conflict:3-5', 'conflict:3-6', 'conflict:5-6', 'multi:2', 'multi:5', 'short-yellow:4']), ({'channels': [[1, 'Y', True], [2, 'RG', True], [3, 'G', True]], 'compat': [], 'yellow_durations': [[3, 26]]}, ['conflict:1-2', 'conflict:1-3', 'conflict:2-3', 'multi:2', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, '', True], [4, 'R', True]], 'compat': [[1, 2], [1, 3], [4, 2]], 'yellow_durations': [[4, 27]]}, ['red-fail:3']), ({'channels': [[1, '', True], [2, 'R', True], [3, 'Y', True]], 'compat': [[2, 1], [1, 3], [3, 2]], 'yellow_durations': [[1, 27]]}, ['red-fail:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'R', True], [5, '', True]], 'compat': [[1, 2], [3, 1], [1, 4], [2, 3], [2, 5], [3, 4], [4, 5]], 'yellow_durations': [[1, 28], [3, 27]]}, ['red-fail:5']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, [])], [({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'Y', True], [4, '', True], [5, 'R', True]], 'compat': [[1, 2], [5, 1]], 'yellow_durations': [[2, 25], [5, 30]]}, ['red-fail:4', 'short-yellow:2']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'G', True], [4, 'RY', True], [5, 'GY', True], [6, 'R', True]], 'compat': [[1, 2], [6, 1], [5, 2], [6, 3], [4, 5], [6, 5]], 'yellow_durations': [[6, 28]]}, ['conflict:3-4', 'conflict:3-5', 'multi:4', 'multi:5', 'red-fail:2']), ({'channels': [[1, 'R', False], [2, 'G', True], [3, 'R', True]], 'compat': [[3, 1]], 'yellow_durations': [[1, 25], [2, 35]]}, ['short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'Y', False], [4, 'Y', True]], 'compat': [[2, 3], [4, 2]], 'yellow_durations': []}, []), ({'channels': [[1, 'GY', True], [2, '', True], [3, 'R', True]], 'compat': [[1, 2], [1, 3]], 'yellow_durations': [[1, 27]]}, ['multi:1', 'red-fail:2']), ({'channels': [[1, 'G', False], [2, '', True], [3, '', True], [4, '', True], [5, 'G', True], [6, 'RY', True]], 'compat': [[3, 1], [1, 4], [5, 1], [2, 5], [4, 3], [3, 6], [5, 4]], 'yellow_durations': [[3, 28], [5, 35]]}, ['conflict:5-6', 'multi:6', 'red-fail:2', 'red-fail:3', 'red-fail:4'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en:
            continue
        if len(col) > 1 and 'R' not in col:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i + 1, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths < 27:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'RG', True], [2, 'RY', True], [3, '', True]], 'compat': [[2, 3]], 'yellow_durations': []}, ['conflict:1-2', 'multi:1', 'multi:2', 'red-fail:3']), ({'channels': [[1, 'G', True], [2, 'RG', True], [3, 'RG', True], [4, 'R', True], [5, 'Y', True], [6, 'G', True]], 'compat': [[2, 1], [2, 3], [2, 6], [3, 5], [4, 5], [6, 4]], 'yellow_durations': [[1, 35], [3, 25]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:1-6', 'conflict:2-5', 'conflict:3-6', 'conflict:5-6', 'multi:2', 'multi:3', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, '', False], [3, '', True]], 'compat': [[1, 2]], 'yellow_durations': [[1, 30]]}, ['red-fail:3']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'Y', True], [4, '', True]], 'compat': [[2, 1], [4, 1]], 'yellow_durations': []}, ['red-fail:4']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'Y', True], [2, 'Y', True], [3, '', True], [4, '', True], [5, '', True]], 'compat': [[1, 4], [3, 2], [5, 3]], 'yellow_durations': [[1, 27], [2, 25]]}, ['conflict:1-2', 'red-fail:3', 'red-fail:4', 'red-fail:5', 'short-yellow:2']), ({'channels': [[1, '', True], [2, 'RG', True], [3, 'RG', True], [4, 'Y', True], [5, 'RY', False], [6, 'R', True]], 'compat': [[5, 1], [2, 4], [2, 5], [2, 6], [4, 5]], 'yellow_durations': [[4, 30], [6, 27]]}, ['conflict:2-3', 'conflict:3-4', 'multi:2', 'multi:3', 'red-fail:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, [])], [({'channels': [[1, 'R', True], [2, 'Y', False], [3, 'R', True], [4, 'G', True]], 'compat': [[2, 3]], 'yellow_durations': [[1, 27], [3, 35]]}, []), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'RY', True], [5, 'R', True], [6, 'G', False]], 'compat': [[1, 5], [6, 2], [3, 4], [5, 4]], 'yellow_durations': [[1, 26], [6, 35]]}, ['multi:4', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, '', True], [4, 'G', False]], 'compat': [[4, 2], [4, 3]], 'yellow_durations': [[1, 35], [2, 27], [3, 28], [4, 25]]}, ['red-fail:3', 'short-yellow:4']), ({'channels': [[1, 'Y', True], [2, 'Y', True], [3, 'RY', True]], 'compat': [[1, 2], [1, 3]], 'yellow_durations': [[2, 35]]}, ['conflict:2-3', 'multi:3']), ({'channels': [[1, 'Y', True], [2, 'Y', True], [3, '', True]], 'compat': [[1, 3], [2, 3]], 'yellow_durations': [[1, 26], [2, 28]]}, ['conflict:1-2', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, '', True], [3, 'R', True], [4, 'G', True], [5, 'RG', True]], 'compat': [[1, 4], [5, 1], [5, 4]], 'yellow_durations': [[3, 25]]}, ['multi:1', 'multi:5', 'red-fail:2', 'short-yellow:3'])], [({'channels': [[1, 'RY', True], [2, 'RY', False], [3, 'RY', False], [4, 'RG', True], [5, 'GY', True], [6, '', True]], 'compat': [[1, 6], [4, 2], [2, 5], [4, 3], [5, 4]], 'yellow_durations': [[3, 30], [4, 28]]}, ['conflict:1-4', 'conflict:1-5', 'multi:1', 'multi:4', 'multi:5', 'red-fail:6']), ({'channels': [[1, '', False], [2, 'Y', True], [3, 'Y', True], [4, 'R', True]], 'compat': [[1, 2], [1, 3], [4, 1], [4, 2], [3, 4]], 'yellow_durations': [[1, 28], [3, 27], [4, 27]]}, ['conflict:2-3']), ({'channels': [[1, 'R', True], [2, 'R', False], [3, 'G', True], [4, 'RG', False], [5, 'G', True], [6, 'R', False]], 'compat': [[3, 1], [5, 1], [2, 4], [4, 3], [5, 3], [5, 6]], 'yellow_durations': [[1, 28]]}, []), ({'channels': [[1, 'R', True], [2, 'RG', True], [3, 'Y', True], [4, 'R', True], [5, 'RG', True], [6, 'R', True]], 'compat': [[5, 1], [4, 2], [4, 3], [5, 3], [4, 5]], 'yellow_durations': [[2, 28]]}, ['conflict:2-3', 'conflict:2-5', 'multi:2', 'multi:5']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RY', True], [2, 'RY', True], [3, 'R', True], [4, 'GY', True]], 'compat': [[2, 1]], 'yellow_durations': [[1, 28]]}, ['conflict:1-4', 'conflict:2-4', 'multi:1', 'multi:2', 'multi:4']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'R', True], [4, 'R', True], [5, '', True]], 'compat': [[1, 3], [3, 2], [3, 5], [5, 4]], 'yellow_durations': [[3, 26], [4, 30]]}, ['conflict:1-2', 'red-fail:5', 'short-yellow:3'])], [({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'R', True], [4, 'GY', True]], 'compat': [[3, 1], [4, 1], [2, 3], [3, 4]], 'yellow_durations': [[1, 27]]}, ['conflict:2-4', 'multi:4']), ({'channels': [[1, 'R', True], [2, 'RG', True], [3, 'Y', True], [4, 'R', True], [5, 'RG', True], [6, 'Y', True]], 'compat': [], 'yellow_durations': [[4, 26], [5, 35], [6, 28]]}, ['conflict:2-3', 'conflict:2-5', 'conflict:2-6', 'conflict:3-5', 'conflict:3-6', 'conflict:5-6', 'multi:2', 'multi:5', 'short-yellow:4']), ({'channels': [[1, 'Y', True], [2, 'RG', True], [3, 'G', True]], 'compat': [], 'yellow_durations': [[3, 26]]}, ['conflict:1-2', 'conflict:1-3', 'conflict:2-3', 'multi:2', 'short-yellow:3']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, '', True], [4, 'R', True]], 'compat': [[1, 2], [1, 3], [4, 2]], 'yellow_durations': [[4, 27]]}, ['red-fail:3']), ({'channels': [[1, '', True], [2, 'R', True], [3, 'Y', True]], 'compat': [[2, 1], [1, 3], [3, 2]], 'yellow_durations': [[1, 27]]}, ['red-fail:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'R', True], [5, '', True]], 'compat': [[1, 2], [3, 1], [1, 4], [2, 3], [2, 5], [3, 4], [4, 5]], 'yellow_durations': [[1, 28], [3, 27]]}, ['red-fail:5']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, [])], [({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'Y', True], [4, '', True], [5, 'R', True]], 'compat': [[1, 2], [5, 1]], 'yellow_durations': [[2, 25], [5, 30]]}, ['red-fail:4', 'short-yellow:2']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'G', True], [4, 'RY', True], [5, 'GY', True], [6, 'R', True]], 'compat': [[1, 2], [6, 1], [5, 2], [6, 3], [4, 5], [6, 5]], 'yellow_durations': [[6, 28]]}, ['conflict:3-4', 'conflict:3-5', 'multi:4', 'multi:5', 'red-fail:2']), ({'channels': [[1, 'R', False], [2, 'G', True], [3, 'R', True]], 'compat': [[3, 1]], 'yellow_durations': [[1, 25], [2, 35]]}, ['short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'Y', True], [3, 'Y', False], [4, 'Y', True]], 'compat': [[2, 3], [4, 2]], 'yellow_durations': []}, []), ({'channels': [[1, 'GY', True], [2, '', True], [3, 'R', True]], 'compat': [[1, 2], [1, 3]], 'yellow_durations': [[1, 27]]}, ['multi:1', 'red-fail:2']), ({'channels': [[1, 'G', False], [2, '', True], [3, '', True], [4, '', True], [5, 'G', True], [6, 'RY', True]], 'compat': [[3, 1], [1, 4], [5, 1], [2, 5], [4, 3], [3, 6], [5, 4]], 'yellow_durations': [[3, 28], [5, 35]]}, ['conflict:5-6', 'multi:6', 'red-fail:2', 'red-fail:3', 'red-fail:4'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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:
Conflict monitor fault scan returns a wrong result when red plus green is not reported as multiple indications.

Input {channels: [[channel, lit colors string over R/Y/G, enabled]], compat: unordered compatible pairs, yellow_durations: [[channel, tenths]]}. Disabled channels are ignored entirely. A channel with more than one lit color is 'multi'; with none lit is 'red-fail'; any channel showing G or Y takes part in the conflict check, and every live pair not listed as compatible is 'conflict:a-b' (a<b). A completed yellow shorter than 2.7 s is 'short-yellow'. Return the sorted fault strings.

split: open-access


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

N = 1
observations = []
def solve(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en:
            continue
        if len(col) > 1:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i + 2, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths < 27:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'RG', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 25]]}, ['short-yellow:2']), ({'channels': [[1, 'RG', False], [2, 'RY', False], [3, 'R', True], [4, 'R', True]], 'compat': [[3, 1], [1, 4], [4, 3]], 'yellow_durations': []}, []), ({'channels': [[1, 'GY', True], [2, 'R', False], [3, 'RG', True], [4, 'R', True], [5, 'RG', True]], 'compat': [[2, 1], [2, 4], [5, 2], [3, 4]], 'yellow_durations': [[4, 28], [5, 27]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:3-5', 'multi:1', 'multi:3', 'multi:5']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'RG', False], [4, 'R', True], [5, '', True], [6, 'R', True]], 'compat': [[1, 2], [1, 6], [2, 3], [4, 2], [6, 2], [3, 5], [4, 6], [6, 5]], 'yellow_durations': [[1, 25], [3, 26]]}, ['red-fail:2', 'red-fail:5', 'short-yellow:1', 'short-yellow:3']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RG', True], [2, 'G', True], [3, 'GY', True], [4, 'RG', True]], 'compat': [[1, 4], [2, 4], [3, 4]], 'yellow_durations': [[3, 25], [4, 28]]}, ['conflict:1-2', 'conflict:1-3', 'conflict:2-3', 'multi:1', 'multi:3', 'multi:4', 'short-yellow:3']), ({'channels': [[1, 'R', False], [2, 'GY', False], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 25]]}, ['red-fail:3', 'short-yellow:1'])], [({'channels': [[1, 'RY', False], [2, 'R', True], [3, '', True]], 'compat': [[2, 1]], 'yellow_durations': [[2, 25]]}, ['red-fail:3', 'short-yellow:2']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'RG', False], [5, '', True]], 'compat': [[1, 2], [1, 4], [2, 3], [2, 5], [3, 5]], 'yellow_durations': [[1, 26], [3, 28], [5, 27]]}, ['red-fail:5', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'R', False], [3, '', False]], 'compat': [[1, 2]], 'yellow_durations': [[1, 30]]}, []), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'Y', True], [4, 'R', True], [5, 'RG', True]], 'compat': [[2, 3], [2, 5], [4, 5]], 'yellow_durations': [[2, 27], [3, 28]]}, ['conflict:3-5', 'multi:5']), ({'channels': [[1, 'R', False], [2, 'R', True], [3, 'R', True]], 'compat': [], 'yellow_durations': []}, []), ({'channels': [[1, 'GY', True], [2, 'R', False], [3, 'R', True], [4, 'R', True], [5, 'GY', True], [6, 'R', True]], 'compat': [[2, 1], [4, 2], [5, 2], [6, 2], [4, 6], [5, 6]], 'yellow_durations': []}, ['conflict:1-5', 'multi:1', 'multi:5'])], [({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', False]], 'compat': [[2, 1]], 'yellow_durations': [[1, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', False], [3, '', True], [4, 'R', True]], 'compat': [[2, 1], [4, 1], [2, 3], [4, 2]], 'yellow_durations': [[1, 27], [3, 25], [4, 27]]}, ['red-fail:3', 'short-yellow:3']), ({'channels': [[1, 'Y', True], [2, 'RY', True], [3, 'R', True], [4, 'R', True], [5, 'R', True]], 'compat': [[5, 2], [3, 5]], 'yellow_durations': [[1, 35], [5, 35]]}, ['conflict:1-2', 'multi:2']), ({'channels': [[1, 'GY', True], [2, 'GY', True], [3, 'R', True]], 'compat': [], 'yellow_durations': []}, ['conflict:1-2', 'multi:1', 'multi:2']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', False]], 'compat': [], 'yellow_durations': [[2, 35]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'GY', False], [2, 'R', False], [3, '', True]], 'compat': [[3, 2]], 'yellow_durations': [[1, 27], [3, 25]]}, ['red-fail:3', 'short-yellow:3'])], [({'channels': [[1, 'R', True], [2, 'R', True], [3, '', False], [4, 'R', True], [5, 'R', True], [6, 'RY', False]], 'compat': [[4, 1], [5, 1], [5, 2], [2, 6], [5, 4], [4, 6]], 'yellow_durations': []}, []), ({'channels': [[1, 'Y', True], [2, 'R', True], [3, 'GY', True], [4, 'RY', True], [5, 'R', True]], 'compat': [[2, 1], [4, 5]], 'yellow_durations': [[4, 30], [5, 26]]}, ['conflict:1-3', 'conflict:1-4', 'conflict:3-4', 'multi:3', 'multi:4', 'short-yellow:5']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, '', False], [3, 'R', False], [4, 'R', True]], 'compat': [[2, 1], [2, 3], [4, 3]], 'yellow_durations': [[2, 25]]}, ['short-yellow:2']), ({'channels': [[1, '', True], [2, 'R', True], [3, 'R', True]], 'compat': [[1, 2]], 'yellow_durations': [[2, 28]]}, ['red-fail:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'Y', True], [5, 'R', False], [6, 'RY', True]], 'compat': [[1, 3], [1, 5], [2, 3], [6, 2], [4, 3]], 'yellow_durations': [[2, 27], [3, 28], [5, 26], [6, 25]]}, ['conflict:4-6', 'multi:6', 'short-yellow:5', 'short-yellow:6']), ({'channels': [[1, '', True], [2, 'R', True], [3, '', True], [4, 'R', True], [5, 'R', True]], 'compat': [[1, 2], [3, 1], [1, 4], [4, 2], [5, 3]], 'yellow_durations': []}, ['red-fail:1', 'red-fail:3'])], [({'channels': [[1, '', True], [2, 'R', False], [3, 'R', True]], 'compat': [[2, 3]], 'yellow_durations': []}, ['red-fail:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, '', True], [2, 'RG', True], [3, 'Y', True], [4, 'R', True], [5, 'R', False]], 'compat': [[5, 4]], 'yellow_durations': [[3, 35]]}, ['conflict:2-3', 'multi:2', 'red-fail:1']), ({'channels': [[1, '', True], [2, '', True], [3, 'R', True]], 'compat': [[3, 1]], 'yellow_durations': []}, ['red-fail:1', 'red-fail:2']), ({'channels': [[1, 'G', False], [2, '', True], [3, '', False], [4, 'Y', False]], 'compat': [[1, 4], [3, 2], [4, 2]], 'yellow_durations': [[1, 26], [3, 27]]}, ['red-fail:2', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'R', True]], 'compat': [[3, 1], [1, 4], [4, 2]], 'yellow_durations': [[1, 25], [2, 28]]}, ['short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'RY', True], [4, 'R', True]], 'compat': [[1, 4], [2, 3]], 'yellow_durations': [[1, 35]]}, ['conflict:1-2', 'conflict:1-3', 'multi:3'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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(x):
    ok = {(min(a, b), max(a, b)) for a, b in x['compat']}
    faults = []
    live = []
    for ch, col, en in x['channels']:
        if not en:
            continue
        if len(col) > 1:
            faults.append('multi:%d' % ch)
        if col == '':
            faults.append('red-fail:%d' % ch)
        if 'G' in col or 'Y' in col:
            live.append(ch)
    live.sort()
    for i in range(len(live)):
        for j in range(i, len(live)):
            if (live[i], live[j]) not in ok:
                faults.append('conflict:%d-%d' % (live[i], live[j]))
    for ch, tenths in x['yellow_durations']:
        if tenths < 27:
            faults.append('short-yellow:%d' % ch)
    return sorted(faults)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'RG', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 25]]}, ['short-yellow:2']), ({'channels': [[1, 'RG', False], [2, 'RY', False], [3, 'R', True], [4, 'R', True]], 'compat': [[3, 1], [1, 4], [4, 3]], 'yellow_durations': []}, []), ({'channels': [[1, 'GY', True], [2, 'R', False], [3, 'RG', True], [4, 'R', True], [5, 'RG', True]], 'compat': [[2, 1], [2, 4], [5, 2], [3, 4]], 'yellow_durations': [[4, 28], [5, 27]]}, ['conflict:1-3', 'conflict:1-5', 'conflict:3-5', 'multi:1', 'multi:3', 'multi:5']), ({'channels': [[1, 'R', True], [2, '', True], [3, 'RG', False], [4, 'R', True], [5, '', True], [6, 'R', True]], 'compat': [[1, 2], [1, 6], [2, 3], [4, 2], [6, 2], [3, 5], [4, 6], [6, 5]], 'yellow_durations': [[1, 25], [3, 26]]}, ['red-fail:2', 'red-fail:5', 'short-yellow:1', 'short-yellow:3']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'RG', True], [2, 'G', True], [3, 'GY', True], [4, 'RG', True]], 'compat': [[1, 4], [2, 4], [3, 4]], 'yellow_durations': [[3, 25], [4, 28]]}, ['conflict:1-2', 'conflict:1-3', 'conflict:2-3', 'multi:1', 'multi:3', 'multi:4', 'short-yellow:3']), ({'channels': [[1, 'R', False], [2, 'GY', False], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 25]]}, ['red-fail:3', 'short-yellow:1'])], [({'channels': [[1, 'RY', False], [2, 'R', True], [3, '', True]], 'compat': [[2, 1]], 'yellow_durations': [[2, 25]]}, ['red-fail:3', 'short-yellow:2']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'RG', False], [5, '', True]], 'compat': [[1, 2], [1, 4], [2, 3], [2, 5], [3, 5]], 'yellow_durations': [[1, 26], [3, 28], [5, 27]]}, ['red-fail:5', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'R', False], [3, '', False]], 'compat': [[1, 2]], 'yellow_durations': [[1, 30]]}, []), ({'channels': [[1, 'R', True], [2, 'G', True], [3, 'Y', True], [4, 'R', True], [5, 'RG', True]], 'compat': [[2, 3], [2, 5], [4, 5]], 'yellow_durations': [[2, 27], [3, 28]]}, ['conflict:3-5', 'multi:5']), ({'channels': [[1, 'R', False], [2, 'R', True], [3, 'R', True]], 'compat': [], 'yellow_durations': []}, []), ({'channels': [[1, 'GY', True], [2, 'R', False], [3, 'R', True], [4, 'R', True], [5, 'GY', True], [6, 'R', True]], 'compat': [[2, 1], [4, 2], [5, 2], [6, 2], [4, 6], [5, 6]], 'yellow_durations': []}, ['conflict:1-5', 'multi:1', 'multi:5'])], [({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', False]], 'compat': [[2, 1]], 'yellow_durations': [[1, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', False], [3, '', True], [4, 'R', True]], 'compat': [[2, 1], [4, 1], [2, 3], [4, 2]], 'yellow_durations': [[1, 27], [3, 25], [4, 27]]}, ['red-fail:3', 'short-yellow:3']), ({'channels': [[1, 'Y', True], [2, 'RY', True], [3, 'R', True], [4, 'R', True], [5, 'R', True]], 'compat': [[5, 2], [3, 5]], 'yellow_durations': [[1, 35], [5, 35]]}, ['conflict:1-2', 'multi:2']), ({'channels': [[1, 'GY', True], [2, 'GY', True], [3, 'R', True]], 'compat': [], 'yellow_durations': []}, ['conflict:1-2', 'multi:1', 'multi:2']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', False]], 'compat': [], 'yellow_durations': [[2, 35]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'GY', False], [2, 'R', False], [3, '', True]], 'compat': [[3, 2]], 'yellow_durations': [[1, 27], [3, 25]]}, ['red-fail:3', 'short-yellow:3'])], [({'channels': [[1, 'R', True], [2, 'R', True], [3, '', False], [4, 'R', True], [5, 'R', True], [6, 'RY', False]], 'compat': [[4, 1], [5, 1], [5, 2], [2, 6], [5, 4], [4, 6]], 'yellow_durations': []}, []), ({'channels': [[1, 'Y', True], [2, 'R', True], [3, 'GY', True], [4, 'RY', True], [5, 'R', True]], 'compat': [[2, 1], [4, 5]], 'yellow_durations': [[4, 30], [5, 26]]}, ['conflict:1-3', 'conflict:1-4', 'conflict:3-4', 'multi:3', 'multi:4', 'short-yellow:5']), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'R', True], [2, '', False], [3, 'R', False], [4, 'R', True]], 'compat': [[2, 1], [2, 3], [4, 3]], 'yellow_durations': [[2, 25]]}, ['short-yellow:2']), ({'channels': [[1, '', True], [2, 'R', True], [3, 'R', True]], 'compat': [[1, 2]], 'yellow_durations': [[2, 28]]}, ['red-fail:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'Y', True], [5, 'R', False], [6, 'RY', True]], 'compat': [[1, 3], [1, 5], [2, 3], [6, 2], [4, 3]], 'yellow_durations': [[2, 27], [3, 28], [5, 26], [6, 25]]}, ['conflict:4-6', 'multi:6', 'short-yellow:5', 'short-yellow:6']), ({'channels': [[1, '', True], [2, 'R', True], [3, '', True], [4, 'R', True], [5, 'R', True]], 'compat': [[1, 2], [3, 1], [1, 4], [4, 2], [5, 3]], 'yellow_durations': []}, ['red-fail:1', 'red-fail:3'])], [({'channels': [[1, '', True], [2, 'R', False], [3, 'R', True]], 'compat': [[2, 3]], 'yellow_durations': []}, ['red-fail:1']), ({'channels': [[1, 'G', True], [2, 'R', True], [3, 'Y', True], [4, 'G', False]], 'compat': [[3, 1]], 'yellow_durations': [[2, 27]]}, []), ({'channels': [[1, 'GY', True], [2, 'G', True], [3, '', True]], 'compat': [], 'yellow_durations': [[1, 26]]}, ['conflict:1-2', 'multi:1', 'red-fail:3', 'short-yellow:1']), ({'channels': [[1, '', True], [2, 'RG', True], [3, 'Y', True], [4, 'R', True], [5, 'R', False]], 'compat': [[5, 4]], 'yellow_durations': [[3, 35]]}, ['conflict:2-3', 'multi:2', 'red-fail:1']), ({'channels': [[1, '', True], [2, '', True], [3, 'R', True]], 'compat': [[3, 1]], 'yellow_durations': []}, ['red-fail:1', 'red-fail:2']), ({'channels': [[1, 'G', False], [2, '', True], [3, '', False], [4, 'Y', False]], 'compat': [[1, 4], [3, 2], [4, 2]], 'yellow_durations': [[1, 26], [3, 27]]}, ['red-fail:2', 'short-yellow:1']), ({'channels': [[1, 'R', True], [2, 'R', True], [3, 'R', True], [4, 'R', True]], 'compat': [[3, 1], [1, 4], [4, 2]], 'yellow_durations': [[1, 25], [2, 28]]}, ['short-yellow:1']), ({'channels': [[1, 'G', True], [2, 'Y', True], [3, 'RY', True], [4, 'R', True]], 'compat': [[1, 4], [2, 3]], 'yellow_durations': [[1, 35]]}, ['conflict:1-2', 'conflict:1-3', 'multi:3'])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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:
Conflict monitor fault scan returns a wrong result when each live channel is paired with itself.

Input {channels: [[channel, lit colors string over R/Y/G, enabled]], compat: unordered compatible pairs, yellow_durations: [[channel, tenths]]}. Disabled channels are ignored entirely. A channel with more than one lit color is 'multi'; with none lit is 'red-fail'; any channel showing G or Y takes part in the conflict check, and every live pair not listed as compatible is 'conflict:a-b' (a<b). A completed yellow shorter than 2.7 s is 'short-yellow'. Return the sorted fault strings.

split: open-access


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

N = 1
observations = []
def solve(x):
    par = set(x['parents'])
    nd = set(x['not_during'])
    cur = {ph: iv for ph, iv in x['state']}
    if all(cur.get(p) == 'G' for p in nd):
        return 'R'
    if any(cur.get(p) == 'G' for p in par):
        return 'G'
    terminating = [p for p in sorted(par) if cur.get(p) in ('Y', 'RC')]
    if terminating:
        if any(p in par for p in x['next']):
            return 'G'
        if any(cur[p] == 'Y' for p in terminating):
            return 'Y'
        return 'R'
    return 'R'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'parents': [4, 5, 8], 'not_during': [], 'state': [[5, 'G'], [7, 'G'], [2, 'G']], 'next': []}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3, 8], 'not_during': [5, 7], 'state': [[5, 'Y'], [3, 'Y'], [4, 'Y']], 'next': [5, 8]}, 'G'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [2, 8], 'not_during': [3, 7], 'state': [[1, 'G'], [5, 'RC'], [7, 'R']], 'next': [4, 5]}, 'R'), ({'parents': [1], 'not_during': [3], 'state': [[1, 'G'], [3, 'Y']], 'next': [8]}, 'G'), ({'parents': [3, 5], 'not_during': [], 'state': [[2, 'G'], [6, 'RC'], [7, 'G']], 'next': [3]}, 'R')], [({'parents': [1, 2, 5], 'not_during': [4, 6], 'state': [[2, 'R']], 'next': []}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 8], 'not_during': [5], 'state': [[2, 'Y'], [5, 'Y']], 'next': []}, 'Y'), ({'parents': [1, 3, 5], 'not_during': [], 'state': [[8, 'G'], [3, 'G'], [4, 'R']], 'next': [4]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 4, 5], 'not_during': [6, 7], 'state': [[8, 'R']], 'next': []}, 'R'), ({'parents': [6, 7], 'not_during': [1], 'state': [[7, 'Y'], [8, 'RC'], [1, 'Y']], 'next': []}, 'Y')], [({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [1, 6, 8], 'not_during': [3, 7], 'state': [[1, 'RC'], [3, 'Y']], 'next': [1, 3]}, 'G'), ({'parents': [2, 4, 8], 'not_during': [5, 6], 'state': [[8, 'G'], [3, 'RC'], [5, 'G']], 'next': [7]}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 4, 7], 'not_during': [8], 'state': [[1, 'R']], 'next': [3]}, 'R'), ({'parents': [2], 'not_during': [1, 4], 'state': [[1, 'G']], 'next': [5]}, 'R'), ({'parents': [1, 2, 4], 'not_during': [5, 8], 'state': [[7, 'RC']], 'next': []}, 'R')], [({'parents': [5, 7], 'not_during': [1, 3], 'state': [[2, 'RC'], [7, 'Y'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [1, 4, 5], 'not_during': [2, 6], 'state': [[6, 'Y'], [5, 'Y'], [1, 'R']], 'next': []}, 'Y'), ({'parents': [1, 3, 7], 'not_during': [5, 6], 'state': [[1, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2], 'not_during': [4, 7], 'state': [[4, 'RC'], [1, 'RC'], [7, 'R']], 'next': [7, 8]}, 'R'), ({'parents': [1, 2, 5], 'not_during': [4, 8], 'state': [[4, 'R'], [8, 'RC'], [5, 'Y']], 'next': [7, 8]}, 'Y')], [({'parents': [6, 7], 'not_during': [5, 8], 'state': [[8, 'Y'], [7, 'G']], 'next': [4]}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [1, 6, 8], 'not_during': [3, 7], 'state': [[6, 'G'], [1, 'Y'], [7, 'G']], 'next': []}, 'R'), ({'parents': [2, 4], 'not_during': [6], 'state': [[4, 'Y'], [6, 'Y']], 'next': [2]}, 'G'), ({'parents': [3, 4, 6], 'not_during': [7], 'state': [[2, 'G'], [5, 'R'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 2, 4], 'not_during': [], 'state': [[8, 'RC']], 'next': [2, 7]}, 'R')]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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(x):
    par = set(x['parents'])
    nd = set(x['not_during'])
    cur = {ph: iv for ph, iv in x['state']}
    if any(cur.get(p) in ('G', 'Y') for p in nd):
        return 'R'
    if any(cur.get(p) == 'G' for p in par):
        return 'G'
    terminating = [p for p in sorted(par) if cur.get(p) in ('Y', 'RC')]
    if terminating:
        if any(p in par for p in x['next']):
            return 'G'
        if any(cur[p] == 'Y' for p in terminating):
            return 'Y'
        return 'R'
    return 'R'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'parents': [4, 5, 8], 'not_during': [], 'state': [[5, 'G'], [7, 'G'], [2, 'G']], 'next': []}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3, 8], 'not_during': [5, 7], 'state': [[5, 'Y'], [3, 'Y'], [4, 'Y']], 'next': [5, 8]}, 'G'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [2, 8], 'not_during': [3, 7], 'state': [[1, 'G'], [5, 'RC'], [7, 'R']], 'next': [4, 5]}, 'R'), ({'parents': [1], 'not_during': [3], 'state': [[1, 'G'], [3, 'Y']], 'next': [8]}, 'G'), ({'parents': [3, 5], 'not_during': [], 'state': [[2, 'G'], [6, 'RC'], [7, 'G']], 'next': [3]}, 'R')], [({'parents': [1, 2, 5], 'not_during': [4, 6], 'state': [[2, 'R']], 'next': []}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 8], 'not_during': [5], 'state': [[2, 'Y'], [5, 'Y']], 'next': []}, 'Y'), ({'parents': [1, 3, 5], 'not_during': [], 'state': [[8, 'G'], [3, 'G'], [4, 'R']], 'next': [4]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 4, 5], 'not_during': [6, 7], 'state': [[8, 'R']], 'next': []}, 'R'), ({'parents': [6, 7], 'not_during': [1], 'state': [[7, 'Y'], [8, 'RC'], [1, 'Y']], 'next': []}, 'Y')], [({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [1, 6, 8], 'not_during': [3, 7], 'state': [[1, 'RC'], [3, 'Y']], 'next': [1, 3]}, 'G'), ({'parents': [2, 4, 8], 'not_during': [5, 6], 'state': [[8, 'G'], [3, 'RC'], [5, 'G']], 'next': [7]}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 4, 7], 'not_during': [8], 'state': [[1, 'R']], 'next': [3]}, 'R'), ({'parents': [2], 'not_during': [1, 4], 'state': [[1, 'G']], 'next': [5]}, 'R'), ({'parents': [1, 2, 4], 'not_during': [5, 8], 'state': [[7, 'RC']], 'next': []}, 'R')], [({'parents': [5, 7], 'not_during': [1, 3], 'state': [[2, 'RC'], [7, 'Y'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [1, 4, 5], 'not_during': [2, 6], 'state': [[6, 'Y'], [5, 'Y'], [1, 'R']], 'next': []}, 'Y'), ({'parents': [1, 3, 7], 'not_during': [5, 6], 'state': [[1, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2], 'not_during': [4, 7], 'state': [[4, 'RC'], [1, 'RC'], [7, 'R']], 'next': [7, 8]}, 'R'), ({'parents': [1, 2, 5], 'not_during': [4, 8], 'state': [[4, 'R'], [8, 'RC'], [5, 'Y']], 'next': [7, 8]}, 'Y')], [({'parents': [6, 7], 'not_during': [5, 8], 'state': [[8, 'Y'], [7, 'G']], 'next': [4]}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [1, 6, 8], 'not_during': [3, 7], 'state': [[6, 'G'], [1, 'Y'], [7, 'G']], 'next': []}, 'R'), ({'parents': [2, 4], 'not_during': [6], 'state': [[4, 'Y'], [6, 'Y']], 'next': [2]}, 'G'), ({'parents': [3, 4, 6], 'not_during': [7], 'state': [[2, 'G'], [5, 'R'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 2, 4], 'not_during': [], 'state': [[8, 'RC']], 'next': [2, 7]}, 'R')]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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:
Overlap phase indication returns a wrong result when the inhibit applies only when every not-during phase is green.

Input {parents, not_during, state: [[phase, G|Y|RC|R]] for timing phases, next: phases to be served next}. The overlap is red while any not_during phase is green. Otherwise it is green while any parent is green. If a parent is terminating (Y or RC) the overlap stays green when any next phase is a parent; otherwise it is yellow if any terminating parent is in yellow, else red. Otherwise red.

split: open-access


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

N = 1
observations = []
def solve(x):
    par = set(x['parents'])
    nd = set(x['not_during'])
    cur = {ph: iv for ph, iv in x['state']}
    if any(cur.get(p) == 'G' for p in nd):
        return 'R'
    if any(cur.get(p) in ('G', 'Y') for p in par):
        return 'G'
    terminating = [p for p in sorted(par) if cur.get(p) in ('Y', 'RC')]
    if terminating:
        if any(p in par for p in x['next']):
            return 'G'
        if any(cur[p] == 'Y' for p in terminating):
            return 'Y'
        return 'R'
    return 'R'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 3, 4], 'not_during': [], 'state': [[8, 'Y'], [7, 'G'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [1, 2, 3], 'not_during': [], 'state': [[3, 'G']], 'next': [6, 7]}, 'G'), ({'parents': [1, 7], 'not_during': [4, 6], 'state': [[2, 'G'], [1, 'Y'], [8, 'R']], 'next': [8]}, 'Y'), ({'parents': [2, 5, 7], 'not_during': [3, 8], 'state': [[8, 'R'], [5, 'G']], 'next': [4]}, 'G'), ({'parents': [5, 7], 'not_during': [8], 'state': [[4, 'RC']], 'next': [2]}, 'R'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y')], [({'parents': [3, 4, 7], 'not_during': [], 'state': [[3, 'Y']], 'next': [2, 8]}, 'Y'), ({'parents': [1, 2, 8], 'not_during': [6], 'state': [[8, 'G'], [4, 'Y']], 'next': [3]}, 'G'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [8], 'not_during': [], 'state': [[7, 'Y'], [3, 'G'], [1, 'R']], 'next': [4]}, 'R'), ({'parents': [4, 5, 7], 'not_during': [2], 'state': [[5, 'Y'], [2, 'RC'], [1, 'Y']], 'next': []}, 'Y'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [1, 2, 4], 'not_during': [3, 6], 'state': [[5, 'RC'], [2, 'G'], [1, 'RC']], 'next': [5]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G')], [({'parents': [2, 6, 8], 'not_during': [], 'state': [[7, 'G'], [8, 'G'], [1, 'Y']], 'next': [3, 5]}, 'G'), ({'parents': [3, 4, 5], 'not_during': [], 'state': [[4, 'G']], 'next': [6]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2], 'not_during': [7], 'state': [[2, 'Y'], [6, 'R']], 'next': [3, 7]}, 'Y'), ({'parents': [2], 'not_during': [3, 6], 'state': [[7, 'G'], [2, 'G'], [6, 'Y']], 'next': [1, 4]}, 'G'), ({'parents': [5], 'not_during': [2, 4], 'state': [[1, 'R'], [5, 'Y'], [8, 'R']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R')], [({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [5, 6, 8], 'not_during': [4], 'state': [[6, 'G']], 'next': [5, 8]}, 'G'), ({'parents': [3, 4, 6], 'not_during': [], 'state': [[7, 'Y'], [6, 'Y']], 'next': [2]}, 'Y'), ({'parents': [6], 'not_during': [], 'state': [[6, 'R'], [5, 'RC']], 'next': []}, 'R'), ({'parents': [4, 5, 8], 'not_during': [2, 3], 'state': [[6, 'G'], [5, 'G'], [8, 'Y']], 'next': [3]}, 'G'), ({'parents': [3, 4, 6], 'not_during': [], 'state': [[1, 'Y'], [4, 'RC'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R')], [({'parents': [1, 3, 8], 'not_during': [], 'state': [[2, 'G'], [4, 'Y'], [6, 'R']], 'next': [1]}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [1, 7], 'not_during': [2, 5], 'state': [[7, 'G'], [3, 'Y']], 'next': []}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[5, 'Y'], [6, 'G']], 'next': []}, 'Y'), ({'parents': [3, 4], 'not_during': [], 'state': [[4, 'G'], [7, 'G'], [5, 'RC']], 'next': [2]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [2, 6], 'not_during': [4], 'state': [[3, 'G'], [2, 'Y'], [4, 'R']], 'next': []}, 'Y')]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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(x):
    par = set(x['parents'])
    nd = set(x['not_during'])
    cur = {ph: iv for ph, iv in x['state']}
    if any(cur.get(p) == 'G' for p in nd):
        return 'R'
    if cur.get(min(par)) == 'G':
        return 'G'
    terminating = [p for p in sorted(par) if cur.get(p) in ('Y', 'RC')]
    if terminating:
        if any(p in par for p in x['next']):
            return 'G'
        if any(cur[p] == 'Y' for p in terminating):
            return 'Y'
        return 'R'
    return 'R'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [1, 3, 4], 'not_during': [], 'state': [[8, 'Y'], [7, 'G'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [1, 2, 3], 'not_during': [], 'state': [[3, 'G']], 'next': [6, 7]}, 'G'), ({'parents': [1, 7], 'not_during': [4, 6], 'state': [[2, 'G'], [1, 'Y'], [8, 'R']], 'next': [8]}, 'Y'), ({'parents': [2, 5, 7], 'not_during': [3, 8], 'state': [[8, 'R'], [5, 'G']], 'next': [4]}, 'G'), ({'parents': [5, 7], 'not_during': [8], 'state': [[4, 'RC']], 'next': [2]}, 'R'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y')], [({'parents': [3, 4, 7], 'not_during': [], 'state': [[3, 'Y']], 'next': [2, 8]}, 'Y'), ({'parents': [1, 2, 8], 'not_during': [6], 'state': [[8, 'G'], [4, 'Y']], 'next': [3]}, 'G'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [8], 'not_during': [], 'state': [[7, 'Y'], [3, 'G'], [1, 'R']], 'next': [4]}, 'R'), ({'parents': [4, 5, 7], 'not_during': [2], 'state': [[5, 'Y'], [2, 'RC'], [1, 'Y']], 'next': []}, 'Y'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [1, 2, 4], 'not_during': [3, 6], 'state': [[5, 'RC'], [2, 'G'], [1, 'RC']], 'next': [5]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G')], [({'parents': [2, 6, 8], 'not_during': [], 'state': [[7, 'G'], [8, 'G'], [1, 'Y']], 'next': [3, 5]}, 'G'), ({'parents': [3, 4, 5], 'not_during': [], 'state': [[4, 'G']], 'next': [6]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2], 'not_during': [7], 'state': [[2, 'Y'], [6, 'R']], 'next': [3, 7]}, 'Y'), ({'parents': [2], 'not_during': [3, 6], 'state': [[7, 'G'], [2, 'G'], [6, 'Y']], 'next': [1, 4]}, 'G'), ({'parents': [5], 'not_during': [2, 4], 'state': [[1, 'R'], [5, 'Y'], [8, 'R']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R')], [({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [5, 6, 8], 'not_during': [4], 'state': [[6, 'G']], 'next': [5, 8]}, 'G'), ({'parents': [3, 4, 6], 'not_during': [], 'state': [[7, 'Y'], [6, 'Y']], 'next': [2]}, 'Y'), ({'parents': [6], 'not_during': [], 'state': [[6, 'R'], [5, 'RC']], 'next': []}, 'R'), ({'parents': [4, 5, 8], 'not_during': [2, 3], 'state': [[6, 'G'], [5, 'G'], [8, 'Y']], 'next': [3]}, 'G'), ({'parents': [3, 4, 6], 'not_during': [], 'state': [[1, 'Y'], [4, 'RC'], [3, 'Y']], 'next': []}, 'Y'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R')], [({'parents': [1, 3, 8], 'not_during': [], 'state': [[2, 'G'], [4, 'Y'], [6, 'R']], 'next': [1]}, 'R'), ({'parents': [4, 5], 'not_during': [], 'state': [[4, 'RC'], [5, 'Y']], 'next': [1]}, 'Y'), ({'parents': [2, 3], 'not_during': [5], 'state': [[3, 'G'], [5, 'G']], 'next': []}, 'R'), ({'parents': [1, 7], 'not_during': [2, 5], 'state': [[7, 'G'], [3, 'Y']], 'next': []}, 'G'), ({'parents': [4, 5], 'not_during': [], 'state': [[5, 'Y'], [6, 'G']], 'next': []}, 'Y'), ({'parents': [3, 4], 'not_during': [], 'state': [[4, 'G'], [7, 'G'], [5, 'RC']], 'next': [2]}, 'G'), ({'parents': [2, 3], 'not_during': [], 'state': [[2, 'RC'], [6, 'RC']], 'next': [3, 7]}, 'G'), ({'parents': [2, 6], 'not_during': [4], 'state': [[3, 'G'], [2, 'Y'], [4, 'R']], 'next': []}, 'Y')]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), 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:
Overlap phase indication returns a wrong result when a parent in yellow keeps the overlap green.

Input {parents, not_during, state: [[phase, G|Y|RC|R]] for timing phases, next: phases to be served next}. The overlap is red while any not_during phase is green. Otherwise it is green while any parent is green. If a parent is terminating (Y or RC) the overlap stays green when any next phase is a parent; otherwise it is yellow if any terminating parent is in yellow, else red. Otherwise red.

split: open-access