broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    sp = x['walk_speed_tenths']
    fdw = -(-x['crossing_ft'] * 10 // sp)
    walk = x['min_walk']
    total = -(-(x['crossing_ft'] + 6) * 10 // 30)
    if walk < total:
        walk = total - fdw
    yr = Fraction(x['yellow_tenths'] + x['red_tenths'], 10)
    g = x['min_green']
    if x['ped_call']:
        need = walk + fdw - yr
        g = max(g, math.ceil(need))
    return {'walk': walk, 'fdw': fdw, 'green': g, 'fits': g + yr <= x['split']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 81, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 34}, {'walk': 5, 'fdw': 24, 'green': 23, 'fits': True}), ({'crossing_ft': 93, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 27}, {'walk': 7, 'fdw': 27, 'green': 30, 'fits': False}), ({'crossing_ft': 80, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 38}, {'walk': 9, 'fdw': 20, 'green': 24, 'fits': True}), ({'crossing_ft': 32, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 27}, {'walk': 7, 'fdw': 10, 'green': 10, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 58, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 24}, {'walk': 7, 'fdw': 15, 'green': 17, 'fits': True})], [({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 86, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 18}, {'walk': 6, 'fdw': 25, 'green': 5, 'fits': True}), ({'crossing_ft': 33, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 42}, {'walk': 7, 'fdw': 11, 'green': 13, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 17}, {'walk': 7, 'fdw': 26, 'green': 29, 'fits': False}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 35, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 43}, {'walk': 5, 'fdw': 9, 'green': 15, 'fits': True}), ({'crossing_ft': 82, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 26}, {'walk': 7, 'fdw': 24, 'green': 26, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True})], [({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 26, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 44}, {'walk': 4, 'fdw': 7, 'green': 8, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 24, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 34}, {'walk': 7, 'fdw': 8, 'green': 5, 'fits': True}), ({'crossing_ft': 87, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 43}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': True}), ({'crossing_ft': 103, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 18}, {'walk': 7, 'fdw': 30, 'green': 31, 'fits': False}), ({'crossing_ft': 64, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 26}, {'walk': 5, 'fdw': 22, 'green': 5, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True})], [({'crossing_ft': 73, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 26}, {'walk': 6, 'fdw': 21, 'green': 22, 'fits': False}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 108, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 35}, {'walk': 7, 'fdw': 31, 'green': 32, 'fits': False}), ({'crossing_ft': 87, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': False}), ({'crossing_ft': 72, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 15}, {'walk': 4, 'fdw': 24, 'green': 5, 'fits': True}), ({'crossing_ft': 44, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 32}, {'walk': 7, 'fdw': 13, 'green': 8, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})], [({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 99, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 20}, {'walk': 6, 'fdw': 29, 'green': 30, 'fits': False}), ({'crossing_ft': 51, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 40}, {'walk': 10, 'fdw': 15, 'green': 10, 'fits': True}), ({'crossing_ft': 77, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 18}, {'walk': 8, 'fdw': 20, 'green': 22, 'fits': False}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 72, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 23}, {'walk': 8, 'fdw': 18, 'green': 20, 'fits': False}), ({'crossing_ft': 29, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 32}, {'walk': 10, 'fdw': 9, 'green': 14, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True})]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    sp = x['walk_speed_tenths']
    fdw = -(-x['crossing_ft'] * 10 // sp)
    walk = x['min_walk']
    total = -(-(x['crossing_ft'] + 6) * 10 // 30)
    if fdw < total:
        walk = total - fdw
    yr = Fraction(x['yellow_tenths'] + x['red_tenths'], 10)
    g = x['min_green']
    if x['ped_call']:
        need = walk + fdw - yr
        g = max(g, math.ceil(need))
    return {'walk': walk, 'fdw': fdw, 'green': g, 'fits': g + yr <= x['split']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 81, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 34}, {'walk': 5, 'fdw': 24, 'green': 23, 'fits': True}), ({'crossing_ft': 93, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 27}, {'walk': 7, 'fdw': 27, 'green': 30, 'fits': False}), ({'crossing_ft': 80, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 38}, {'walk': 9, 'fdw': 20, 'green': 24, 'fits': True}), ({'crossing_ft': 32, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 27}, {'walk': 7, 'fdw': 10, 'green': 10, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 58, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 24}, {'walk': 7, 'fdw': 15, 'green': 17, 'fits': True})], [({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 86, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 18}, {'walk': 6, 'fdw': 25, 'green': 5, 'fits': True}), ({'crossing_ft': 33, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 42}, {'walk': 7, 'fdw': 11, 'green': 13, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 17}, {'walk': 7, 'fdw': 26, 'green': 29, 'fits': False}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 35, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 43}, {'walk': 5, 'fdw': 9, 'green': 15, 'fits': True}), ({'crossing_ft': 82, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 26}, {'walk': 7, 'fdw': 24, 'green': 26, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True})], [({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 26, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 44}, {'walk': 4, 'fdw': 7, 'green': 8, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 24, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 34}, {'walk': 7, 'fdw': 8, 'green': 5, 'fits': True}), ({'crossing_ft': 87, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 43}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': True}), ({'crossing_ft': 103, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 18}, {'walk': 7, 'fdw': 30, 'green': 31, 'fits': False}), ({'crossing_ft': 64, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 26}, {'walk': 5, 'fdw': 22, 'green': 5, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True})], [({'crossing_ft': 73, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 26}, {'walk': 6, 'fdw': 21, 'green': 22, 'fits': False}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 108, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 35}, {'walk': 7, 'fdw': 31, 'green': 32, 'fits': False}), ({'crossing_ft': 87, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': False}), ({'crossing_ft': 72, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 15}, {'walk': 4, 'fdw': 24, 'green': 5, 'fits': True}), ({'crossing_ft': 44, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 32}, {'walk': 7, 'fdw': 13, 'green': 8, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})], [({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 99, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 20}, {'walk': 6, 'fdw': 29, 'green': 30, 'fits': False}), ({'crossing_ft': 51, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 40}, {'walk': 10, 'fdw': 15, 'green': 10, 'fits': True}), ({'crossing_ft': 77, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 18}, {'walk': 8, 'fdw': 20, 'green': 22, 'fits': False}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 72, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 23}, {'walk': 8, 'fdw': 18, 'green': 20, 'fits': False}), ({'crossing_ft': 29, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 32}, {'walk': 10, 'fdw': 9, 'green': 14, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True})]]
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:
Pedestrian walk and clearance timing returns a wrong result when walk is extended by comparing walk alone to total crossing time.

