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

N = 1
observations = []
def solve(x):
    m = x['min_green']
    initial = min(x['max_initial'], max(m, x['red_actuations'] * x['added_per_act_tenths'] // 10))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - max(x['call'], 0)
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = g0 - (g0 - gm) * done // x['time_to_reduce']
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 18, 'red_actuations': 20, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 2, 'time_to_reduce': 14, 'call': 3, 't': 42}, {'initial': 18, 'gap_tenths': 20}), ({'min_green': 4, 'added_per_act_tenths': 25, 'max_initial': 22, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 7, 'time_to_reduce': 18, 'call': 2, 't': 53}, {'initial': 18, 'gap_tenths': 20}), ({'min_green': 9, 'added_per_act_tenths': 20, 'max_initial': 24, 'red_actuations': 4, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 24, 'call': 3, 't': 30}, {'initial': 9, 'gap_tenths': 18}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 11, 'red_actuations': 0, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 5, 'call': 13, 't': 52}, {'initial': 4, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 7, 'added_per_act_tenths': 10, 'max_initial': 11, 'red_actuations': 20, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 15, 'time_to_reduce': 12, 'call': -4, 't': 2}, {'initial': 11, 'gap_tenths': 35})], [({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 14, 'red_actuations': 20, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 24, 'call': 7, 't': 19}, {'initial': 14, 'gap_tenths': 35}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 28, 'red_actuations': 15, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 30, 'call': 12, 't': 47}, {'initial': 15, 'gap_tenths': 15}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 9, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 11, 'time_to_reduce': 6, 'call': -4, 't': 39}, {'initial': 14, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 20, 'red_actuations': 1, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 18, 'call': 12, 't': 3}, {'initial': 10, 'gap_tenths': 35}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 18, 'red_actuations': 5, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 16, 'call': 5, 't': 55}, {'initial': 13, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31})], [({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 21, 'red_actuations': 15, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 12, 'time_to_reduce': 15, 'call': 12, 't': 57}, {'initial': 21, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 18, 'red_actuations': 14, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 19, 'call': 11, 't': 17}, {'initial': 18, 'gap_tenths': 29}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 29, 'red_actuations': 7, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 15, 'call': -3, 't': 18}, {'initial': 18, 'gap_tenths': 14}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 15, 'red_actuations': 13, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 29, 'call': 9, 't': 16}, {'initial': 15, 'gap_tenths': 31}), ({'min_green': 8, 'added_per_act_tenths': 10, 'max_initial': 12, 'red_actuations': 17, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 10, 'time_to_reduce': 10, 'call': 14, 't': 25}, {'initial': 12, 'gap_tenths': 46}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 15, 'max_initial': 19, 'red_actuations': 5, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 7, 'call': 11, 't': 29}, {'initial': 9, 'gap_tenths': 20}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 27, 'red_actuations': 13, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 27, 'call': 7, 't': 51}, {'initial': 20, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 10, 'max_initial': 17, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 29, 'call': -1, 't': 9}, {'initial': 5, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 17, 'red_actuations': 7, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 4, 'time_to_reduce': 15, 'call': 13, 't': 57}, {'initial': 9, 'gap_tenths': 10}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 21, 'red_actuations': 17, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 0, 'time_to_reduce': 13, 'call': 0, 't': 20}, {'initial': 17, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 17, 'red_actuations': 6, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 15, 'time_to_reduce': 22, 'call': 9, 't': 1}, {'initial': 15, 'gap_tenths': 35}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 19, 'red_actuations': 20, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 6, 'time_to_reduce': 8, 'call': 10, 't': 49}, {'initial': 19, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 10, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 28, 'call': 0, 't': 1}, {'initial': 10, 'gap_tenths': 40}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 17, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 26, 'call': 2, 't': 51}, {'initial': 17, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 24, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 3, 'time_to_reduce': 18, 'call': 4, 't': 52}, {'initial': 23, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})]]
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):
    m = x['min_green']
    initial = min(x['max_initial'], max(m, x['red_actuations'] * -(-x['added_per_act_tenths'] // 10)))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - max(x['call'], 0)
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = g0 - (g0 - gm) * done // x['time_to_reduce']
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 18, 'red_actuations': 20, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 2, 'time_to_reduce': 14, 'call': 3, 't': 42}, {'initial': 18, 'gap_tenths': 20}), ({'min_green': 4, 'added_per_act_tenths': 25, 'max_initial': 22, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 7, 'time_to_reduce': 18, 'call': 2, 't': 53}, {'initial': 18, 'gap_tenths': 20}), ({'min_green': 9, 'added_per_act_tenths': 20, 'max_initial': 24, 'red_actuations': 4, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 24, 'call': 3, 't': 30}, {'initial': 9, 'gap_tenths': 18}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 11, 'red_actuations': 0, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 5, 'call': 13, 't': 52}, {'initial': 4, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 7, 'added_per_act_tenths': 10, 'max_initial': 11, 'red_actuations': 20, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 15, 'time_to_reduce': 12, 'call': -4, 't': 2}, {'initial': 11, 'gap_tenths': 35})], [({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 14, 'red_actuations': 20, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 24, 'call': 7, 't': 19}, {'initial': 14, 'gap_tenths': 35}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 28, 'red_actuations': 15, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 30, 'call': 12, 't': 47}, {'initial': 15, 'gap_tenths': 15}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 9, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 11, 'time_to_reduce': 6, 'call': -4, 't': 39}, {'initial': 14, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 20, 'red_actuations': 1, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 18, 'call': 12, 't': 3}, {'initial': 10, 'gap_tenths': 35}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 18, 'red_actuations': 5, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 16, 'call': 5, 't': 55}, {'initial': 13, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31})], [({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 21, 'red_actuations': 15, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 12, 'time_to_reduce': 15, 'call': 12, 't': 57}, {'initial': 21, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 18, 'red_actuations': 14, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 19, 'call': 11, 't': 17}, {'initial': 18, 'gap_tenths': 29}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 29, 'red_actuations': 7, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 15, 'call': -3, 't': 18}, {'initial': 18, 'gap_tenths': 14}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 15, 'red_actuations': 13, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 29, 'call': 9, 't': 16}, {'initial': 15, 'gap_tenths': 31}), ({'min_green': 8, 'added_per_act_tenths': 10, 'max_initial': 12, 'red_actuations': 17, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 10, 'time_to_reduce': 10, 'call': 14, 't': 25}, {'initial': 12, 'gap_tenths': 46}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 15, 'max_initial': 19, 'red_actuations': 5, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 7, 'call': 11, 't': 29}, {'initial': 9, 'gap_tenths': 20}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 27, 'red_actuations': 13, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 27, 'call': 7, 't': 51}, {'initial': 20, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 10, 'max_initial': 17, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 29, 'call': -1, 't': 9}, {'initial': 5, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 17, 'red_actuations': 7, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 4, 'time_to_reduce': 15, 'call': 13, 't': 57}, {'initial': 9, 'gap_tenths': 10}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 21, 'red_actuations': 17, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 0, 'time_to_reduce': 13, 'call': 0, 't': 20}, {'initial': 17, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 17, 'red_actuations': 6, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 15, 'time_to_reduce': 22, 'call': 9, 't': 1}, {'initial': 15, 'gap_tenths': 35}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 19, 'red_actuations': 20, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 6, 'time_to_reduce': 8, 'call': 10, 't': 49}, {'initial': 19, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 10, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 28, 'call': 0, 't': 1}, {'initial': 10, 'gap_tenths': 40}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 17, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 26, 'call': 2, 't': 51}, {'initial': 17, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 24, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 3, 'time_to_reduce': 18, 'call': 4, 't': 52}, {'initial': 23, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})]]
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:
Variable initial green is one second short whenever the accumulated added initial is fractional.

