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

N = 1
observations = []
def solve(x):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'yellow', 'elapsed': 5, 'min_green': 13, 'preempt_min_green': 3, 'yellow': 6, 'red': 3, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [4, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 12, 'preempt_min_green': 10, 'yellow': 4, 'red': 1, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': True, 'track_current': False}, [14, 9]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 8, 'preempt_min_green': 6, 'yellow': 5, 'red': 2, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': True}, [5, 0]), ({'state': 'green', 'elapsed': 13, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 6, 'red': 2, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'red', 'elapsed': 1, 'min_green': 13, 'preempt_min_green': 5, 'yellow': 5, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': True}, [2, 0]), ({'state': 'yellow', 'elapsed': 6, 'min_green': 10, 'preempt_min_green': 10, 'yellow': 6, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': True}, [1, 0])], [({'state': 'red', 'elapsed': 7, 'min_green': 11, 'preempt_min_green': 5, 'yellow': 6, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 8, 'preempt_min_green': 2, 'yellow': 3, 'red': 2, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 0, 'min_green': 20, 'preempt_min_green': 3, 'yellow': 4, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 5, 'min_green': 13, 'preempt_min_green': 3, 'yellow': 6, 'red': 1, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': True, 'track_current': True}, [2, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 14, 'preempt_min_green': 7, 'yellow': 4, 'red': 2, 'fdw': 20, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [6, 0])], [({'state': 'green', 'elapsed': 16, 'min_green': 19, 'preempt_min_green': 8, 'yellow': 6, 'red': 3, 'fdw': 17, 'ped': 'fdw', 'ped_elapsed': 15, 'ped_truncate': False, 'track_current': False}, [11, 2]), ({'state': 'green', 'elapsed': 2, 'min_green': 15, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [15, 7]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 13, 'min_green': 8, 'preempt_min_green': 2, 'yellow': 3, 'red': 2, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': True, 'track_current': False}, [5, 0]), ({'state': 'yellow', 'elapsed': 5, 'min_green': 15, 'preempt_min_green': 2, 'yellow': 3, 'red': 2, 'fdw': 17, 'ped': 'none', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [2, 0]), ({'state': 'yellow', 'elapsed': 1, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 4, 'red': 3, 'fdw': 19, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [6, 0]), ({'state': 'yellow', 'elapsed': 0, 'min_green': 20, 'preempt_min_green': 3, 'yellow': 3, 'red': 3, 'fdw': 19, 'ped': 'none', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [6, 0])], [({'state': 'green', 'elapsed': 17, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 17, 'ped': 'fdw', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'yellow', 'elapsed': 1, 'min_green': 16, 'preempt_min_green': 7, 'yellow': 3, 'red': 3, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [5, 0]), ({'state': 'green', 'elapsed': 18, 'min_green': 16, 'preempt_min_green': 9, 'yellow': 6, 'red': 3, 'fdw': 20, 'ped': 'fdw', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [9, 0]), ({'state': 'yellow', 'elapsed': 3, 'min_green': 12, 'preempt_min_green': 2, 'yellow': 3, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 5, 'min_green': 9, 'preempt_min_green': 4, 'yellow': 6, 'red': 2, 'fdw': 22, 'ped': 'none', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'red', 'elapsed': 5, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 3, 'red': 1, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [0, 0])], [({'state': 'yellow', 'elapsed': 1, 'min_green': 17, 'preempt_min_green': 8, 'yellow': 6, 'red': 1, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 14, 'ped_truncate': False, 'track_current': True}, [6, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 9, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 5, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 11, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 17, 'min_green': 20, 'preempt_min_green': 5, 'yellow': 3, 'red': 3, 'fdw': 19, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'red', 'elapsed': 4, 'min_green': 12, 'preempt_min_green': 9, 'yellow': 6, 'red': 1, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 13, 'min_green': 12, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 3, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 15, 'preempt_min_green': 8, 'yellow': 3, 'red': 3, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [4, 0])]]
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):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [max(0, y - el), 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'yellow', 'elapsed': 5, 'min_green': 13, 'preempt_min_green': 3, 'yellow': 6, 'red': 3, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [4, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 12, 'preempt_min_green': 10, 'yellow': 4, 'red': 1, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': True, 'track_current': False}, [14, 9]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 8, 'preempt_min_green': 6, 'yellow': 5, 'red': 2, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': True}, [5, 0]), ({'state': 'green', 'elapsed': 13, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 6, 'red': 2, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'red', 'elapsed': 1, 'min_green': 13, 'preempt_min_green': 5, 'yellow': 5, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': True}, [2, 0]), ({'state': 'yellow', 'elapsed': 6, 'min_green': 10, 'preempt_min_green': 10, 'yellow': 6, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': True}, [1, 0])], [({'state': 'red', 'elapsed': 7, 'min_green': 11, 'preempt_min_green': 5, 'yellow': 6, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 8, 'preempt_min_green': 2, 'yellow': 3, 'red': 2, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 0, 'min_green': 20, 'preempt_min_green': 3, 'yellow': 4, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 5, 'min_green': 13, 'preempt_min_green': 3, 'yellow': 6, 'red': 1, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': True, 'track_current': True}, [2, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 14, 'preempt_min_green': 7, 'yellow': 4, 'red': 2, 'fdw': 20, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [6, 0])], [({'state': 'green', 'elapsed': 16, 'min_green': 19, 'preempt_min_green': 8, 'yellow': 6, 'red': 3, 'fdw': 17, 'ped': 'fdw', 'ped_elapsed': 15, 'ped_truncate': False, 'track_current': False}, [11, 2]), ({'state': 'green', 'elapsed': 2, 'min_green': 15, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [15, 7]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 13, 'min_green': 8, 'preempt_min_green': 2, 'yellow': 3, 'red': 2, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': True, 'track_current': False}, [5, 0]), ({'state': 'yellow', 'elapsed': 5, 'min_green': 15, 'preempt_min_green': 2, 'yellow': 3, 'red': 2, 'fdw': 17, 'ped': 'none', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [2, 0]), ({'state': 'yellow', 'elapsed': 1, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 4, 'red': 3, 'fdw': 19, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [6, 0]), ({'state': 'yellow', 'elapsed': 0, 'min_green': 20, 'preempt_min_green': 3, 'yellow': 3, 'red': 3, 'fdw': 19, 'ped': 'none', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [6, 0])], [({'state': 'green', 'elapsed': 17, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 17, 'ped': 'fdw', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'yellow', 'elapsed': 1, 'min_green': 16, 'preempt_min_green': 7, 'yellow': 3, 'red': 3, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [5, 0]), ({'state': 'green', 'elapsed': 18, 'min_green': 16, 'preempt_min_green': 9, 'yellow': 6, 'red': 3, 'fdw': 20, 'ped': 'fdw', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [9, 0]), ({'state': 'yellow', 'elapsed': 3, 'min_green': 12, 'preempt_min_green': 2, 'yellow': 3, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 5, 'min_green': 9, 'preempt_min_green': 4, 'yellow': 6, 'red': 2, 'fdw': 22, 'ped': 'none', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'red', 'elapsed': 5, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 3, 'red': 1, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [0, 0])], [({'state': 'yellow', 'elapsed': 1, 'min_green': 17, 'preempt_min_green': 8, 'yellow': 6, 'red': 1, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 14, 'ped_truncate': False, 'track_current': True}, [6, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 9, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 5, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 11, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 17, 'min_green': 20, 'preempt_min_green': 5, 'yellow': 3, 'red': 3, 'fdw': 19, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'red', 'elapsed': 4, 'min_green': 12, 'preempt_min_green': 9, 'yellow': 6, 'red': 1, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 13, 'min_green': 12, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 3, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 15, 'preempt_min_green': 8, 'yellow': 3, 'red': 3, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [4, 0])]]
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:
Railroad preemption entry timing returns a wrong result when an active yellow is truncated on preemption.

Input {state: green|yellow|red (red = all-red clearance), elapsed, min_green, preempt_min_green, yellow, red, fdw, ped: none|walk|fdw, ped_elapsed, ped_truncate, track_current}. If the track clearance phase is already green the answer is [0, 0]. In all-red the remaining red is timed; in yellow the remaining yellow and full red are timed. In green the hold is the larger of the remaining preempt minimum green (not the normal minimum) and the pedestrian time: walk is abandoned and FDW is timed in full, or skipped when ped_truncate; an active FDW completes its remainder unless truncated. Return [seconds until track clearance green, green hold].

split: open-access


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

N = 1
observations = []
def solve(x):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'red', 'elapsed': 20, 'min_green': 20, 'preempt_min_green': 4, 'yellow': 5, 'red': 3, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 2, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 7, 'min_green': 15, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 11, 'ped': 'walk', 'ped_elapsed': 10, 'ped_truncate': True, 'track_current': False}, [6, 2]), ({'state': 'green', 'elapsed': 17, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [16, 11]), ({'state': 'green', 'elapsed': 8, 'min_green': 16, 'preempt_min_green': 10, 'yellow': 4, 'red': 3, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [9, 2]), ({'state': 'green', 'elapsed': 8, 'min_green': 13, 'preempt_min_green': 2, 'yellow': 5, 'red': 1, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [20, 14]), ({'state': 'green', 'elapsed': 2, 'min_green': 13, 'preempt_min_green': 10, 'yellow': 4, 'red': 2, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [14, 8])], [({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 14, 'min_green': 13, 'preempt_min_green': 3, 'yellow': 3, 'red': 2, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [5, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 13, 'preempt_min_green': 8, 'yellow': 3, 'red': 3, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [24, 18]), ({'state': 'red', 'elapsed': 5, 'min_green': 13, 'preempt_min_green': 10, 'yellow': 4, 'red': 1, 'fdw': 17, 'ped': 'none', 'ped_elapsed': 15, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 2, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 6, 'red': 3, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 20, 'ped_truncate': True, 'track_current': False}, [14, 5]), ({'state': 'green', 'elapsed': 14, 'min_green': 18, 'preempt_min_green': 7, 'yellow': 5, 'red': 2, 'fdw': 12, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [19, 12]), ({'state': 'green', 'elapsed': 3, 'min_green': 16, 'preempt_min_green': 5, 'yellow': 3, 'red': 1, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [6, 2])], [({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 19, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [27, 21]), ({'state': 'red', 'elapsed': 19, 'min_green': 10, 'preempt_min_green': 6, 'yellow': 4, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 14, 'min_green': 8, 'preempt_min_green': 2, 'yellow': 6, 'red': 3, 'fdw': 12, 'ped': 'walk', 'ped_elapsed': 4, 'ped_truncate': True, 'track_current': False}, [9, 0]), ({'state': 'green', 'elapsed': 19, 'min_green': 15, 'preempt_min_green': 8, 'yellow': 6, 'red': 1, 'fdw': 16, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [23, 16]), ({'state': 'green', 'elapsed': 11, 'min_green': 16, 'preempt_min_green': 6, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 3, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 9, 'min_green': 8, 'preempt_min_green': 10, 'yellow': 4, 'red': 1, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [6, 1])], [({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 19, 'min_green': 10, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 13, 'preempt_min_green': 9, 'yellow': 4, 'red': 2, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 14, 'ped_truncate': False, 'track_current': False}, [9, 3]), ({'state': 'green', 'elapsed': 13, 'min_green': 18, 'preempt_min_green': 2, 'yellow': 4, 'red': 3, 'fdw': 23, 'ped': 'walk', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 14, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': True, 'track_current': False}, [11, 3]), ({'state': 'green', 'elapsed': 12, 'min_green': 16, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 19, 'ped': 'walk', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [26, 19]), ({'state': 'green', 'elapsed': 6, 'min_green': 16, 'preempt_min_green': 10, 'yellow': 6, 'red': 1, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [25, 18])], [({'state': 'green', 'elapsed': 4, 'min_green': 20, 'preempt_min_green': 8, 'yellow': 5, 'red': 1, 'fdw': 9, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [15, 9]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 19, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 1, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'yellow', 'elapsed': 12, 'min_green': 9, 'preempt_min_green': 7, 'yellow': 6, 'red': 3, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 10, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 0, 'min_green': 18, 'preempt_min_green': 2, 'yellow': 5, 'red': 1, 'fdw': 10, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [16, 10]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 19, 'min_green': 15, 'preempt_min_green': 9, 'yellow': 3, 'red': 2, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 3, 'ped_truncate': True, 'track_current': False}, [5, 0])]]
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):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'red', 'elapsed': 20, 'min_green': 20, 'preempt_min_green': 4, 'yellow': 5, 'red': 3, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 2, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 7, 'min_green': 15, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 11, 'ped': 'walk', 'ped_elapsed': 10, 'ped_truncate': True, 'track_current': False}, [6, 2]), ({'state': 'green', 'elapsed': 17, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [16, 11]), ({'state': 'green', 'elapsed': 8, 'min_green': 16, 'preempt_min_green': 10, 'yellow': 4, 'red': 3, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [9, 2]), ({'state': 'green', 'elapsed': 8, 'min_green': 13, 'preempt_min_green': 2, 'yellow': 5, 'red': 1, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [20, 14]), ({'state': 'green', 'elapsed': 2, 'min_green': 13, 'preempt_min_green': 10, 'yellow': 4, 'red': 2, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [14, 8])], [({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 14, 'min_green': 13, 'preempt_min_green': 3, 'yellow': 3, 'red': 2, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [5, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 13, 'preempt_min_green': 8, 'yellow': 3, 'red': 3, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [24, 18]), ({'state': 'red', 'elapsed': 5, 'min_green': 13, 'preempt_min_green': 10, 'yellow': 4, 'red': 1, 'fdw': 17, 'ped': 'none', 'ped_elapsed': 15, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 2, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 6, 'red': 3, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 20, 'ped_truncate': True, 'track_current': False}, [14, 5]), ({'state': 'green', 'elapsed': 14, 'min_green': 18, 'preempt_min_green': 7, 'yellow': 5, 'red': 2, 'fdw': 12, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [19, 12]), ({'state': 'green', 'elapsed': 3, 'min_green': 16, 'preempt_min_green': 5, 'yellow': 3, 'red': 1, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [6, 2])], [({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 19, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [27, 21]), ({'state': 'red', 'elapsed': 19, 'min_green': 10, 'preempt_min_green': 6, 'yellow': 4, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 14, 'min_green': 8, 'preempt_min_green': 2, 'yellow': 6, 'red': 3, 'fdw': 12, 'ped': 'walk', 'ped_elapsed': 4, 'ped_truncate': True, 'track_current': False}, [9, 0]), ({'state': 'green', 'elapsed': 19, 'min_green': 15, 'preempt_min_green': 8, 'yellow': 6, 'red': 1, 'fdw': 16, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [23, 16]), ({'state': 'green', 'elapsed': 11, 'min_green': 16, 'preempt_min_green': 6, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 3, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 9, 'min_green': 8, 'preempt_min_green': 10, 'yellow': 4, 'red': 1, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [6, 1])], [({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 19, 'min_green': 10, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 13, 'preempt_min_green': 9, 'yellow': 4, 'red': 2, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 14, 'ped_truncate': False, 'track_current': False}, [9, 3]), ({'state': 'green', 'elapsed': 13, 'min_green': 18, 'preempt_min_green': 2, 'yellow': 4, 'red': 3, 'fdw': 23, 'ped': 'walk', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 14, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': True, 'track_current': False}, [11, 3]), ({'state': 'green', 'elapsed': 12, 'min_green': 16, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 19, 'ped': 'walk', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [26, 19]), ({'state': 'green', 'elapsed': 6, 'min_green': 16, 'preempt_min_green': 10, 'yellow': 6, 'red': 1, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [25, 18])], [({'state': 'green', 'elapsed': 4, 'min_green': 20, 'preempt_min_green': 8, 'yellow': 5, 'red': 1, 'fdw': 9, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [15, 9]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 19, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 1, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'yellow', 'elapsed': 12, 'min_green': 9, 'preempt_min_green': 7, 'yellow': 6, 'red': 3, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 10, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 0, 'min_green': 18, 'preempt_min_green': 2, 'yellow': 5, 'red': 1, 'fdw': 10, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [16, 10]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 19, 'min_green': 15, 'preempt_min_green': 9, 'yellow': 3, 'red': 2, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 3, 'ped_truncate': True, 'track_current': False}, [5, 0])]]
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:
Railroad preemption entry timing returns a wrong result when fDW is timed even when pedestrian truncation is enabled.

Input {state: green|yellow|red (red = all-red clearance), elapsed, min_green, preempt_min_green, yellow, red, fdw, ped: none|walk|fdw, ped_elapsed, ped_truncate, track_current}. If the track clearance phase is already green the answer is [0, 0]. In all-red the remaining red is timed; in yellow the remaining yellow and full red are timed. In green the hold is the larger of the remaining preempt minimum green (not the normal minimum) and the pedestrian time: walk is abandoned and FDW is timed in full, or skipped when ped_truncate; an active FDW completes its remainder unless truncated. Return [seconds until track clearance green, green hold].

split: open-access


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

N = 1
observations = []
def solve(x):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else f
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'green', 'elapsed': 4, 'min_green': 10, 'preempt_min_green': 5, 'yellow': 3, 'red': 1, 'fdw': 14, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [5, 1]), ({'state': 'green', 'elapsed': 1, 'min_green': 11, 'preempt_min_green': 4, 'yellow': 4, 'red': 3, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': False, 'track_current': False}, [10, 3]), ({'state': 'yellow', 'elapsed': 4, 'min_green': 15, 'preempt_min_green': 10, 'yellow': 3, 'red': 1, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': True, 'track_current': True}, [1, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 3, 'red': 2, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [24, 19]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 9, 'min_green': 18, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 19, 'ped': 'fdw', 'ped_elapsed': 19, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 9, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 13, 'ped': 'fdw', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [15, 8]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8])], [({'state': 'green', 'elapsed': 20, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 5, 'red': 1, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 6, 'red': 3, 'fdw': 22, 'ped': 'fdw', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [28, 19]), ({'state': 'green', 'elapsed': 1, 'min_green': 11, 'preempt_min_green': 2, 'yellow': 3, 'red': 1, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [5, 1]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 4, 'min_green': 11, 'preempt_min_green': 4, 'yellow': 4, 'red': 3, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 7, 'ped_truncate': False, 'track_current': False}, [12, 5]), ({'state': 'green', 'elapsed': 12, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 18, 'ped': 'fdw', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 19, 'preempt_min_green': 10, 'yellow': 6, 'red': 3, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': False}, [30, 21]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'yellow', 'elapsed': 7, 'min_green': 16, 'preempt_min_green': 7, 'yellow': 6, 'red': 2, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [2, 0]), ({'state': 'red', 'elapsed': 6, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 5, 'red': 1, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 5, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 11, 'min_green': 20, 'preempt_min_green': 6, 'yellow': 4, 'red': 3, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 19, 'preempt_min_green': 2, 'yellow': 5, 'red': 1, 'fdw': 22, 'ped': 'fdw', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [20, 14]), ({'state': 'red', 'elapsed': 6, 'min_green': 16, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 9, 'min_green': 16, 'preempt_min_green': 5, 'yellow': 3, 'red': 3, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [26, 20])], [({'state': 'green', 'elapsed': 9, 'min_green': 20, 'preempt_min_green': 2, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [19, 11]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 7, 'min_green': 12, 'preempt_min_green': 8, 'yellow': 5, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [7, 1]), ({'state': 'green', 'elapsed': 13, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 3, 'red': 3, 'fdw': 8, 'ped': 'fdw', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [9, 3]), ({'state': 'green', 'elapsed': 11, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 3, 'red': 2, 'fdw': 22, 'ped': 'walk', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [27, 22]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 5, 'min_green': 9, 'preempt_min_green': 6, 'yellow': 3, 'red': 3, 'fdw': 25, 'ped': 'fdw', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [31, 25]), ({'state': 'yellow', 'elapsed': 18, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 6, 'red': 2, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': False, 'track_current': True}, [2, 0])], [({'state': 'green', 'elapsed': 3, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 4, 'red': 1, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [9, 4]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 0, 'min_green': 12, 'preempt_min_green': 7, 'yellow': 4, 'red': 3, 'fdw': 23, 'ped': 'fdw', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [14, 7]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 17, 'min_green': 16, 'preempt_min_green': 5, 'yellow': 5, 'red': 1, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 15, 'ped': 'fdw', 'ped_elapsed': 2, 'ped_truncate': False, 'track_current': False}, [18, 13]), ({'state': 'yellow', 'elapsed': 6, 'min_green': 13, 'preempt_min_green': 4, 'yellow': 6, 'red': 3, 'fdw': 14, 'ped': 'none', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 10, 'min_green': 10, 'preempt_min_green': 6, 'yellow': 6, 'red': 2, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [0, 0])]]
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):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - el)
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'green', 'elapsed': 4, 'min_green': 10, 'preempt_min_green': 5, 'yellow': 3, 'red': 1, 'fdw': 14, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [5, 1]), ({'state': 'green', 'elapsed': 1, 'min_green': 11, 'preempt_min_green': 4, 'yellow': 4, 'red': 3, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': False, 'track_current': False}, [10, 3]), ({'state': 'yellow', 'elapsed': 4, 'min_green': 15, 'preempt_min_green': 10, 'yellow': 3, 'red': 1, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': True, 'track_current': True}, [1, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 3, 'red': 2, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [24, 19]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 9, 'min_green': 18, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 19, 'ped': 'fdw', 'ped_elapsed': 19, 'ped_truncate': True, 'track_current': False}, [8, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 9, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 13, 'ped': 'fdw', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [15, 8]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8])], [({'state': 'green', 'elapsed': 20, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 5, 'red': 1, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 6, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 6, 'red': 3, 'fdw': 22, 'ped': 'fdw', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [28, 19]), ({'state': 'green', 'elapsed': 1, 'min_green': 11, 'preempt_min_green': 2, 'yellow': 3, 'red': 1, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [5, 1]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 4, 'min_green': 11, 'preempt_min_green': 4, 'yellow': 4, 'red': 3, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 7, 'ped_truncate': False, 'track_current': False}, [12, 5]), ({'state': 'green', 'elapsed': 12, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 18, 'ped': 'fdw', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 19, 'preempt_min_green': 10, 'yellow': 6, 'red': 3, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': False}, [30, 21]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'yellow', 'elapsed': 7, 'min_green': 16, 'preempt_min_green': 7, 'yellow': 6, 'red': 2, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [2, 0]), ({'state': 'red', 'elapsed': 6, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 5, 'red': 1, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 5, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 11, 'min_green': 20, 'preempt_min_green': 6, 'yellow': 4, 'red': 3, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': True, 'track_current': False}, [7, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 19, 'preempt_min_green': 2, 'yellow': 5, 'red': 1, 'fdw': 22, 'ped': 'fdw', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [20, 14]), ({'state': 'red', 'elapsed': 6, 'min_green': 16, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 9, 'min_green': 16, 'preempt_min_green': 5, 'yellow': 3, 'red': 3, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [26, 20])], [({'state': 'green', 'elapsed': 9, 'min_green': 20, 'preempt_min_green': 2, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [19, 11]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 7, 'min_green': 12, 'preempt_min_green': 8, 'yellow': 5, 'red': 1, 'fdw': 25, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [7, 1]), ({'state': 'green', 'elapsed': 13, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 3, 'red': 3, 'fdw': 8, 'ped': 'fdw', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [9, 3]), ({'state': 'green', 'elapsed': 11, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 3, 'red': 2, 'fdw': 22, 'ped': 'walk', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [27, 22]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 5, 'min_green': 9, 'preempt_min_green': 6, 'yellow': 3, 'red': 3, 'fdw': 25, 'ped': 'fdw', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [31, 25]), ({'state': 'yellow', 'elapsed': 18, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 6, 'red': 2, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': False, 'track_current': True}, [2, 0])], [({'state': 'green', 'elapsed': 3, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 4, 'red': 1, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [9, 4]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 0, 'min_green': 12, 'preempt_min_green': 7, 'yellow': 4, 'red': 3, 'fdw': 23, 'ped': 'fdw', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [14, 7]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 17, 'min_green': 16, 'preempt_min_green': 5, 'yellow': 5, 'red': 1, 'fdw': 21, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 15, 'ped': 'fdw', 'ped_elapsed': 2, 'ped_truncate': False, 'track_current': False}, [18, 13]), ({'state': 'yellow', 'elapsed': 6, 'min_green': 13, 'preempt_min_green': 4, 'yellow': 6, 'red': 3, 'fdw': 14, 'ped': 'none', 'ped_elapsed': 15, 'ped_truncate': True, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 10, 'min_green': 10, 'preempt_min_green': 6, 'yellow': 6, 'red': 2, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [0, 0])]]
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:
Railroad preemption entry timing returns a wrong result when the FDW remainder is measured from vehicle green.

Input {state: green|yellow|red (red = all-red clearance), elapsed, min_green, preempt_min_green, yellow, red, fdw, ped: none|walk|fdw, ped_elapsed, ped_truncate, track_current}. If the track clearance phase is already green the answer is [0, 0]. In all-red the remaining red is timed; in yellow the remaining yellow and full red are timed. In green the hold is the larger of the remaining preempt minimum green (not the normal minimum) and the pedestrian time: walk is abandoned and FDW is timed in full, or skipped when ped_truncate; an active FDW completes its remainder unless truncated. Return [seconds until track clearance green, green hold].

split: open-access


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

N = 1
observations = []
def solve(x):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = ped + max(0, x['preempt_min_green'] - el)
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 20, 'preempt_min_green': 9, 'yellow': 5, 'red': 2, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [12, 5]), ({'state': 'green', 'elapsed': 4, 'min_green': 19, 'preempt_min_green': 5, 'yellow': 3, 'red': 2, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 17, 'ped_truncate': False, 'track_current': False}, [12, 7]), ({'state': 'yellow', 'elapsed': 19, 'min_green': 11, 'preempt_min_green': 3, 'yellow': 5, 'red': 3, 'fdw': 20, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 2, 'min_green': 17, 'preempt_min_green': 7, 'yellow': 3, 'red': 1, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [9, 5]), ({'state': 'green', 'elapsed': 2, 'min_green': 9, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [22, 14]), ({'state': 'green', 'elapsed': 11, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 5, 'red': 2, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [22, 15])], [({'state': 'yellow', 'elapsed': 17, 'min_green': 10, 'preempt_min_green': 7, 'yellow': 3, 'red': 3, 'fdw': 20, 'ped': 'none', 'ped_elapsed': 2, 'ped_truncate': False, 'track_current': True}, [3, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 0, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 20, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [17, 9]), ({'state': 'green', 'elapsed': 6, 'min_green': 17, 'preempt_min_green': 7, 'yellow': 5, 'red': 2, 'fdw': 20, 'ped': 'fdw', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [24, 17]), ({'state': 'green', 'elapsed': 4, 'min_green': 16, 'preempt_min_green': 8, 'yellow': 5, 'red': 1, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 7, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 4, 'red': 2, 'fdw': 23, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [29, 23]), ({'state': 'green', 'elapsed': 7, 'min_green': 14, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 14, 'ped': 'none', 'ped_elapsed': 1, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'yellow', 'elapsed': 5, 'min_green': 14, 'preempt_min_green': 3, 'yellow': 6, 'red': 3, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': True, 'track_current': False}, [4, 0]), ({'state': 'green', 'elapsed': 0, 'min_green': 12, 'preempt_min_green': 5, 'yellow': 4, 'red': 1, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [10, 5]), ({'state': 'green', 'elapsed': 5, 'min_green': 12, 'preempt_min_green': 5, 'yellow': 5, 'red': 1, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 5, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 6, 'red': 3, 'fdw': 19, 'ped': 'fdw', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [19, 10]), ({'state': 'red', 'elapsed': 14, 'min_green': 17, 'preempt_min_green': 9, 'yellow': 5, 'red': 2, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 16, 'preempt_min_green': 4, 'yellow': 6, 'red': 2, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [11, 3]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8])], [({'state': 'green', 'elapsed': 0, 'min_green': 8, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [13, 9]), ({'state': 'red', 'elapsed': 14, 'min_green': 8, 'preempt_min_green': 10, 'yellow': 5, 'red': 1, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 20, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 3, 'red': 2, 'fdw': 17, 'ped': 'none', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': True}, [2, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 8, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 22, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [27, 22]), ({'state': 'yellow', 'elapsed': 10, 'min_green': 11, 'preempt_min_green': 9, 'yellow': 5, 'red': 1, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': False, 'track_current': False}, [1, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 17, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [16, 11]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'green', 'elapsed': 14, 'min_green': 8, 'preempt_min_green': 3, 'yellow': 4, 'red': 2, 'fdw': 8, 'ped': 'fdw', 'ped_elapsed': 16, 'ped_truncate': False, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 3, 'min_green': 17, 'preempt_min_green': 10, 'yellow': 5, 'red': 2, 'fdw': 25, 'ped': 'fdw', 'ped_elapsed': 14, 'ped_truncate': False, 'track_current': False}, [18, 11]), ({'state': 'green', 'elapsed': 1, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 3, 'red': 2, 'fdw': 23, 'ped': 'walk', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 14, 'min_green': 13, 'preempt_min_green': 5, 'yellow': 6, 'red': 3, 'fdw': 16, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': False, 'track_current': False}, [9, 0]), ({'state': 'green', 'elapsed': 5, 'min_green': 19, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 19, 'ped': 'fdw', 'ped_elapsed': 16, 'ped_truncate': False, 'track_current': False}, [8, 4]), ({'state': 'green', 'elapsed': 8, 'min_green': 19, 'preempt_min_green': 9, 'yellow': 4, 'red': 2, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [19, 13])]]
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):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el), 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = ped or max(0, x['preempt_min_green'] - el)
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 20, 'preempt_min_green': 9, 'yellow': 5, 'red': 2, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 12, 'ped_truncate': False, 'track_current': False}, [12, 5]), ({'state': 'green', 'elapsed': 4, 'min_green': 19, 'preempt_min_green': 5, 'yellow': 3, 'red': 2, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 17, 'ped_truncate': False, 'track_current': False}, [12, 7]), ({'state': 'yellow', 'elapsed': 19, 'min_green': 11, 'preempt_min_green': 3, 'yellow': 5, 'red': 3, 'fdw': 20, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 2, 'min_green': 17, 'preempt_min_green': 7, 'yellow': 3, 'red': 1, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [9, 5]), ({'state': 'green', 'elapsed': 2, 'min_green': 9, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 14, 'ped': 'walk', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': False}, [22, 14]), ({'state': 'green', 'elapsed': 11, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 5, 'red': 2, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [22, 15])], [({'state': 'yellow', 'elapsed': 17, 'min_green': 10, 'preempt_min_green': 7, 'yellow': 3, 'red': 3, 'fdw': 20, 'ped': 'none', 'ped_elapsed': 2, 'ped_truncate': False, 'track_current': True}, [3, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 0, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 5, 'red': 3, 'fdw': 20, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [17, 9]), ({'state': 'green', 'elapsed': 6, 'min_green': 17, 'preempt_min_green': 7, 'yellow': 5, 'red': 2, 'fdw': 20, 'ped': 'fdw', 'ped_elapsed': 3, 'ped_truncate': False, 'track_current': False}, [24, 17]), ({'state': 'green', 'elapsed': 4, 'min_green': 16, 'preempt_min_green': 8, 'yellow': 5, 'red': 1, 'fdw': 8, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 7, 'min_green': 19, 'preempt_min_green': 7, 'yellow': 4, 'red': 2, 'fdw': 23, 'ped': 'walk', 'ped_elapsed': 11, 'ped_truncate': False, 'track_current': False}, [29, 23]), ({'state': 'green', 'elapsed': 7, 'min_green': 14, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 14, 'ped': 'none', 'ped_elapsed': 1, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'yellow', 'elapsed': 5, 'min_green': 14, 'preempt_min_green': 3, 'yellow': 6, 'red': 3, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': True, 'track_current': False}, [4, 0]), ({'state': 'green', 'elapsed': 0, 'min_green': 12, 'preempt_min_green': 5, 'yellow': 4, 'red': 1, 'fdw': 14, 'ped': 'fdw', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': False}, [10, 5]), ({'state': 'green', 'elapsed': 5, 'min_green': 12, 'preempt_min_green': 5, 'yellow': 5, 'red': 1, 'fdw': 25, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 5, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 6, 'red': 3, 'fdw': 19, 'ped': 'fdw', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [19, 10]), ({'state': 'red', 'elapsed': 14, 'min_green': 17, 'preempt_min_green': 9, 'yellow': 5, 'red': 2, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 16, 'preempt_min_green': 4, 'yellow': 6, 'red': 2, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [11, 3]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8])], [({'state': 'green', 'elapsed': 0, 'min_green': 8, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 24, 'ped': 'fdw', 'ped_elapsed': 20, 'ped_truncate': False, 'track_current': False}, [13, 9]), ({'state': 'red', 'elapsed': 14, 'min_green': 8, 'preempt_min_green': 10, 'yellow': 5, 'red': 1, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'yellow', 'elapsed': 20, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 3, 'red': 2, 'fdw': 17, 'ped': 'none', 'ped_elapsed': 5, 'ped_truncate': False, 'track_current': True}, [2, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 8, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 22, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [27, 22]), ({'state': 'yellow', 'elapsed': 10, 'min_green': 11, 'preempt_min_green': 9, 'yellow': 5, 'red': 1, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': False, 'track_current': False}, [1, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 17, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'walk', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [16, 11]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'green', 'elapsed': 14, 'min_green': 8, 'preempt_min_green': 3, 'yellow': 4, 'red': 2, 'fdw': 8, 'ped': 'fdw', 'ped_elapsed': 16, 'ped_truncate': False, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 3, 'min_green': 17, 'preempt_min_green': 10, 'yellow': 5, 'red': 2, 'fdw': 25, 'ped': 'fdw', 'ped_elapsed': 14, 'ped_truncate': False, 'track_current': False}, [18, 11]), ({'state': 'green', 'elapsed': 1, 'min_green': 10, 'preempt_min_green': 9, 'yellow': 3, 'red': 2, 'fdw': 23, 'ped': 'walk', 'ped_elapsed': 13, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 14, 'min_green': 13, 'preempt_min_green': 5, 'yellow': 6, 'red': 3, 'fdw': 16, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': False, 'track_current': False}, [9, 0]), ({'state': 'green', 'elapsed': 5, 'min_green': 19, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 19, 'ped': 'fdw', 'ped_elapsed': 16, 'ped_truncate': False, 'track_current': False}, [8, 4]), ({'state': 'green', 'elapsed': 8, 'min_green': 19, 'preempt_min_green': 9, 'yellow': 4, 'red': 2, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [19, 13])]]
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:
Railroad preemption entry timing returns a wrong result when pedestrian time and minimum green are added.

Input {state: green|yellow|red (red = all-red clearance), elapsed, min_green, preempt_min_green, yellow, red, fdw, ped: none|walk|fdw, ped_elapsed, ped_truncate, track_current}. If the track clearance phase is already green the answer is [0, 0]. In all-red the remaining red is timed; in yellow the remaining yellow and full red are timed. In green the hold is the larger of the remaining preempt minimum green (not the normal minimum) and the pedestrian time: walk is abandoned and FDW is timed in full, or skipped when ped_truncate; an active FDW completes its remainder unless truncated. Return [seconds until track clearance green, green hold].

split: open-access


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

N = 1
observations = []
def solve(x):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [r, 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'green', 'elapsed': 11, 'min_green': 14, 'preempt_min_green': 3, 'yellow': 5, 'red': 3, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [32, 24]), ({'state': 'red', 'elapsed': 11, 'min_green': 16, 'preempt_min_green': 4, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 13, 'min_green': 16, 'preempt_min_green': 9, 'yellow': 5, 'red': 1, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 20, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 12, 'min_green': 18, 'preempt_min_green': 4, 'yellow': 3, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 18, 'min_green': 20, 'preempt_min_green': 4, 'yellow': 6, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': False, 'track_current': False}, [9, 0]), ({'state': 'green', 'elapsed': 2, 'min_green': 18, 'preempt_min_green': 7, 'yellow': 3, 'red': 1, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [17, 13]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'green', 'elapsed': 8, 'min_green': 11, 'preempt_min_green': 5, 'yellow': 6, 'red': 2, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'red', 'elapsed': 13, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 5, 'red': 2, 'fdw': 20, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 18, 'min_green': 16, 'preempt_min_green': 8, 'yellow': 3, 'red': 1, 'fdw': 22, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [4, 0]), ({'state': 'yellow', 'elapsed': 14, 'min_green': 15, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'red', 'elapsed': 12, 'min_green': 14, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 22, 'ped': 'none', 'ped_elapsed': 2, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 9, 'min_green': 20, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [0, 0])], [({'state': 'green', 'elapsed': 1, 'min_green': 14, 'preempt_min_green': 9, 'yellow': 4, 'red': 1, 'fdw': 17, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 16, 'min_green': 18, 'preempt_min_green': 3, 'yellow': 3, 'red': 3, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 6, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 11, 'min_green': 10, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 13, 'preempt_min_green': 9, 'yellow': 3, 'red': 2, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 20, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 9, 'preempt_min_green': 6, 'yellow': 3, 'red': 2, 'fdw': 12, 'ped': 'walk', 'ped_elapsed': 1, 'ped_truncate': False, 'track_current': False}, [17, 12]), ({'state': 'red', 'elapsed': 16, 'min_green': 16, 'preempt_min_green': 6, 'yellow': 5, 'red': 2, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': True, 'track_current': False}, [0, 0])], [({'state': 'green', 'elapsed': 16, 'min_green': 14, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 18, 'ped': 'fdw', 'ped_elapsed': 18, 'ped_truncate': False, 'track_current': False}, [7, 0]), ({'state': 'red', 'elapsed': 2, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 5, 'red': 2, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 6, 'min_green': 17, 'preempt_min_green': 6, 'yellow': 3, 'red': 1, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 4, 'min_green': 8, 'preempt_min_green': 8, 'yellow': 6, 'red': 2, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 16, 'ped_truncate': False, 'track_current': False}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 14, 'min_green': 9, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 10, 'min_green': 13, 'preempt_min_green': 10, 'yellow': 5, 'red': 1, 'fdw': 23, 'ped': 'fdw', 'ped_elapsed': 14, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'red', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 7, 'yellow': 4, 'red': 3, 'fdw': 16, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [1, 0]), ({'state': 'red', 'elapsed': 18, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 6, 'red': 1, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 1, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 3, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [12, 5]), ({'state': 'red', 'elapsed': 12, 'min_green': 17, 'preempt_min_green': 6, 'yellow': 6, 'red': 3, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 9, 'min_green': 16, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 10, 'preempt_min_green': 3, 'yellow': 5, 'red': 1, 'fdw': 13, 'ped': 'fdw', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': False}, [6, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])]]
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):
    st, el = x['state'], x['elapsed']
    y, r, f = x['yellow'], x['red'], x['fdw']
    if st == 'green' and x['track_current']:
        return [0, 0]
    if st == 'red':
        return [max(0, r - el) + y, 0]
    if st == 'yellow':
        return [max(0, y - el) + r, 0]
    ped = 0
    if x['ped'] == 'walk':
        ped = 0 if x['ped_truncate'] else f
    elif x['ped'] == 'fdw':
        ped = 0 if x['ped_truncate'] else max(0, f - x['ped_elapsed'])
    hold = max(ped, max(0, x['preempt_min_green'] - el))
    return [hold + y + r, hold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'state': 'green', 'elapsed': 11, 'min_green': 14, 'preempt_min_green': 3, 'yellow': 5, 'red': 3, 'fdw': 24, 'ped': 'walk', 'ped_elapsed': 6, 'ped_truncate': False, 'track_current': False}, [32, 24]), ({'state': 'red', 'elapsed': 11, 'min_green': 16, 'preempt_min_green': 4, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 18, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 13, 'min_green': 16, 'preempt_min_green': 9, 'yellow': 5, 'red': 1, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 20, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 12, 'min_green': 18, 'preempt_min_green': 4, 'yellow': 3, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 16, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 18, 'min_green': 20, 'preempt_min_green': 4, 'yellow': 6, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 7, 'ped_truncate': False, 'track_current': False}, [9, 0]), ({'state': 'green', 'elapsed': 2, 'min_green': 18, 'preempt_min_green': 7, 'yellow': 3, 'red': 1, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': False}, [17, 13]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'green', 'elapsed': 8, 'min_green': 11, 'preempt_min_green': 5, 'yellow': 6, 'red': 2, 'fdw': 18, 'ped': 'walk', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': True}, [0, 0]), ({'state': 'red', 'elapsed': 13, 'min_green': 15, 'preempt_min_green': 3, 'yellow': 5, 'red': 2, 'fdw': 20, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 18, 'min_green': 16, 'preempt_min_green': 8, 'yellow': 3, 'red': 1, 'fdw': 22, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [4, 0]), ({'state': 'yellow', 'elapsed': 14, 'min_green': 15, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 24, 'ped': 'none', 'ped_elapsed': 8, 'ped_truncate': False, 'track_current': False}, [3, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'red', 'elapsed': 12, 'min_green': 14, 'preempt_min_green': 9, 'yellow': 3, 'red': 1, 'fdw': 22, 'ped': 'none', 'ped_elapsed': 2, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 9, 'min_green': 20, 'preempt_min_green': 9, 'yellow': 4, 'red': 3, 'fdw': 21, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [0, 0])], [({'state': 'green', 'elapsed': 1, 'min_green': 14, 'preempt_min_green': 9, 'yellow': 4, 'red': 1, 'fdw': 17, 'ped': 'walk', 'ped_elapsed': 0, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 16, 'min_green': 18, 'preempt_min_green': 3, 'yellow': 3, 'red': 3, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 6, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 11, 'min_green': 10, 'preempt_min_green': 8, 'yellow': 4, 'red': 1, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 4, 'min_green': 13, 'preempt_min_green': 9, 'yellow': 3, 'red': 2, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 20, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0]), ({'state': 'green', 'elapsed': 12, 'min_green': 9, 'preempt_min_green': 6, 'yellow': 3, 'red': 2, 'fdw': 12, 'ped': 'walk', 'ped_elapsed': 1, 'ped_truncate': False, 'track_current': False}, [17, 12]), ({'state': 'red', 'elapsed': 16, 'min_green': 16, 'preempt_min_green': 6, 'yellow': 5, 'red': 2, 'fdw': 15, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': True, 'track_current': False}, [0, 0])], [({'state': 'green', 'elapsed': 16, 'min_green': 14, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 18, 'ped': 'fdw', 'ped_elapsed': 18, 'ped_truncate': False, 'track_current': False}, [7, 0]), ({'state': 'red', 'elapsed': 2, 'min_green': 18, 'preempt_min_green': 9, 'yellow': 5, 'red': 2, 'fdw': 11, 'ped': 'none', 'ped_elapsed': 13, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'red', 'elapsed': 6, 'min_green': 17, 'preempt_min_green': 6, 'yellow': 3, 'red': 1, 'fdw': 8, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 4, 'min_green': 8, 'preempt_min_green': 8, 'yellow': 6, 'red': 2, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 16, 'ped_truncate': False, 'track_current': False}, [4, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'red', 'elapsed': 14, 'min_green': 9, 'preempt_min_green': 3, 'yellow': 6, 'red': 2, 'fdw': 13, 'ped': 'none', 'ped_elapsed': 10, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 10, 'min_green': 13, 'preempt_min_green': 10, 'yellow': 5, 'red': 1, 'fdw': 23, 'ped': 'fdw', 'ped_elapsed': 14, 'ped_truncate': True, 'track_current': True}, [0, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])], [({'state': 'red', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 7, 'yellow': 4, 'red': 3, 'fdw': 16, 'ped': 'none', 'ped_elapsed': 9, 'ped_truncate': False, 'track_current': False}, [1, 0]), ({'state': 'red', 'elapsed': 18, 'min_green': 8, 'preempt_min_green': 4, 'yellow': 6, 'red': 1, 'fdw': 23, 'ped': 'none', 'ped_elapsed': 1, 'ped_truncate': True, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 1, 'min_green': 15, 'preempt_min_green': 5, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'fdw', 'ped_elapsed': 4, 'ped_truncate': False, 'track_current': False}, [14, 8]), ({'state': 'green', 'elapsed': 3, 'min_green': 18, 'preempt_min_green': 8, 'yellow': 4, 'red': 3, 'fdw': 13, 'ped': 'walk', 'ped_elapsed': 9, 'ped_truncate': True, 'track_current': False}, [12, 5]), ({'state': 'red', 'elapsed': 12, 'min_green': 17, 'preempt_min_green': 6, 'yellow': 6, 'red': 3, 'fdw': 10, 'ped': 'none', 'ped_elapsed': 17, 'ped_truncate': False, 'track_current': False}, [0, 0]), ({'state': 'green', 'elapsed': 9, 'min_green': 16, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 18, 'ped': 'none', 'ped_elapsed': 12, 'ped_truncate': True, 'track_current': False}, [6, 0]), ({'state': 'green', 'elapsed': 15, 'min_green': 10, 'preempt_min_green': 3, 'yellow': 5, 'red': 1, 'fdw': 13, 'ped': 'fdw', 'ped_elapsed': 19, 'ped_truncate': False, 'track_current': False}, [6, 0]), ({'state': 'yellow', 'elapsed': 2, 'min_green': 10, 'preempt_min_green': 4, 'yellow': 4, 'red': 2, 'fdw': 12, 'ped': 'none', 'ped_elapsed': 0, 'ped_truncate': False, 'track_current': True}, [4, 0])]]
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:
Railroad preemption entry timing returns a wrong result when an all-red in progress is timed again in full.

Input {state: green|yellow|red (red = all-red clearance), elapsed, min_green, preempt_min_green, yellow, red, fdw, ped: none|walk|fdw, ped_elapsed, ped_truncate, track_current}. If the track clearance phase is already green the answer is [0, 0]. In all-red the remaining red is timed; in yellow the remaining yellow and full red are timed. In green the hold is the larger of the remaining preempt minimum green (not the normal minimum) and the pedestrian time: walk is abandoned and FDW is timed in full, or skipped when ped_truncate; an active FDW completes its remainder unless truncated. Return [seconds until track clearance green, green hold].

split: open-access