Input {crossing_ft, walk_speed_tenths (ft/s*10), min_walk, yellow_tenths, red_tenths, min_green, ped_call, split}. FDW = ceil(crossing*10/speed). Walk starts at min_walk and is extended so that walk + FDW >= ceil((crossing + 6)/3.0) (pushbutton-to-far-curb check at 3.0 ft/s). FDW may overlap yellow and all-red, so with a ped call the vehicle green is max(min_green, ceil(walk + FDW - (yellow+red))). Without a call green = min_green. fits is green + yellow + red <= split. Return {walk, fdw, green, fits}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    sp = x['walk_speed_tenths']
    fdw = -(-x['crossing_ft'] * 10 // sp)
    walk = x['min_walk']
    total = -(-(x['crossing_ft'] + 6) * 10 // 30)
    if walk + fdw < total:
        walk = total - fdw
    yr = Fraction(x['yellow_tenths'] + x['red_tenths'], 10)
    g = x['min_green']
    if x['ped_call']:
        need = walk + fdw
        g = max(g, math.ceil(need))
    return {'walk': walk, 'fdw': fdw, 'green': g, 'fits': g + yr <= x['split']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 25, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': False, 'split': 18}, {'walk': 4, 'fdw': 7, 'green': 8, 'fits': True}), ({'crossing_ft': 50, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 21}, {'walk': 4, 'fdw': 15, 'green': 10, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 51, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 22}, {'walk': 10, 'fdw': 15, 'green': 21, 'fits': False}), ({'crossing_ft': 40, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 10, 'fdw': 14, 'green': 18, 'fits': False}), ({'crossing_ft': 103, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 31}, {'walk': 10, 'fdw': 30, 'green': 5, 'fits': True})], [({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 8, 'ped_call': False, 'split': 42}, {'walk': 7, 'fdw': 26, 'green': 8, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': False, 'split': 37}, {'walk': 7, 'fdw': 26, 'green': 15, 'fits': True}), ({'crossing_ft': 85, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 18}, {'walk': 10, 'fdw': 25, 'green': 10, 'fits': True}), ({'crossing_ft': 62, 'walk_speed_tenths': 40, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 27}, {'walk': 10, 'fdw': 16, 'green': 21, 'fits': True}), ({'crossing_ft': 30, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 17}, {'walk': 7, 'fdw': 9, 'green': 10, 'fits': True})], [({'crossing_ft': 35, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 27}, {'walk': 5, 'fdw': 12, 'green': 8, 'fits': True}), ({'crossing_ft': 30, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 39}, {'walk': 4, 'fdw': 10, 'green': 15, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 104, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 36}, {'walk': 7, 'fdw': 30, 'green': 32, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 96, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 37}, {'walk': 6, 'fdw': 28, 'green': 5, 'fits': True}), ({'crossing_ft': 68, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 38}, {'walk': 8, 'fdw': 17, 'green': 20, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})], [({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 44, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 40}, {'walk': 7, 'fdw': 13, 'green': 5, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 46, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 43}, {'walk': 10, 'fdw': 16, 'green': 8, 'fits': True}), ({'crossing_ft': 35, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 42}, {'walk': 7, 'fdw': 10, 'green': 11, 'fits': True}), ({'crossing_ft': 43, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 32}, {'walk': 5, 'fdw': 15, 'green': 10, 'fits': True}), ({'crossing_ft': 107, 'walk_speed_tenths': 40, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 19}, {'walk': 11, 'fdw': 27, 'green': 10, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})], [({'crossing_ft': 29, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 29}, {'walk': 10, 'fdw': 10, 'green': 16, 'fits': True}), ({'crossing_ft': 48, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 44}, {'walk': 10, 'fdw': 16, 'green': 5, 'fits': True}), ({'crossing_ft': 108, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 26}, {'walk': 4, 'fdw': 36, 'green': 36, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 74, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 42}, {'walk': 8, 'fdw': 19, 'green': 10, 'fits': True}), ({'crossing_ft': 101, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 23}, {'walk': 7, 'fdw': 29, 'green': 8, 'fits': True})]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    sp = x['walk_speed_tenths']
    fdw = -(-x['crossing_ft'] * 10 // sp)
    walk = x['min_walk']
    total = -(-(x['crossing_ft'] + 6) * 10 // 30)
    if walk + fdw < total:
        walk = total - fdw
    yr = Fraction(x['yellow_tenths'] + x['red_tenths'], 10)
    g = x['min_green']
    if x['ped_call']:
        need = walk + fdw - Fraction(x['yellow_tenths'], 10)
        g = max(g, math.ceil(need))
    return {'walk': walk, 'fdw': fdw, 'green': g, 'fits': g + yr <= x['split']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 25, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': False, 'split': 18}, {'walk': 4, 'fdw': 7, 'green': 8, 'fits': True}), ({'crossing_ft': 50, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 21}, {'walk': 4, 'fdw': 15, 'green': 10, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 51, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 22}, {'walk': 10, 'fdw': 15, 'green': 21, 'fits': False}), ({'crossing_ft': 40, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 10, 'fdw': 14, 'green': 18, 'fits': False}), ({'crossing_ft': 103, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 31}, {'walk': 10, 'fdw': 30, 'green': 5, 'fits': True})], [({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 8, 'ped_call': False, 'split': 42}, {'walk': 7, 'fdw': 26, 'green': 8, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': False, 'split': 37}, {'walk': 7, 'fdw': 26, 'green': 15, 'fits': True}), ({'crossing_ft': 85, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 18}, {'walk': 10, 'fdw': 25, 'green': 10, 'fits': True}), ({'crossing_ft': 62, 'walk_speed_tenths': 40, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 27}, {'walk': 10, 'fdw': 16, 'green': 21, 'fits': True}), ({'crossing_ft': 30, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 17}, {'walk': 7, 'fdw': 9, 'green': 10, 'fits': True})], [({'crossing_ft': 35, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 27}, {'walk': 5, 'fdw': 12, 'green': 8, 'fits': True}), ({'crossing_ft': 30, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 39}, {'walk': 4, 'fdw': 10, 'green': 15, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 104, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 36}, {'walk': 7, 'fdw': 30, 'green': 32, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 96, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 37}, {'walk': 6, 'fdw': 28, 'green': 5, 'fits': True}), ({'crossing_ft': 68, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 38}, {'walk': 8, 'fdw': 17, 'green': 20, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})], [({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 44, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 40}, {'walk': 7, 'fdw': 13, 'green': 5, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 46, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 43}, {'walk': 10, 'fdw': 16, 'green': 8, 'fits': True}), ({'crossing_ft': 35, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 42}, {'walk': 7, 'fdw': 10, 'green': 11, 'fits': True}), ({'crossing_ft': 43, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 32}, {'walk': 5, 'fdw': 15, 'green': 10, 'fits': True}), ({'crossing_ft': 107, 'walk_speed_tenths': 40, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 19}, {'walk': 11, 'fdw': 27, 'green': 10, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})], [({'crossing_ft': 29, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 29}, {'walk': 10, 'fdw': 10, 'green': 16, 'fits': True}), ({'crossing_ft': 48, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 44}, {'walk': 10, 'fdw': 16, 'green': 5, 'fits': True}), ({'crossing_ft': 108, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 26}, {'walk': 4, 'fdw': 36, 'green': 36, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 74, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 42}, {'walk': 8, 'fdw': 19, 'green': 10, 'fits': True}), ({'crossing_ft': 101, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 23}, {'walk': 7, 'fdw': 29, 'green': 8, 'fits': True})]]
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:
Pedestrian walk and clearance timing returns a wrong result when no credit is taken for FDW overlapping the yellow and all-red.