Input {min_green, added_per_act_tenths, max_initial, red_actuations, initial_gap_tenths, min_gap_tenths, time_before_reduction, time_to_reduce, call, t}. Variable initial = min(max_initial, max(min_green, ceil(actuations*added/10))) seconds. Gap reduction is timed from the conflicting call (a call before green start counts from 0): until time_before_reduction elapses the allowed gap is the initial gap; during time_to_reduce it falls linearly with the reduction amount truncated to whole tenths; afterwards it is the minimum gap. Return {initial, gap_tenths}.

split: open-access


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

N = 1
observations = []
def solve(x):
    m = x['min_green']
    initial = max(x['max_initial'], min(m, -(-x['red_actuations'] * x['added_per_act_tenths'] // 10)))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - max(x['call'], 0)
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = g0 - (g0 - gm) * done // x['time_to_reduce']
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 9, 'added_per_act_tenths': 15, 'max_initial': 19, 'red_actuations': 11, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 21, 'call': 13, 't': 11}, {'initial': 17, 'gap_tenths': 50}), ({'min_green': 7, 'added_per_act_tenths': 20, 'max_initial': 27, 'red_actuations': 2, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 17, 'call': 15, 't': 60}, {'initial': 7, 'gap_tenths': 15}), ({'min_green': 10, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 3, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 14, 'time_to_reduce': 28, 'call': 5, 't': 59}, {'initial': 10, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 9, 'added_per_act_tenths': 20, 'max_initial': 28, 'red_actuations': 18, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 1, 'time_to_reduce': 8, 'call': -2, 't': 11}, {'initial': 28, 'gap_tenths': 10}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 27, 'red_actuations': 18, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 6, 'call': 1, 't': 59}, {'initial': 27, 'gap_tenths': 20})], [({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 20, 'red_actuations': 20, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 13, 'time_to_reduce': 6, 'call': 3, 't': 13}, {'initial': 20, 'gap_tenths': 50}), ({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 2, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 9, 'time_to_reduce': 22, 'call': 9, 't': 29}, {'initial': 8, 'gap_tenths': 25}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 15, 'red_actuations': 14, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 12, 'call': -1, 't': 23}, {'initial': 15, 'gap_tenths': 27}), ({'min_green': 9, 'added_per_act_tenths': 15, 'max_initial': 24, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 11, 'time_to_reduce': 25, 'call': 10, 't': 6}, {'initial': 9, 'gap_tenths': 30}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 20, 'max_initial': 10, 'red_actuations': 6, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 1, 'time_to_reduce': 25, 'call': -1, 't': 52}, {'initial': 10, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 11, 'red_actuations': 18, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 17, 'call': 2, 't': 46}, {'initial': 11, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 27, 'red_actuations': 2, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 21, 'call': 10, 't': 4}, {'initial': 8, 'gap_tenths': 30}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 24, 'red_actuations': 2, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 11, 'time_to_reduce': 8, 'call': -2, 't': 26}, {'initial': 6, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 20, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 24, 'call': 14, 't': 35}, {'initial': 12, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 29, 'red_actuations': 3, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 12, 'time_to_reduce': 13, 'call': -2, 't': 48}, {'initial': 5, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 20, 'max_initial': 25, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 13, 'time_to_reduce': 29, 'call': -4, 't': 16}, {'initial': 25, 'gap_tenths': 33}), ({'min_green': 7, 'added_per_act_tenths': 10, 'max_initial': 11, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 12, 'time_to_reduce': 6, 'call': 1, 't': 28}, {'initial': 7, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 18, 'red_actuations': 12, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 24, 'call': -2, 't': 33}, {'initial': 18, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 21, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 29, 'call': 13, 't': 51}, {'initial': 6, 'gap_tenths': 15}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 20, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 27, 'call': 12, 't': 31}, {'initial': 20, 'gap_tenths': 20})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 25, 'max_initial': 15, 'red_actuations': 1, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 21, 'call': 9, 't': 44}, {'initial': 4, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 20, 'max_initial': 27, 'red_actuations': 1, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 5, 'call': -4, 't': 31}, {'initial': 5, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 18, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 14, 'time_to_reduce': 22, 'call': -2, 't': 11}, {'initial': 10, 'gap_tenths': 35}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 17, 'red_actuations': 20, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 1, 'time_to_reduce': 12, 'call': -3, 't': 60}, {'initial': 17, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 25, 'max_initial': 22, 'red_actuations': 19, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 23, 'call': 12, 't': 12}, {'initial': 22, 'gap_tenths': 40})]]
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):
    m = x['min_green']
    initial = min(x['max_initial'], max(0, -(-x['red_actuations'] * x['added_per_act_tenths'] // 10)))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - max(x['call'], 0)
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = g0 - (g0 - gm) * done // x['time_to_reduce']
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 9, 'added_per_act_tenths': 15, 'max_initial': 19, 'red_actuations': 11, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 21, 'call': 13, 't': 11}, {'initial': 17, 'gap_tenths': 50}), ({'min_green': 7, 'added_per_act_tenths': 20, 'max_initial': 27, 'red_actuations': 2, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 17, 'call': 15, 't': 60}, {'initial': 7, 'gap_tenths': 15}), ({'min_green': 10, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 3, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 14, 'time_to_reduce': 28, 'call': 5, 't': 59}, {'initial': 10, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 9, 'added_per_act_tenths': 20, 'max_initial': 28, 'red_actuations': 18, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 1, 'time_to_reduce': 8, 'call': -2, 't': 11}, {'initial': 28, 'gap_tenths': 10}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 27, 'red_actuations': 18, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 6, 'call': 1, 't': 59}, {'initial': 27, 'gap_tenths': 20})], [({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 20, 'red_actuations': 20, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 13, 'time_to_reduce': 6, 'call': 3, 't': 13}, {'initial': 20, 'gap_tenths': 50}), ({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 2, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 9, 'time_to_reduce': 22, 'call': 9, 't': 29}, {'initial': 8, 'gap_tenths': 25}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 15, 'red_actuations': 14, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 12, 'call': -1, 't': 23}, {'initial': 15, 'gap_tenths': 27}), ({'min_green': 9, 'added_per_act_tenths': 15, 'max_initial': 24, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 11, 'time_to_reduce': 25, 'call': 10, 't': 6}, {'initial': 9, 'gap_tenths': 30}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 20, 'max_initial': 10, 'red_actuations': 6, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 1, 'time_to_reduce': 25, 'call': -1, 't': 52}, {'initial': 10, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 11, 'red_actuations': 18, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 17, 'call': 2, 't': 46}, {'initial': 11, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 27, 'red_actuations': 2, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 21, 'call': 10, 't': 4}, {'initial': 8, 'gap_tenths': 30}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 24, 'red_actuations': 2, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 11, 'time_to_reduce': 8, 'call': -2, 't': 26}, {'initial': 6, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 20, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 24, 'call': 14, 't': 35}, {'initial': 12, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 29, 'red_actuations': 3, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 12, 'time_to_reduce': 13, 'call': -2, 't': 48}, {'initial': 5, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 20, 'max_initial': 25, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 13, 'time_to_reduce': 29, 'call': -4, 't': 16}, {'initial': 25, 'gap_tenths': 33}), ({'min_green': 7, 'added_per_act_tenths': 10, 'max_initial': 11, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 12, 'time_to_reduce': 6, 'call': 1, 't': 28}, {'initial': 7, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 18, 'red_actuations': 12, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 24, 'call': -2, 't': 33}, {'initial': 18, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 21, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 6, 'time_to_reduce': 29, 'call': 13, 't': 51}, {'initial': 6, 'gap_tenths': 15}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 20, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 27, 'call': 12, 't': 31}, {'initial': 20, 'gap_tenths': 20})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 25, 'max_initial': 15, 'red_actuations': 1, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 21, 'call': 9, 't': 44}, {'initial': 4, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 20, 'max_initial': 27, 'red_actuations': 1, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 5, 'call': -4, 't': 31}, {'initial': 5, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 25, 'max_initial': 10, 'red_actuations': 18, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 14, 'time_to_reduce': 22, 'call': -2, 't': 11}, {'initial': 10, 'gap_tenths': 35}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 17, 'red_actuations': 20, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 1, 'time_to_reduce': 12, 'call': -3, 't': 60}, {'initial': 17, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 25, 'max_initial': 22, 'red_actuations': 19, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 2, 'time_to_reduce': 23, 'call': 12, 't': 12}, {'initial': 22, 'gap_tenths': 40})]]
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:
Volume-density added initial and gap reduction returns a wrong result when variable initial is not floored at min green.

Input {min_green, added_per_act_tenths, max_initial, red_actuations, initial_gap_tenths, min_gap_tenths, time_before_reduction, time_to_reduce, call, t}. Variable initial = min(max_initial, max(min_green, ceil(actuations*added/10))) seconds. Gap reduction is timed from the conflicting call (a call before green start counts from 0): until time_before_reduction elapses the allowed gap is the initial gap; during time_to_reduce it falls linearly with the reduction amount truncated to whole tenths; afterwards it is the minimum gap. Return {initial, gap_tenths}.

split: open-access


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

N = 1
observations = []
def solve(x):
    m = x['min_green']
    initial = min(x['max_initial'], max(m, -(-x['red_actuations'] * x['added_per_act_tenths'] // 10)))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - 0
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = g0 - (g0 - gm) * done // x['time_to_reduce']
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 7, 'added_per_act_tenths': 10, 'max_initial': 30, 'red_actuations': 16, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 9, 'time_to_reduce': 29, 'call': 9, 't': 36}, {'initial': 16, 'gap_tenths': 25}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 25, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 0, 'time_to_reduce': 27, 'call': 5, 't': 50}, {'initial': 8, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 14, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 14, 'call': 10, 't': 12}, {'initial': 7, 'gap_tenths': 30}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 3, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 11, 'time_to_reduce': 17, 'call': 3, 't': 6}, {'initial': 6, 'gap_tenths': 30}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 18, 'red_actuations': 14, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 4, 'time_to_reduce': 5, 'call': -1, 't': 6}, {'initial': 18, 'gap_tenths': 22}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 7, 'added_per_act_tenths': 15, 'max_initial': 19, 'red_actuations': 2, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 14, 'time_to_reduce': 14, 'call': 1, 't': 23}, {'initial': 7, 'gap_tenths': 30}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 25, 'red_actuations': 14, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 29, 'call': -4, 't': 11}, {'initial': 21, 'gap_tenths': 38}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 27, 'red_actuations': 13, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 10, 'call': 1, 't': 26}, {'initial': 20, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 26, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 14, 'time_to_reduce': 21, 'call': 15, 't': 46}, {'initial': 26, 'gap_tenths': 18}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 27, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 0, 'time_to_reduce': 11, 'call': 7, 't': 35}, {'initial': 27, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31})], [({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 20, 'red_actuations': 13, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 28, 'call': 13, 't': 6}, {'initial': 20, 'gap_tenths': 35}), ({'min_green': 8, 'added_per_act_tenths': 10, 'max_initial': 27, 'red_actuations': 5, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 19, 'call': -2, 't': 17}, {'initial': 8, 'gap_tenths': 19}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 15, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 13, 'time_to_reduce': 23, 'call': 7, 't': 16}, {'initial': 12, 'gap_tenths': 40}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 22, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 4, 'time_to_reduce': 27, 'call': 7, 't': 27}, {'initial': 6, 'gap_tenths': 27}), ({'min_green': 5, 'added_per_act_tenths': 20, 'max_initial': 23, 'red_actuations': 1, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 14, 'time_to_reduce': 12, 'call': 7, 't': 55}, {'initial': 5, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28})], [({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 20, 'red_actuations': 18, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 7, 'time_to_reduce': 13, 'call': -5, 't': 10}, {'initial': 20, 'gap_tenths': 42}), ({'min_green': 4, 'added_per_act_tenths': 10, 'max_initial': 12, 'red_actuations': 1, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 7, 'time_to_reduce': 17, 'call': 2, 't': 8}, {'initial': 4, 'gap_tenths': 50}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 28, 'red_actuations': 5, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 11, 'time_to_reduce': 20, 'call': 7, 't': 1}, {'initial': 13, 'gap_tenths': 30}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 17, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 23, 'call': 4, 't': 20}, {'initial': 26, 'gap_tenths': 32}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 29, 'red_actuations': 5, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 7, 'time_to_reduce': 8, 'call': -2, 't': 52}, {'initial': 10, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 21, 'red_actuations': 20, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 26, 'call': 15, 't': 25}, {'initial': 21, 'gap_tenths': 29}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 14, 'red_actuations': 6, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 21, 'call': -2, 't': 12}, {'initial': 9, 'gap_tenths': 25}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 15, 'max_initial': 16, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 7, 'time_to_reduce': 21, 'call': 9, 't': 57}, {'initial': 11, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 30, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 9, 'call': 11, 't': 28}, {'initial': 30, 'gap_tenths': 27}), ({'min_green': 4, 'added_per_act_tenths': 10, 'max_initial': 23, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 11, 'call': -1, 't': 19}, {'initial': 17, 'gap_tenths': 15})]]
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):
    m = x['min_green']
    initial = min(x['max_initial'], max(m, -(-x['red_actuations'] * x['added_per_act_tenths'] // 10)))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - x['call']
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = g0 - (g0 - gm) * done // x['time_to_reduce']
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 7, 'added_per_act_tenths': 10, 'max_initial': 30, 'red_actuations': 16, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 9, 'time_to_reduce': 29, 'call': 9, 't': 36}, {'initial': 16, 'gap_tenths': 25}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 25, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 0, 'time_to_reduce': 27, 'call': 5, 't': 50}, {'initial': 8, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 14, 'red_actuations': 0, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 14, 'call': 10, 't': 12}, {'initial': 7, 'gap_tenths': 30}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 3, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 11, 'time_to_reduce': 17, 'call': 3, 't': 6}, {'initial': 6, 'gap_tenths': 30}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 18, 'red_actuations': 14, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 4, 'time_to_reduce': 5, 'call': -1, 't': 6}, {'initial': 18, 'gap_tenths': 22}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 7, 'added_per_act_tenths': 15, 'max_initial': 19, 'red_actuations': 2, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 14, 'time_to_reduce': 14, 'call': 1, 't': 23}, {'initial': 7, 'gap_tenths': 30}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 25, 'red_actuations': 14, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 29, 'call': -4, 't': 11}, {'initial': 21, 'gap_tenths': 38}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 27, 'red_actuations': 13, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 10, 'call': 1, 't': 26}, {'initial': 20, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 25, 'max_initial': 26, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 14, 'time_to_reduce': 21, 'call': 15, 't': 46}, {'initial': 26, 'gap_tenths': 18}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 9, 'added_per_act_tenths': 25, 'max_initial': 27, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 0, 'time_to_reduce': 11, 'call': 7, 't': 35}, {'initial': 27, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31})], [({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 20, 'red_actuations': 13, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 28, 'call': 13, 't': 6}, {'initial': 20, 'gap_tenths': 35}), ({'min_green': 8, 'added_per_act_tenths': 10, 'max_initial': 27, 'red_actuations': 5, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 19, 'call': -2, 't': 17}, {'initial': 8, 'gap_tenths': 19}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 15, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 13, 'time_to_reduce': 23, 'call': 7, 't': 16}, {'initial': 12, 'gap_tenths': 40}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 22, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 4, 'time_to_reduce': 27, 'call': 7, 't': 27}, {'initial': 6, 'gap_tenths': 27}), ({'min_green': 5, 'added_per_act_tenths': 20, 'max_initial': 23, 'red_actuations': 1, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 14, 'time_to_reduce': 12, 'call': 7, 't': 55}, {'initial': 5, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28})], [({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 20, 'red_actuations': 18, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 7, 'time_to_reduce': 13, 'call': -5, 't': 10}, {'initial': 20, 'gap_tenths': 42}), ({'min_green': 4, 'added_per_act_tenths': 10, 'max_initial': 12, 'red_actuations': 1, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 7, 'time_to_reduce': 17, 'call': 2, 't': 8}, {'initial': 4, 'gap_tenths': 50}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 28, 'red_actuations': 5, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 11, 'time_to_reduce': 20, 'call': 7, 't': 1}, {'initial': 13, 'gap_tenths': 30}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 17, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 23, 'call': 4, 't': 20}, {'initial': 26, 'gap_tenths': 32}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 29, 'red_actuations': 5, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 7, 'time_to_reduce': 8, 'call': -2, 't': 52}, {'initial': 10, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 21, 'red_actuations': 20, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 26, 'call': 15, 't': 25}, {'initial': 21, 'gap_tenths': 29}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 14, 'red_actuations': 6, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 21, 'call': -2, 't': 12}, {'initial': 9, 'gap_tenths': 25}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 7, 'added_per_act_tenths': 15, 'max_initial': 16, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 7, 'time_to_reduce': 21, 'call': 9, 't': 57}, {'initial': 11, 'gap_tenths': 15}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 30, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 12, 'time_to_reduce': 9, 'call': 11, 't': 28}, {'initial': 30, 'gap_tenths': 27}), ({'min_green': 4, 'added_per_act_tenths': 10, 'max_initial': 23, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 11, 'call': -1, 't': 19}, {'initial': 17, 'gap_tenths': 15})]]
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:
Volume-density added initial and gap reduction returns a wrong result when gap reduction is timed from green start.