Input {crossing_ft, walk_speed_tenths (ft/s*10), min_walk, yellow_tenths, red_tenths, min_green, ped_call, split}. FDW = ceil(crossing*10/speed). Walk starts at min_walk and is extended so that walk + FDW >= ceil((crossing + 6)/3.0) (pushbutton-to-far-curb check at 3.0 ft/s). FDW may overlap yellow and all-red, so with a ped call the vehicle green is max(min_green, ceil(walk + FDW - (yellow+red))). Without a call green = min_green. fits is green + yellow + red <= split. Return {walk, fdw, green, fits}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    sp = x['walk_speed_tenths']
    fdw = -(-x['crossing_ft'] * 10 // sp)
    walk = x['min_walk']
    total = -(-(x['crossing_ft'] + 6) * 10 // 30)
    if walk + fdw < total:
        walk = total - fdw
    yr = Fraction(x['yellow_tenths'] + x['red_tenths'], 10)
    g = x['min_green']
    if x['ped_call']:
        need = walk + fdw - yr
        g = max(g, math.ceil(need))
    return {'walk': walk, 'fdw': fdw, 'green': g, 'fits': g + yr < x['split']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossing_ft': 78, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 28}, {'walk': 5, 'fdw': 23, 'green': 23, 'fits': True}), ({'crossing_ft': 62, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 7, 'fdw': 16, 'green': 18, 'fits': True}), ({'crossing_ft': 85, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 32}, {'walk': 7, 'fdw': 25, 'green': 27, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 30, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 21}, {'walk': 5, 'fdw': 10, 'green': 15, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 81, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 43}, {'walk': 5, 'fdw': 24, 'green': 8, 'fits': True})], [({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 79, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 29}, {'walk': 6, 'fdw': 23, 'green': 24, 'fits': True}), ({'crossing_ft': 47, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 37}, {'walk': 7, 'fdw': 12, 'green': 5, 'fits': True}), ({'crossing_ft': 78, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 5, 'fdw': 23, 'green': 23, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 84, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 38}, {'walk': 10, 'fdw': 28, 'green': 33, 'fits': True}), ({'crossing_ft': 44, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 15}, {'walk': 6, 'fdw': 11, 'green': 12, 'fits': False})], [({'crossing_ft': 103, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 22}, {'walk': 7, 'fdw': 30, 'green': 33, 'fits': False}), ({'crossing_ft': 105, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 37}, {'walk': 7, 'fdw': 30, 'green': 32, 'fits': True}), ({'crossing_ft': 100, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 34}, {'walk': 7, 'fdw': 29, 'green': 31, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 101, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 36}, {'walk': 10, 'fdw': 26, 'green': 31, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 100, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 35}, {'walk': 7, 'fdw': 29, 'green': 32, 'fits': False})], [({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 34, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 20}, {'walk': 5, 'fdw': 12, 'green': 15, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 16}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': False}), ({'crossing_ft': 42, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 19}, {'walk': 5, 'fdw': 14, 'green': 13, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 95, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 36}, {'walk': 10, 'fdw': 28, 'green': 34, 'fits': False}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': False, 'split': 19}, {'walk': 7, 'fdw': 26, 'green': 15, 'fits': False})], [({'crossing_ft': 94, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 33}, {'walk': 10, 'fdw': 24, 'green': 28, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 80, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 31}, {'walk': 7, 'fdw': 23, 'green': 24, 'fits': True}), ({'crossing_ft': 86, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 36}, {'walk': 7, 'fdw': 29, 'green': 32, 'fits': True}), ({'crossing_ft': 55, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 7, 'fdw': 14, 'green': 15, 'fits': False}), ({'crossing_ft': 33, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 10, 'fdw': 10, 'green': 14, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})]]
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
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    sp = x['walk_speed_tenths']
    fdw = -(-x['crossing_ft'] * 10 // sp)
    walk = x['min_walk']
    total = -(-(x['crossing_ft'] + 6) * 10 // 30)
    if walk + fdw < total:
        walk = total - fdw
    yr = Fraction(x['yellow_tenths'] + x['red_tenths'], 10)
    g = x['min_green']
    if x['ped_call']:
        need = walk + fdw - yr
        g = max(g, math.ceil(need))
    return {'walk': walk, 'fdw': fdw, 'green': g, 'fits': g <= x['split']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'crossing_ft': 78, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 28}, {'walk': 5, 'fdw': 23, 'green': 23, 'fits': True}), ({'crossing_ft': 62, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 7, 'fdw': 16, 'green': 18, 'fits': True}), ({'crossing_ft': 85, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 32}, {'walk': 7, 'fdw': 25, 'green': 27, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 30, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 21}, {'walk': 5, 'fdw': 10, 'green': 15, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 81, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 43}, {'walk': 5, 'fdw': 24, 'green': 8, 'fits': True})], [({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 79, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 29}, {'walk': 6, 'fdw': 23, 'green': 24, 'fits': True}), ({'crossing_ft': 47, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 37}, {'walk': 7, 'fdw': 12, 'green': 5, 'fits': True}), ({'crossing_ft': 78, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 5, 'fdw': 23, 'green': 23, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 84, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 38}, {'walk': 10, 'fdw': 28, 'green': 33, 'fits': True}), ({'crossing_ft': 44, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 15}, {'walk': 6, 'fdw': 11, 'green': 12, 'fits': False})], [({'crossing_ft': 103, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 22}, {'walk': 7, 'fdw': 30, 'green': 33, 'fits': False}), ({'crossing_ft': 105, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 37}, {'walk': 7, 'fdw': 30, 'green': 32, 'fits': True}), ({'crossing_ft': 100, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 34}, {'walk': 7, 'fdw': 29, 'green': 31, 'fits': False}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 101, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 36}, {'walk': 10, 'fdw': 26, 'green': 31, 'fits': True}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 100, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 35}, {'walk': 7, 'fdw': 29, 'green': 32, 'fits': False})], [({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 34, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 20}, {'walk': 5, 'fdw': 12, 'green': 15, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 16}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': False}), ({'crossing_ft': 42, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 19}, {'walk': 5, 'fdw': 14, 'green': 13, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True}), ({'crossing_ft': 95, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 36}, {'walk': 10, 'fdw': 28, 'green': 34, 'fits': False}), ({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': False, 'split': 19}, {'walk': 7, 'fdw': 26, 'green': 15, 'fits': False})], [({'crossing_ft': 94, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 33}, {'walk': 10, 'fdw': 24, 'green': 28, 'fits': False}), ({'crossing_ft': 70, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 7, 'fdw': 20, 'green': 21, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 12}, {'walk': 7, 'fdw': 9, 'green': 8, 'fits': True}), ({'crossing_ft': 80, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 31}, {'walk': 7, 'fdw': 23, 'green': 24, 'fits': True}), ({'crossing_ft': 86, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 36}, {'walk': 7, 'fdw': 29, 'green': 32, 'fits': True}), ({'crossing_ft': 55, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 7, 'fdw': 14, 'green': 15, 'fits': False}), ({'crossing_ft': 33, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 10, 'fdw': 10, 'green': 14, 'fits': True}), ({'crossing_ft': 90, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 35}, {'walk': 6, 'fdw': 26, 'green': 27, 'fits': True})]]
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:
Pedestrian walk and clearance timing returns a wrong result when a plan that exactly fills its split is reported as not fitting.

Input {crossing_ft, walk_speed_tenths (ft/s*10), min_walk, yellow_tenths, red_tenths, min_green, ped_call, split}. FDW = ceil(crossing*10/speed). Walk starts at min_walk and is extended so that walk + FDW >= ceil((crossing + 6)/3.0) (pushbutton-to-far-curb check at 3.0 ft/s). FDW may overlap yellow and all-red, so with a ped call the vehicle green is max(min_green, ceil(walk + FDW - (yellow+red))). Without a call green = min_green. fits is green + yellow + red <= split. Return {walk, fdw, green, fits}.

split: open-access


prompt:
Actuated phase gap-out and max-out returns a wrong result when an actuation exactly at gap expiry is treated as a gap.

Input {min_green, gap, max_green, actuations: integer seconds since green start (any order), conflict_call: seconds or null}. Each actuation at a keeps the phase eligible until a+gap; an actuation exactly at expiry extends; actuations during min green always extend. Gap-out time = max(min_green, final expiry). With no conflicting call return ['rest', gap time]. The max timer starts at the call (a call before green start counts as 0); max-out at call+max_green. If gap time <= max-out the phase ends by 'gap-out' at max(gap time, call), else by 'max-out'.

split: open-access


prompt:
Actuated phase gap-out and max-out returns a wrong result when the max timer runs from the start of green.

Input {min_green, gap, max_green, actuations: integer seconds since green start (any order), conflict_call: seconds or null}. Each actuation at a keeps the phase eligible until a+gap; an actuation exactly at expiry extends; actuations during min green always extend. Gap-out time = max(min_green, final expiry). With no conflicting call return ['rest', gap time]. The max timer starts at the call (a call before green start counts as 0); max-out at call+max_green. If gap time <= max-out the phase ends by 'gap-out' at max(gap time, call), else by 'max-out'.

split: open-access


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