Input {min_green, added_per_act_tenths, max_initial, red_actuations, initial_gap_tenths, min_gap_tenths, time_before_reduction, time_to_reduce, call, t}. Variable initial = min(max_initial, max(min_green, ceil(actuations*added/10))) seconds. Gap reduction is timed from the conflicting call (a call before green start counts from 0): until time_before_reduction elapses the allowed gap is the initial gap; during time_to_reduce it falls linearly with the reduction amount truncated to whole tenths; afterwards it is the minimum gap. Return {initial, gap_tenths}.

split: open-access


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

N = 1
observations = []
def solve(x):
    m = x['min_green']
    initial = min(x['max_initial'], max(m, -(-x['red_actuations'] * x['added_per_act_tenths'] // 10)))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - max(x['call'], 0)
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = g0 - (g0 - gm) * (done // x['time_to_reduce'])
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 10, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 13, 'time_to_reduce': 19, 'call': 12, 't': 11}, {'initial': 10, 'gap_tenths': 50}), ({'min_green': 5, 'added_per_act_tenths': 25, 'max_initial': 11, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 9, 'time_to_reduce': 29, 'call': -4, 't': 36}, {'initial': 11, 'gap_tenths': 17}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 16, 'red_actuations': 13, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 24, 'call': 14, 't': 46}, {'initial': 16, 'gap_tenths': 10}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 30, 'red_actuations': 5, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 10, 'call': 11, 't': 58}, {'initial': 13, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 13, 'red_actuations': 16, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 11, 'time_to_reduce': 12, 'call': 14, 't': 43}, {'initial': 13, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 22, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 22, 'call': 6, 't': 7}, {'initial': 9, 'gap_tenths': 50}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 25, 'red_actuations': 1, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 5, 'call': -1, 't': 37}, {'initial': 5, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 10, 'red_actuations': 4, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 0, 'time_to_reduce': 28, 'call': 9, 't': 30}, {'initial': 6, 'gap_tenths': 18}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 28, 'red_actuations': 8, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 1, 'time_to_reduce': 26, 'call': -2, 't': 29}, {'initial': 16, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 6, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 8, 'call': -2, 't': 34}, {'initial': 9, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 18, 'call': 14, 't': 8}, {'initial': 24, 'gap_tenths': 35}), ({'min_green': 5, 'added_per_act_tenths': 10, 'max_initial': 11, 'red_actuations': 8, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 1, 'time_to_reduce': 10, 'call': -4, 't': 19}, {'initial': 8, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 14, 'red_actuations': 13, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 6, 'call': 4, 't': 0}, {'initial': 14, 'gap_tenths': 50}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 29, 'red_actuations': 17, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 15, 'call': 12, 't': 36}, {'initial': 29, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 10, 'max_initial': 18, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 11, 'time_to_reduce': 25, 'call': 5, 't': 28}, {'initial': 16, 'gap_tenths': 26})], [({'min_green': 8, 'added_per_act_tenths': 15, 'max_initial': 29, 'red_actuations': 15, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 3, 'time_to_reduce': 23, 'call': 0, 't': 2}, {'initial': 23, 'gap_tenths': 40}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 10, 'red_actuations': 1, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 9, 'time_to_reduce': 30, 'call': 8, 't': 26}, {'initial': 9, 'gap_tenths': 40}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 25, 'max_initial': 17, 'red_actuations': 5, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 6, 'time_to_reduce': 6, 'call': -1, 't': 21}, {'initial': 13, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 14, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 5, 'call': 9, 't': 47}, {'initial': 14, 'gap_tenths': 15}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 22, 'red_actuations': 2, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 5, 'call': -4, 't': 3}, {'initial': 10, 'gap_tenths': 50})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 10, 'max_initial': 24, 'red_actuations': 15, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 1, 'time_to_reduce': 27, 'call': 13, 't': 35}, {'initial': 15, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 7, 'added_per_act_tenths': 15, 'max_initial': 12, 'red_actuations': 3, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 3, 'time_to_reduce': 6, 'call': 0, 't': 40}, {'initial': 7, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 30, 'red_actuations': 18, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 0, 'time_to_reduce': 26, 'call': 0, 't': 33}, {'initial': 30, 'gap_tenths': 20}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 13, 'red_actuations': 8, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 6, 'time_to_reduce': 23, 'call': 0, 't': 55}, {'initial': 13, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 15, 'max_initial': 28, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 10, 'call': 5, 't': 20}, {'initial': 8, 'gap_tenths': 50})]]
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):
    m = x['min_green']
    initial = min(x['max_initial'], max(m, -(-x['red_actuations'] * x['added_per_act_tenths'] // 10)))
    g0, gm = x['initial_gap_tenths'], x['min_gap_tenths']
    el = x['t'] - max(x['call'], 0)
    if el <= x['time_before_reduction']:
        gap = g0
    elif el >= x['time_before_reduction'] + x['time_to_reduce']:
        gap = gm
    else:
        done = el - x['time_before_reduction']
        gap = (g0 * (x['time_to_reduce'] - done) + gm * done) // x['time_to_reduce']
    return {'initial': initial, 'gap_tenths': gap}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 10, 'red_actuations': 15, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 13, 'time_to_reduce': 19, 'call': 12, 't': 11}, {'initial': 10, 'gap_tenths': 50}), ({'min_green': 5, 'added_per_act_tenths': 25, 'max_initial': 11, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 9, 'time_to_reduce': 29, 'call': -4, 't': 36}, {'initial': 11, 'gap_tenths': 17}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 16, 'red_actuations': 13, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 2, 'time_to_reduce': 24, 'call': 14, 't': 46}, {'initial': 16, 'gap_tenths': 10}), ({'min_green': 7, 'added_per_act_tenths': 25, 'max_initial': 30, 'red_actuations': 5, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 5, 'time_to_reduce': 10, 'call': 11, 't': 58}, {'initial': 13, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 13, 'red_actuations': 16, 'initial_gap_tenths': 30, 'min_gap_tenths': 10, 'time_before_reduction': 11, 'time_to_reduce': 12, 'call': 14, 't': 43}, {'initial': 13, 'gap_tenths': 10})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 22, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 22, 'call': 6, 't': 7}, {'initial': 9, 'gap_tenths': 50}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 25, 'red_actuations': 1, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 8, 'time_to_reduce': 5, 'call': -1, 't': 37}, {'initial': 5, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 10, 'red_actuations': 4, 'initial_gap_tenths': 40, 'min_gap_tenths': 10, 'time_before_reduction': 0, 'time_to_reduce': 28, 'call': 9, 't': 30}, {'initial': 6, 'gap_tenths': 18}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 28, 'red_actuations': 8, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 1, 'time_to_reduce': 26, 'call': -2, 't': 29}, {'initial': 16, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 6, 'initial_gap_tenths': 30, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 8, 'call': -2, 't': 34}, {'initial': 9, 'gap_tenths': 15}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20})], [({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 26, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 4, 'time_to_reduce': 18, 'call': 14, 't': 8}, {'initial': 24, 'gap_tenths': 35}), ({'min_green': 5, 'added_per_act_tenths': 10, 'max_initial': 11, 'red_actuations': 8, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 1, 'time_to_reduce': 10, 'call': -4, 't': 19}, {'initial': 8, 'gap_tenths': 15}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 14, 'red_actuations': 13, 'initial_gap_tenths': 50, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 6, 'call': 4, 't': 0}, {'initial': 14, 'gap_tenths': 50}), ({'min_green': 6, 'added_per_act_tenths': 20, 'max_initial': 29, 'red_actuations': 17, 'initial_gap_tenths': 35, 'min_gap_tenths': 10, 'time_before_reduction': 6, 'time_to_reduce': 15, 'call': 12, 't': 36}, {'initial': 29, 'gap_tenths': 10}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 5, 'added_per_act_tenths': 10, 'max_initial': 18, 'red_actuations': 16, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 11, 'time_to_reduce': 25, 'call': 5, 't': 28}, {'initial': 16, 'gap_tenths': 26})], [({'min_green': 8, 'added_per_act_tenths': 15, 'max_initial': 29, 'red_actuations': 15, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 3, 'time_to_reduce': 23, 'call': 0, 't': 2}, {'initial': 23, 'gap_tenths': 40}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 9, 'added_per_act_tenths': 10, 'max_initial': 10, 'red_actuations': 1, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 9, 'time_to_reduce': 30, 'call': 8, 't': 26}, {'initial': 9, 'gap_tenths': 40}), ({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 25, 'max_initial': 17, 'red_actuations': 5, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 6, 'time_to_reduce': 6, 'call': -1, 't': 21}, {'initial': 13, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 14, 'red_actuations': 17, 'initial_gap_tenths': 40, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 5, 'call': 9, 't': 47}, {'initial': 14, 'gap_tenths': 15}), ({'min_green': 10, 'added_per_act_tenths': 15, 'max_initial': 22, 'red_actuations': 2, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 5, 'call': -4, 't': 3}, {'initial': 10, 'gap_tenths': 50})], [({'min_green': 5, 'added_per_act_tenths': 15, 'max_initial': 20, 'red_actuations': 7, 'initial_gap_tenths': 40, 'min_gap_tenths': 20, 'time_before_reduction': 10, 'time_to_reduce': 15, 'call': 3, 't': 20}, {'initial': 11, 'gap_tenths': 31}), ({'min_green': 4, 'added_per_act_tenths': 10, 'max_initial': 24, 'red_actuations': 15, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 1, 'time_to_reduce': 27, 'call': 13, 't': 35}, {'initial': 15, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 20, 'max_initial': 12, 'red_actuations': 9, 'initial_gap_tenths': 35, 'min_gap_tenths': 15, 'time_before_reduction': 5, 'time_to_reduce': 20, 'call': -4, 't': 12}, {'initial': 12, 'gap_tenths': 28}), ({'min_green': 7, 'added_per_act_tenths': 15, 'max_initial': 12, 'red_actuations': 3, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 3, 'time_to_reduce': 6, 'call': 0, 't': 40}, {'initial': 7, 'gap_tenths': 20}), ({'min_green': 10, 'added_per_act_tenths': 20, 'max_initial': 30, 'red_actuations': 18, 'initial_gap_tenths': 35, 'min_gap_tenths': 20, 'time_before_reduction': 0, 'time_to_reduce': 26, 'call': 0, 't': 33}, {'initial': 30, 'gap_tenths': 20}), ({'min_green': 4, 'added_per_act_tenths': 20, 'max_initial': 13, 'red_actuations': 8, 'initial_gap_tenths': 30, 'min_gap_tenths': 20, 'time_before_reduction': 6, 'time_to_reduce': 23, 'call': 0, 't': 55}, {'initial': 13, 'gap_tenths': 20}), ({'min_green': 6, 'added_per_act_tenths': 25, 'max_initial': 25, 'red_actuations': 3, 'initial_gap_tenths': 50, 'min_gap_tenths': 20, 'time_before_reduction': 8, 'time_to_reduce': 12, 'call': 0, 't': 40}, {'initial': 8, 'gap_tenths': 20}), ({'min_green': 8, 'added_per_act_tenths': 15, 'max_initial': 28, 'red_actuations': 0, 'initial_gap_tenths': 50, 'min_gap_tenths': 15, 'time_before_reduction': 15, 'time_to_reduce': 10, 'call': 5, 't': 20}, {'initial': 8, 'gap_tenths': 50})]]
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:
Volume-density added initial and gap reduction returns a wrong result when the reduction is quantised to whole reduction periods.

Input {min_green, added_per_act_tenths, max_initial, red_actuations, initial_gap_tenths, min_gap_tenths, time_before_reduction, time_to_reduce, call, t}. Variable initial = min(max_initial, max(min_green, ceil(actuations*added/10))) seconds. Gap reduction is timed from the conflicting call (a call before green start counts from 0): until time_before_reduction elapses the allowed gap is the initial gap; during time_to_reduce it falls linearly with the reduction amount truncated to whole tenths; afterwards it is the minimum gap. Return {initial, gap_tenths}.

split: open-access