N = 1
observations = []
def solve(x):
    m, p, M = x['min_green'], x['gap'], x['max_green']
    exp = 0
    for a in sorted(x['actuations']):
        if a > exp and a > m:
            break
        exp = max(exp, a + p)
    gap_end = max(m, exp)
    tc = x['conflict_call']
    if tc is None:
        return ['rest', gap_end]
    tc = max(tc, 0)
    max_end = tc + M
    if gap_end < max_end:
        return ['gap-out', max(gap_end, tc)]
    return ['max-out', max_end]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 8, 'gap': 3, 'max_green': 30, 'actuations': [2, 6], 'conflict_call': 20}, ['gap-out', 20]), ({'min_green': 5, 'gap': 4, 'max_green': 19, 'actuations': [1, 2, 3, 4, 5, 6, 8, 9, 11, 12, 19, 20, 25, 28, 30, 35, 36, 38, 40, 49, 59], 'conflict_call': None}, ['rest', 16]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 5, 'gap': 5, 'max_green': 43, 'actuations': [0, 2, 8, 9, 11, 24, 53], 'conflict_call': 25}, ['gap-out', 25]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15])], [({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 9, 'gap': 2, 'max_green': 19, 'actuations': [12, 17, 20, 29, 38, 40, 44], 'conflict_call': None}, ['rest', 9]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 9, 'gap': 2, 'max_green': 21, 'actuations': [59, 4, 58, 36, 53, 57, 17, 30, 23], 'conflict_call': -2}, ['gap-out', 9]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7])], [({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 10, 'gap': 3, 'max_green': 44, 'actuations': [1, 27, 56, 32, 11, 54, 44, 28, 7, 58, 37, 30, 52, 0, 47, 46, 48], 'conflict_call': 4}, ['gap-out', 10]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 8, 'gap': 3, 'max_green': 30, 'actuations': [2, 6], 'conflict_call': 20}, ['gap-out', 20]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 5, 'gap': 3, 'max_green': 29, 'actuations': [2, 4, 6, 7, 10, 11, 14, 15, 19, 20, 21, 22, 24, 27, 29, 31, 32, 33, 34, 36, 39, 42, 43, 45, 47, 48, 50, 51, 52, 53, 54, 56, 57, 58, 59], 'conflict_call': None}, ['rest', 18]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15])], [({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 10, 'gap': 5, 'max_green': 37, 'actuations': [0, 1, 3, 4, 5, 7, 10, 12, 13, 17, 19, 23, 24, 26, 30, 31, 32, 34, 36, 37, 38, 42, 44, 45, 48, 49, 50, 51, 54, 55, 56], 'conflict_call': 22}, ['max-out', 59]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 6, 'gap': 5, 'max_green': 16, 'actuations': [1, 4, 8, 10, 11, 15, 20, 25, 31, 55, 59], 'conflict_call': 14}, ['gap-out', 30]), ({'min_green': 4, 'gap': 5, 'max_green': 19, 'actuations': [22, 17, 57, 12, 39, 42, 4, 38, 9, 2, 19, 16, 6, 8, 54, 43, 30, 58, 15, 59, 3, 35, 44, 53, 28, 51, 7, 27, 55, 40, 31, 36], 'conflict_call': 30}, ['gap-out', 49]), ({'min_green': 6, 'gap': 4, 'max_green': 30, 'actuations': [0, 7, 10, 12, 13, 17, 20, 22, 25, 38, 50, 53, 54, 58, 59], 'conflict_call': None}, ['rest', 6]), ({'min_green': 7, 'gap': 3, 'max_green': 39, 'actuations': [8, 10, 12, 13, 14, 17, 22, 29, 31, 36, 42, 44, 45, 50, 52, 54, 57, 58, 59], 'conflict_call': 30}, ['gap-out', 30])], [({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 8, 'gap': 4, 'max_green': 43, 'actuations': [1, 2, 4, 5, 7, 9, 15, 21, 23, 27, 28, 29, 30, 31, 33, 34, 35, 37, 39, 42, 43, 45, 46, 47, 49, 51, 53, 54, 55, 58, 59], 'conflict_call': 21}, ['gap-out', 21]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 9, 'gap': 5, 'max_green': 30, 'actuations': [0, 1, 2, 3, 4, 5, 7, 10, 12, 14, 16, 17, 19, 23, 24, 26, 27, 30, 33, 34, 37, 42, 43, 46, 47, 48, 50, 51, 55, 56, 59], 'conflict_call': 14}, ['max-out', 44]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 6, 'gap': 4, 'max_green': 26, 'actuations': [0, 8, 14, 15, 22, 31, 33, 40, 50, 52, 59], 'conflict_call': 33}, ['gap-out', 33])]]
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, p, M = x['min_green'], x['gap'], x['max_green']
    exp = 0
    for a in sorted(x['actuations']):
        if a > exp and a > m:
            break
        exp = max(exp, a + p)
    gap_end = max(m, exp)
    tc = x['conflict_call']
    if tc is None:
        return ['rest', gap_end]
    tc = max(tc, 0)
    max_end = tc + M
    if exp <= max_end:
        return ['gap-out', max(gap_end, tc)]
    return ['max-out', max_end]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 8, 'gap': 3, 'max_green': 30, 'actuations': [2, 6], 'conflict_call': 20}, ['gap-out', 20]), ({'min_green': 5, 'gap': 4, 'max_green': 19, 'actuations': [1, 2, 3, 4, 5, 6, 8, 9, 11, 12, 19, 20, 25, 28, 30, 35, 36, 38, 40, 49, 59], 'conflict_call': None}, ['rest', 16]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 5, 'gap': 5, 'max_green': 43, 'actuations': [0, 2, 8, 9, 11, 24, 53], 'conflict_call': 25}, ['gap-out', 25]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15])], [({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 9, 'gap': 2, 'max_green': 19, 'actuations': [12, 17, 20, 29, 38, 40, 44], 'conflict_call': None}, ['rest', 9]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 9, 'gap': 2, 'max_green': 21, 'actuations': [59, 4, 58, 36, 53, 57, 17, 30, 23], 'conflict_call': -2}, ['gap-out', 9]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7])], [({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 10, 'gap': 3, 'max_green': 44, 'actuations': [1, 27, 56, 32, 11, 54, 44, 28, 7, 58, 37, 30, 52, 0, 47, 46, 48], 'conflict_call': 4}, ['gap-out', 10]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 8, 'gap': 3, 'max_green': 30, 'actuations': [2, 6], 'conflict_call': 20}, ['gap-out', 20]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 5, 'gap': 3, 'max_green': 29, 'actuations': [2, 4, 6, 7, 10, 11, 14, 15, 19, 20, 21, 22, 24, 27, 29, 31, 32, 33, 34, 36, 39, 42, 43, 45, 47, 48, 50, 51, 52, 53, 54, 56, 57, 58, 59], 'conflict_call': None}, ['rest', 18]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15])], [({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 10, 'gap': 5, 'max_green': 37, 'actuations': [0, 1, 3, 4, 5, 7, 10, 12, 13, 17, 19, 23, 24, 26, 30, 31, 32, 34, 36, 37, 38, 42, 44, 45, 48, 49, 50, 51, 54, 55, 56], 'conflict_call': 22}, ['max-out', 59]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 6, 'gap': 5, 'max_green': 16, 'actuations': [1, 4, 8, 10, 11, 15, 20, 25, 31, 55, 59], 'conflict_call': 14}, ['gap-out', 30]), ({'min_green': 4, 'gap': 5, 'max_green': 19, 'actuations': [22, 17, 57, 12, 39, 42, 4, 38, 9, 2, 19, 16, 6, 8, 54, 43, 30, 58, 15, 59, 3, 35, 44, 53, 28, 51, 7, 27, 55, 40, 31, 36], 'conflict_call': 30}, ['gap-out', 49]), ({'min_green': 6, 'gap': 4, 'max_green': 30, 'actuations': [0, 7, 10, 12, 13, 17, 20, 22, 25, 38, 50, 53, 54, 58, 59], 'conflict_call': None}, ['rest', 6]), ({'min_green': 7, 'gap': 3, 'max_green': 39, 'actuations': [8, 10, 12, 13, 14, 17, 22, 29, 31, 36, 42, 44, 45, 50, 52, 54, 57, 58, 59], 'conflict_call': 30}, ['gap-out', 30])], [({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 8, 'gap': 4, 'max_green': 43, 'actuations': [1, 2, 4, 5, 7, 9, 15, 21, 23, 27, 28, 29, 30, 31, 33, 34, 35, 37, 39, 42, 43, 45, 46, 47, 49, 51, 53, 54, 55, 58, 59], 'conflict_call': 21}, ['gap-out', 21]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 10, 'gap': 2, 'max_green': 3, 'actuations': [], 'conflict_call': 0}, ['max-out', 3]), ({'min_green': 9, 'gap': 5, 'max_green': 30, 'actuations': [0, 1, 2, 3, 4, 5, 7, 10, 12, 14, 16, 17, 19, 23, 24, 26, 27, 30, 33, 34, 37, 42, 43, 46, 47, 48, 50, 51, 55, 56, 59], 'conflict_call': 14}, ['max-out', 44]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 6, 'gap': 4, 'max_green': 26, 'actuations': [0, 8, 14, 15, 22, 31, 33, 40, 50, 52, 59], 'conflict_call': 33}, ['gap-out', 33])]]
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:
Actuated phase gap-out and max-out returns a wrong result when the raw passage expiry is compared with max-out.

Input {min_green, gap, max_green, actuations: integer seconds since green start (any order), conflict_call: seconds or null}. Each actuation at a keeps the phase eligible until a+gap; an actuation exactly at expiry extends; actuations during min green always extend. Gap-out time = max(min_green, final expiry). With no conflicting call return ['rest', gap time]. The max timer starts at the call (a call before green start counts as 0); max-out at call+max_green. If gap time <= max-out the phase ends by 'gap-out' at max(gap time, call), else by 'max-out'.

split: open-access


prompt:
Actuated phase gap-out and max-out returns a wrong result when a phase that gapped out before the call ends before the call arrives.

Input {min_green, gap, max_green, actuations: integer seconds since green start (any order), conflict_call: seconds or null}. Each actuation at a keeps the phase eligible until a+gap; an actuation exactly at expiry extends; actuations during min green always extend. Gap-out time = max(min_green, final expiry). With no conflicting call return ['rest', gap time]. The max timer starts at the call (a call before green start counts as 0); max-out at call+max_green. If gap time <= max-out the phase ends by 'gap-out' at max(gap time, call), else by 'max-out'.

split: open-access


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

N = 1
observations = []
def solve(x):
    m, p, M = x['min_green'], x['gap'], x['max_green']
    exp = 0
    for a in sorted(x['actuations']):
        if a > exp and a > m:
            break
        exp = max(exp, a + p - 1)
    gap_end = max(m, exp)
    tc = x['conflict_call']
    if tc is None:
        return ['rest', gap_end]
    tc = max(tc, 0)
    max_end = tc + M
    if gap_end <= max_end:
        return ['gap-out', max(gap_end, tc)]
    return ['max-out', max_end]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 8, 'gap': 3, 'max_green': 30, 'actuations': [2, 6], 'conflict_call': 20}, ['gap-out', 20]), ({'min_green': 9, 'gap': 2, 'max_green': 27, 'actuations': [2, 4, 6, 12, 13, 19, 22, 25, 39, 42], 'conflict_call': 8}, ['gap-out', 9]), ({'min_green': 9, 'gap': 2, 'max_green': 28, 'actuations': [1, 6, 8, 12, 14, 16, 18, 19, 21, 22, 24, 33, 34, 37, 40, 47, 50, 52, 58], 'conflict_call': 21}, ['gap-out', 21]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 8, 'gap': 3, 'max_green': 34, 'actuations': [25, 15, 18, 8, 49, 45, 14, 40, 51, 13, 33, 42, 36, 11, 58, 16, 10, 55, 3], 'conflict_call': -1}, ['gap-out', 21]), ({'min_green': 4, 'gap': 3, 'max_green': 27, 'actuations': [0, 10, 18, 20, 23, 25, 36, 39, 40, 50, 54, 58], 'conflict_call': None}, ['rest', 4]), ({'min_green': 4, 'gap': 5, 'max_green': 24, 'actuations': [4, 18, 35, 45, 48, 49], 'conflict_call': 31}, ['gap-out', 31])], [({'min_green': 6, 'gap': 5, 'max_green': 32, 'actuations': [2, 5, 6, 7, 8, 11, 12, 15, 16, 17, 19, 21, 23, 26, 27, 28, 29, 32, 35, 37, 42, 44, 45, 47, 49, 50, 52, 56, 57, 59], 'conflict_call': 25}, ['max-out', 57]), ({'min_green': 5, 'gap': 4, 'max_green': 23, 'actuations': [0, 2, 4, 16, 19, 21, 22, 24, 28, 40, 44, 45, 46, 54, 55, 57, 58], 'conflict_call': None}, ['rest', 8]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 7, 'gap': 4, 'max_green': 21, 'actuations': [3, 6, 8, 9, 11, 12, 15, 17, 19, 21, 23, 25, 28, 33, 34, 35, 39, 47, 52, 54, 56, 58, 59], 'conflict_call': 7}, ['max-out', 28]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 4, 'gap': 4, 'max_green': 15, 'actuations': [1, 2, 4, 6, 11, 13, 15, 19, 20, 22, 23, 26, 27, 37, 41, 44, 47, 48, 50, 52, 53, 54, 56, 58, 59], 'conflict_call': 26}, ['gap-out', 26]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 8, 'gap': 5, 'max_green': 16, 'actuations': [2, 17, 23, 41, 50, 54, 57, 59], 'conflict_call': -2}, ['gap-out', 8])], [({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 6, 'gap': 2, 'max_green': 29, 'actuations': [0, 1, 2, 3, 7, 8, 9, 10, 11, 12, 16, 17, 19, 24, 27, 29, 32, 34, 36, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 53, 56, 58, 59], 'conflict_call': -3}, ['gap-out', 6]), ({'min_green': 4, 'gap': 5, 'max_green': 22, 'actuations': [1, 2, 8, 11, 18, 20, 24, 26, 35, 37, 39, 45, 47, 50, 51, 54, 55, 56, 57, 59], 'conflict_call': 31}, ['gap-out', 31]), ({'min_green': 7, 'gap': 5, 'max_green': 42, 'actuations': [1, 3, 5, 8, 10, 29, 33, 38, 42, 44, 50, 53, 55], 'conflict_call': -5}, ['gap-out', 15]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 7, 'gap': 4, 'max_green': 34, 'actuations': [49, 44, 18, 9, 59, 20, 16, 5, 26, 24, 37, 54, 32, 3, 27, 6, 15, 53, 28, 57, 52, 47, 46, 19, 38, 51, 58, 23, 40, 30], 'conflict_call': 24}, ['gap-out', 24]), ({'min_green': 5, 'gap': 5, 'max_green': 30, 'actuations': [3, 12, 14, 28, 29, 34, 37, 42, 44, 45, 48, 52, 54, 56, 59], 'conflict_call': None}, ['rest', 8]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7])], [({'min_green': 10, 'gap': 2, 'max_green': 15, 'actuations': [2, 5, 6, 8, 9, 14, 15, 17, 18, 22, 25, 26, 30, 31, 33, 36, 40, 42, 50], 'conflict_call': 6}, ['gap-out', 11]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 4, 'gap': 5, 'max_green': 25, 'actuations': [1, 9, 10, 12, 13, 14, 15, 16, 17, 21, 24, 26, 27, 29, 30, 36, 37, 38, 41, 42, 43, 46, 47, 48, 49, 51, 53, 55, 58], 'conflict_call': 10}, ['gap-out', 10]), ({'min_green': 7, 'gap': 3, 'max_green': 15, 'actuations': [54, 34, 26, 11, 41, 56, 5], 'conflict_call': 10}, ['gap-out', 10]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 4, 'gap': 3, 'max_green': 19, 'actuations': [0, 4, 7, 8, 13, 15, 17, 18, 21, 22, 23, 26, 28, 29, 30, 33, 35, 37, 41, 43, 45, 46, 47, 49, 50, 53, 56, 57], 'conflict_call': 30}, ['gap-out', 30]), ({'min_green': 4, 'gap': 3, 'max_green': 45, 'actuations': [0, 4, 5, 6, 8, 16, 17, 22, 23, 27, 31, 39, 40, 42, 45, 47, 48, 52, 54, 58], 'conflict_call': 27}, ['gap-out', 27])], [({'min_green': 4, 'gap': 2, 'max_green': 32, 'actuations': [10, 16, 21, 24, 25, 27, 30, 34, 39, 42, 49, 50, 52, 53, 56], 'conflict_call': 9}, ['gap-out', 9]), ({'min_green': 4, 'gap': 3, 'max_green': 31, 'actuations': [14, 21, 44, 47], 'conflict_call': 0}, ['gap-out', 4]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 10, 'gap': 3, 'max_green': 39, 'actuations': [1, 2, 3, 4, 5, 8, 9, 11, 13, 15, 16, 17, 20, 21, 23, 29, 31, 32, 35, 36, 37, 42, 44, 45, 47, 48, 52, 55, 56, 59], 'conflict_call': 12}, ['gap-out', 26]), ({'min_green': 9, 'gap': 4, 'max_green': 29, 'actuations': [2, 4, 7, 17, 23, 25, 27, 36, 37, 45, 50], 'conflict_call': None}, ['rest', 11]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 8, 'gap': 2, 'max_green': 31, 'actuations': [2, 11, 12, 14, 15, 27, 37, 41, 46, 49], 'conflict_call': None}, ['rest', 8])]]
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, p, M = x['min_green'], x['gap'], x['max_green']
    exp = 0
    for a in sorted(x['actuations']):
        if a > exp and a > m:
            break
        exp = max(exp, max(a, m) + p)
    gap_end = max(m, exp)
    tc = x['conflict_call']
    if tc is None:
        return ['rest', gap_end]
    tc = max(tc, 0)
    max_end = tc + M
    if gap_end <= max_end:
        return ['gap-out', max(gap_end, tc)]
    return ['max-out', max_end]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 8, 'gap': 3, 'max_green': 30, 'actuations': [2, 6], 'conflict_call': 20}, ['gap-out', 20]), ({'min_green': 9, 'gap': 2, 'max_green': 27, 'actuations': [2, 4, 6, 12, 13, 19, 22, 25, 39, 42], 'conflict_call': 8}, ['gap-out', 9]), ({'min_green': 9, 'gap': 2, 'max_green': 28, 'actuations': [1, 6, 8, 12, 14, 16, 18, 19, 21, 22, 24, 33, 34, 37, 40, 47, 50, 52, 58], 'conflict_call': 21}, ['gap-out', 21]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 8, 'gap': 3, 'max_green': 34, 'actuations': [25, 15, 18, 8, 49, 45, 14, 40, 51, 13, 33, 42, 36, 11, 58, 16, 10, 55, 3], 'conflict_call': -1}, ['gap-out', 21]), ({'min_green': 4, 'gap': 3, 'max_green': 27, 'actuations': [0, 10, 18, 20, 23, 25, 36, 39, 40, 50, 54, 58], 'conflict_call': None}, ['rest', 4]), ({'min_green': 4, 'gap': 5, 'max_green': 24, 'actuations': [4, 18, 35, 45, 48, 49], 'conflict_call': 31}, ['gap-out', 31])], [({'min_green': 6, 'gap': 5, 'max_green': 32, 'actuations': [2, 5, 6, 7, 8, 11, 12, 15, 16, 17, 19, 21, 23, 26, 27, 28, 29, 32, 35, 37, 42, 44, 45, 47, 49, 50, 52, 56, 57, 59], 'conflict_call': 25}, ['max-out', 57]), ({'min_green': 5, 'gap': 4, 'max_green': 23, 'actuations': [0, 2, 4, 16, 19, 21, 22, 24, 28, 40, 44, 45, 46, 54, 55, 57, 58], 'conflict_call': None}, ['rest', 8]), ({'min_green': 5, 'gap': 3, 'max_green': 10, 'actuations': [0, 3, 6, 9, 12], 'conflict_call': 5}, ['gap-out', 15]), ({'min_green': 7, 'gap': 4, 'max_green': 21, 'actuations': [3, 6, 8, 9, 11, 12, 15, 17, 19, 21, 23, 25, 28, 33, 34, 35, 39, 47, 52, 54, 56, 58, 59], 'conflict_call': 7}, ['max-out', 28]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 4, 'gap': 4, 'max_green': 15, 'actuations': [1, 2, 4, 6, 11, 13, 15, 19, 20, 22, 23, 26, 27, 37, 41, 44, 47, 48, 50, 52, 53, 54, 56, 58, 59], 'conflict_call': 26}, ['gap-out', 26]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 8, 'gap': 5, 'max_green': 16, 'actuations': [2, 17, 23, 41, 50, 54, 57, 59], 'conflict_call': -2}, ['gap-out', 8])], [({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 6, 'gap': 2, 'max_green': 29, 'actuations': [0, 1, 2, 3, 7, 8, 9, 10, 11, 12, 16, 17, 19, 24, 27, 29, 32, 34, 36, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 53, 56, 58, 59], 'conflict_call': -3}, ['gap-out', 6]), ({'min_green': 4, 'gap': 5, 'max_green': 22, 'actuations': [1, 2, 8, 11, 18, 20, 24, 26, 35, 37, 39, 45, 47, 50, 51, 54, 55, 56, 57, 59], 'conflict_call': 31}, ['gap-out', 31]), ({'min_green': 7, 'gap': 5, 'max_green': 42, 'actuations': [1, 3, 5, 8, 10, 29, 33, 38, 42, 44, 50, 53, 55], 'conflict_call': -5}, ['gap-out', 15]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 7, 'gap': 4, 'max_green': 34, 'actuations': [49, 44, 18, 9, 59, 20, 16, 5, 26, 24, 37, 54, 32, 3, 27, 6, 15, 53, 28, 57, 52, 47, 46, 19, 38, 51, 58, 23, 40, 30], 'conflict_call': 24}, ['gap-out', 24]), ({'min_green': 5, 'gap': 5, 'max_green': 30, 'actuations': [3, 12, 14, 28, 29, 34, 37, 42, 44, 45, 48, 52, 54, 56, 59], 'conflict_call': None}, ['rest', 8]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7])], [({'min_green': 10, 'gap': 2, 'max_green': 15, 'actuations': [2, 5, 6, 8, 9, 14, 15, 17, 18, 22, 25, 26, 30, 31, 33, 36, 40, 42, 50], 'conflict_call': 6}, ['gap-out', 11]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 4, 'gap': 5, 'max_green': 25, 'actuations': [1, 9, 10, 12, 13, 14, 15, 16, 17, 21, 24, 26, 27, 29, 30, 36, 37, 38, 41, 42, 43, 46, 47, 48, 49, 51, 53, 55, 58], 'conflict_call': 10}, ['gap-out', 10]), ({'min_green': 7, 'gap': 3, 'max_green': 15, 'actuations': [54, 34, 26, 11, 41, 56, 5], 'conflict_call': 10}, ['gap-out', 10]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 6, 'gap': 2, 'max_green': 12, 'actuations': [1, 3, 5, 7, 9, 11, 13], 'conflict_call': 3}, ['gap-out', 15]), ({'min_green': 4, 'gap': 3, 'max_green': 19, 'actuations': [0, 4, 7, 8, 13, 15, 17, 18, 21, 22, 23, 26, 28, 29, 30, 33, 35, 37, 41, 43, 45, 46, 47, 49, 50, 53, 56, 57], 'conflict_call': 30}, ['gap-out', 30]), ({'min_green': 4, 'gap': 3, 'max_green': 45, 'actuations': [0, 4, 5, 6, 8, 16, 17, 22, 23, 27, 31, 39, 40, 42, 45, 47, 48, 52, 54, 58], 'conflict_call': 27}, ['gap-out', 27])], [({'min_green': 4, 'gap': 2, 'max_green': 32, 'actuations': [10, 16, 21, 24, 25, 27, 30, 34, 39, 42, 49, 50, 52, 53, 56], 'conflict_call': 9}, ['gap-out', 9]), ({'min_green': 4, 'gap': 3, 'max_green': 31, 'actuations': [14, 21, 44, 47], 'conflict_call': 0}, ['gap-out', 4]), ({'min_green': 12, 'gap': 3, 'max_green': 5, 'actuations': [1], 'conflict_call': 2}, ['max-out', 7]), ({'min_green': 6, 'gap': 2, 'max_green': 15, 'actuations': [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38], 'conflict_call': -3}, ['max-out', 15]), ({'min_green': 10, 'gap': 3, 'max_green': 39, 'actuations': [1, 2, 3, 4, 5, 8, 9, 11, 13, 15, 16, 17, 20, 21, 23, 29, 31, 32, 35, 36, 37, 42, 44, 45, 47, 48, 52, 55, 56, 59], 'conflict_call': 12}, ['gap-out', 26]), ({'min_green': 9, 'gap': 4, 'max_green': 29, 'actuations': [2, 4, 7, 17, 23, 25, 27, 36, 37, 45, 50], 'conflict_call': None}, ['rest', 11]), ({'min_green': 5, 'gap': 3, 'max_green': 20, 'actuations': [1, 4, 7, 10, 13], 'conflict_call': 2}, ['gap-out', 16]), ({'min_green': 8, 'gap': 2, 'max_green': 31, 'actuations': [2, 11, 12, 14, 15, 27, 37, 41, 46, 49], 'conflict_call': None}, ['rest', 8])]]
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:
Actuated phase gap-out and max-out returns a wrong result when the passage timer is started only after min green.

Input {min_green, gap, max_green, actuations: integer seconds since green start (any order), conflict_call: seconds or null}. Each actuation at a keeps the phase eligible until a+gap; an actuation exactly at expiry extends; actuations during min green always extend. Gap-out time = max(min_green, final expiry). With no conflicting call return ['rest', gap time]. The max timer starts at the call (a call before green start counts as 0); max-out at call+max_green. If gap time <= max-out the phase ends by 'gap-out' at max(gap time, call), else by 'max-out'.

split: open-access


prompt:
Actuated phase gap-out and max-out returns a wrong result when the max timer is started at the end of min green.

Input {min_green, gap, max_green, actuations: integer seconds since green start (any order), conflict_call: seconds or null}. Each actuation at a keeps the phase eligible until a+gap; an actuation exactly at expiry extends; actuations during min green always extend. Gap-out time = max(min_green, final expiry). With no conflicting call return ['rest', gap time]. The max timer starts at the call (a call before green start counts as 0); max-out at call+max_green. If gap time <= max-out the phase ends by 'gap-out' at max(gap time, call), else by 'max-out'.

split: open-access


prompt:
Actuated phase gap-out and max-out returns a wrong result when a phase without a conflicting call reports a gap-out.

Input {min_green, gap, max_green, actuations: integer seconds since green start (any order), conflict_call: seconds or null}. Each actuation at a keeps the phase eligible until a+gap; an actuation exactly at expiry extends; actuations during min green always extend. Gap-out time = max(min_green, final expiry). With no conflicting call return ['rest', gap time]. The max timer starts at the call (a call before green start counts as 0); max-out at call+max_green. If gap time <= max-out the phase ends by 'gap-out' at max(gap time, call), else by 'max-out'.

split: open-access