broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    v = Fraction(x['speed_mph']) * Fraction(1467, 1000)
    t = Fraction(x['reaction_tenths'], 10)
    den = 2 * x['decel'] + 2 * Fraction(322, 10) * Fraction(x['grade_pct'], 100)
    if den <= 0:
        return 'invalid'
    yl = max(30, min(60, math.ceil((t + v / den) * 10)))
    w = x['width_ft'] + (x['crosswalk_ft'] if not x['ped'] else 0)
    rd = max(10, min(60, math.ceil((w + x['veh_len_ft']) / v * 10)))
    return {'yellow_tenths': yl, 'red_tenths': rd}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 55, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 93, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 44, 'red_tenths': 16}), ({'speed_mph': 65, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 61, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 45, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 62, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 49, 'red_tenths': 10})], [({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 50, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 45, 'red_tenths': 17}), ({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 41, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 53, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 57, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 70, 'grade_pct': 4, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 54, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 58, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19})], [({'speed_mph': 30, 'grade_pct': 5, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 20}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 60, 'grade_pct': -6, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 40, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': -6, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 55, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': 7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 56, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 47, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 44, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 54, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16})], [({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 124, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 40, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 41, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 20, 'grade_pct': -2, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 114, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 31, 'red_tenths': 51}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 20, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 135, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 60, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 57, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 65, 'grade_pct': 6, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 80, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 12}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 69, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 58, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': -6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 66, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 23}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 70, 'grade_pct': 6, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 46, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 59, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 48, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10})]]
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):
    v = Fraction(x['speed_mph']) * Fraction(1467, 1000)
    t = Fraction(x['reaction_tenths'], 10)
    den = 2 * x['decel'] + 2 * Fraction(322, 10) * Fraction(x['grade_pct'], 100)
    if den <= 0:
        return 'invalid'
    yl = max(30, min(60, math.ceil((t + v / den) * 10)))
    w = x['width_ft'] + (x['crosswalk_ft'] // 2 if x['ped'] else 0)
    rd = max(10, min(60, math.ceil((w + x['veh_len_ft']) / v * 10)))
    return {'yellow_tenths': yl, 'red_tenths': rd}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 55, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 93, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 44, 'red_tenths': 16}), ({'speed_mph': 65, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 61, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 45, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 62, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 49, 'red_tenths': 10})], [({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 50, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 45, 'red_tenths': 17}), ({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 41, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 53, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 57, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 70, 'grade_pct': 4, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 54, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 58, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19})], [({'speed_mph': 30, 'grade_pct': 5, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 20}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 60, 'grade_pct': -6, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 40, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': -6, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 55, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': 7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 56, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 47, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 44, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 54, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16})], [({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 124, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 40, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 41, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 20, 'grade_pct': -2, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 114, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 31, 'red_tenths': 51}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 20, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 135, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 60, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 57, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 65, 'grade_pct': 6, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 80, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 12}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 69, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 58, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': -6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 66, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 23}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 70, 'grade_pct': 6, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 46, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 59, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 48, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10})]]
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:
Yellow and all-red intervals returns a wrong result when the far crosswalk is added when no pedestrians are present.

Input {speed_mph, grade_pct (uphill positive), reaction_tenths, decel ft/s^2, width_ft, veh_len_ft, crosswalk_ft, ped}. v = 1.467*speed ft/s; yellow = t + v/(2a + 2*32.2*grade/100), rounded UP to 0.1 s and clamped to [3.0, 6.0]; a non-positive denominator returns 'invalid'. All-red = (W + vehicle length)/v where W includes the far crosswalk when ped is true, rounded UP to 0.1 s and clamped to [1.0, 6.0]. Return tenths.

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):
    v = Fraction(x['speed_mph']) * Fraction(1467, 1000)
    t = Fraction(x['reaction_tenths'], 10)
    den = 2 * x['decel'] + 2 * Fraction(322, 10) * Fraction(x['grade_pct'], 100)
    if den <= 0:
        return 'invalid'
    yl = max(30, min(60, math.ceil((t + v / den) * 10)))
    w = x['width_ft'] + (x['crosswalk_ft'] if x['ped'] else 0)
    rd = max(10, min(60, math.ceil(w / v * 10)))
    return {'yellow_tenths': yl, 'red_tenths': rd}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'speed_mph': 45, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 127, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 34, 'red_tenths': 26}), ({'speed_mph': 65, 'grade_pct': -4, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 56, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -3, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 45, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -1, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 78, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 49, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 50, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 76, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 42, 'red_tenths': 14}), ({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 58, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 75, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 42, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 50, 'grade_pct': 0, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 43, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 46, 'red_tenths': 10})], [({'speed_mph': 70, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 56, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -5, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 43, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 118, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 37, 'red_tenths': 19}), ({'speed_mph': 40, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 41, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 38, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 68, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 10})], [({'speed_mph': 45, 'grade_pct': 6, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 43, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 72, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 136, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 25}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 48, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 60, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 59, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 60, 'grade_pct': 3, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 50, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 70, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 47, 'red_tenths': 10}), ({'speed_mph': 55, 'grade_pct': -4, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 44, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 46, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -5, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 45, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 45, 'grade_pct': -3, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 112, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 55, 'red_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)

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):
    v = Fraction(x['speed_mph']) * Fraction(1467, 1000)
    t = Fraction(x['reaction_tenths'], 10)
    den = 2 * x['decel'] + 2 * Fraction(322, 10) * Fraction(x['grade_pct'], 100)
    if den <= 0:
        return 'invalid'
    yl = max(30, min(60, math.ceil((t + v / den) * 10)))
    w = x['width_ft'] + (x['crosswalk_ft'] if x['ped'] else 0)
    rd = max(10, min(60, math.ceil((w + x['veh_len_ft'] // 2) / v * 10)))
    return {'yellow_tenths': yl, 'red_tenths': rd}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'speed_mph': 45, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 127, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 34, 'red_tenths': 26}), ({'speed_mph': 65, 'grade_pct': -4, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 56, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -3, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 45, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -1, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 78, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 49, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 50, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 76, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 42, 'red_tenths': 14}), ({'speed_mph': 65, 'grade_pct': 2, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 58, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 75, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 42, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 50, 'grade_pct': 0, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 43, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 46, 'red_tenths': 10})], [({'speed_mph': 70, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 56, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -5, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 43, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 118, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 37, 'red_tenths': 19}), ({'speed_mph': 40, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 41, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 38, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 68, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 10})], [({'speed_mph': 45, 'grade_pct': 6, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 43, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 72, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 136, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 25}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 48, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 60, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 59, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 60, 'grade_pct': 3, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 50, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 120, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 16}), ({'speed_mph': 30, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 60, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 19}), ({'speed_mph': 70, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 47, 'red_tenths': 10}), ({'speed_mph': 55, 'grade_pct': -4, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 44, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 46, 'red_tenths': 10}), ({'speed_mph': 70, 'grade_pct': -5, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 45, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 45, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 80, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 17}), ({'speed_mph': 45, 'grade_pct': -3, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 112, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 55, 'red_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:
Yellow and all-red intervals returns a wrong result when all-red ignores the vehicle length.

Input {speed_mph, grade_pct (uphill positive), reaction_tenths, decel ft/s^2, width_ft, veh_len_ft, crosswalk_ft, ped}. v = 1.467*speed ft/s; yellow = t + v/(2a + 2*32.2*grade/100), rounded UP to 0.1 s and clamped to [3.0, 6.0]; a non-positive denominator returns 'invalid'. All-red = (W + vehicle length)/v where W includes the far crosswalk when ped is true, rounded UP to 0.1 s and clamped to [1.0, 6.0]. Return tenths.

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': 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': 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': 27, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 38}, {'walk': 5, 'fdw': 9, 'green': 10, 'fits': True}), ({'crossing_ft': 110, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 40}, {'walk': 7, 'fdw': 32, 'green': 34, 'fits': True}), ({'crossing_ft': 42, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 41}, {'walk': 5, 'fdw': 11, 'green': 11, 'fits': True}), ({'crossing_ft': 74, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 18}, {'walk': 7, 'fdw': 25, 'green': 27, 'fits': False}), ({'crossing_ft': 89, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 43}, {'walk': 10, 'fdw': 26, 'green': 8, 'fits': True})], [({'crossing_ft': 41, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 41}, {'walk': 7, 'fdw': 11, 'green': 12, 'fits': True}), ({'crossing_ft': 33, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 42}, {'walk': 7, 'fdw': 10, 'green': 12, 'fits': True}), ({'crossing_ft': 37, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': False, 'split': 39}, {'walk': 7, 'fdw': 11, 'green': 15, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 29}, {'walk': 10, 'fdw': 11, 'green': 16, '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': 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': 84, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 26}, {'walk': 10, 'fdw': 24, 'green': 28, 'fits': False})], [({'crossing_ft': 79, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 21}, {'walk': 7, 'fdw': 23, 'green': 8, 'fits': True}), ({'crossing_ft': 109, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 31}, {'walk': 7, 'fdw': 32, 'green': 10, 'fits': True}), ({'crossing_ft': 40, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 39}, {'walk': 4, 'fdw': 12, 'green': 12, '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': 24, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 30}, {'walk': 10, 'fdw': 7, 'green': 12, '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': 107, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 40}, {'walk': 10, 'fdw': 36, 'green': 41, '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': 34, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 38}, {'walk': 7, 'fdw': 10, 'green': 13, 'fits': True}), ({'crossing_ft': 75, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 36}, {'walk': 5, 'fdw': 25, 'green': 25, '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': 96, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 21}, {'walk': 6, 'fdw': 28, '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': 81, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 10, 'fdw': 24, 'green': 30, 'fits': False}), ({'crossing_ft': 45, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 41}, {'walk': 7, 'fdw': 13, 'green': 5, 'fits': True})], [({'crossing_ft': 65, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 40}, {'walk': 5, 'fdw': 19, 'green': 19, 'fits': True}), ({'crossing_ft': 87, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 38}, {'walk': 10, 'fdw': 25, 'green': 30, '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': 85, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 28}, {'walk': 5, 'fdw': 29, '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': 92, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 34}, {'walk': 7, 'fdw': 27, 'green': 29, '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': 64, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 21}, {'walk': 4, 'fdw': 22, 'green': 21, 'fits': False})]]
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'] // 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': 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': 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': 27, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 38}, {'walk': 5, 'fdw': 9, 'green': 10, 'fits': True}), ({'crossing_ft': 110, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 40}, {'walk': 7, 'fdw': 32, 'green': 34, 'fits': True}), ({'crossing_ft': 42, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 41}, {'walk': 5, 'fdw': 11, 'green': 11, 'fits': True}), ({'crossing_ft': 74, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 18}, {'walk': 7, 'fdw': 25, 'green': 27, 'fits': False}), ({'crossing_ft': 89, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 43}, {'walk': 10, 'fdw': 26, 'green': 8, 'fits': True})], [({'crossing_ft': 41, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 41}, {'walk': 7, 'fdw': 11, 'green': 12, 'fits': True}), ({'crossing_ft': 33, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 42}, {'walk': 7, 'fdw': 10, 'green': 12, 'fits': True}), ({'crossing_ft': 37, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': False, 'split': 39}, {'walk': 7, 'fdw': 11, 'green': 15, 'fits': True}), ({'crossing_ft': 36, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 29}, {'walk': 10, 'fdw': 11, 'green': 16, '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': 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': 84, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 26}, {'walk': 10, 'fdw': 24, 'green': 28, 'fits': False})], [({'crossing_ft': 79, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 21}, {'walk': 7, 'fdw': 23, 'green': 8, 'fits': True}), ({'crossing_ft': 109, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 31}, {'walk': 7, 'fdw': 32, 'green': 10, 'fits': True}), ({'crossing_ft': 40, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 39}, {'walk': 4, 'fdw': 12, 'green': 12, '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': 24, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 30}, {'walk': 10, 'fdw': 7, 'green': 12, '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': 107, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 40}, {'walk': 10, 'fdw': 36, 'green': 41, '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': 34, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 38}, {'walk': 7, 'fdw': 10, 'green': 13, 'fits': True}), ({'crossing_ft': 75, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 36}, {'walk': 5, 'fdw': 25, 'green': 25, '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': 96, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 21}, {'walk': 6, 'fdw': 28, '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': 81, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 30}, {'walk': 10, 'fdw': 24, 'green': 30, 'fits': False}), ({'crossing_ft': 45, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 41}, {'walk': 7, 'fdw': 13, 'green': 5, 'fits': True})], [({'crossing_ft': 65, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 40}, {'walk': 5, 'fdw': 19, 'green': 19, 'fits': True}), ({'crossing_ft': 87, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 38}, {'walk': 10, 'fdw': 25, 'green': 30, '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': 85, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 28}, {'walk': 5, 'fdw': 29, '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': 92, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 34}, {'walk': 7, 'fdw': 27, 'green': 29, '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': 64, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 21}, {'walk': 4, 'fdw': 22, 'green': 21, 'fits': False})]]
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 the flashing dont walk interval is truncated.

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'] * 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': 53, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 43}, {'walk': 7, 'fdw': 16, 'green': 19, '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': 85, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 26}, {'walk': 6, 'fdw': 25, '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': 74, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 41}, {'walk': 4, 'fdw': 25, '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': 58, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 31}, {'walk': 7, 'fdw': 17, 'green': 18, 'fits': True}), ({'crossing_ft': 49, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 19}, {'walk': 5, 'fdw': 14, '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}), ({'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': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 39}, {'walk': 10, 'fdw': 17, 'green': 10, 'fits': True}), ({'crossing_ft': 78, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 42}, {'walk': 8, 'fdw': 20, 'green': 10, 'fits': True}), ({'crossing_ft': 49, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 15, 'ped_call': False, 'split': 30}, {'walk': 5, 'fdw': 17, 'green': 15, 'fits': True}), ({'crossing_ft': 104, 'walk_speed_tenths': 40, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 27}, {'walk': 11, 'fdw': 26, 'green': 5, 'fits': True}), ({'crossing_ft': 45, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 33}, {'walk': 4, 'fdw': 15, 'green': 15, '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': 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': 66, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 25}, {'walk': 7, 'fdw': 19, 'green': 21, 'fits': False}), ({'crossing_ft': 73, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 33}, {'walk': 7, 'fdw': 25, 'green': 27, 'fits': True}), ({'crossing_ft': 87, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 24}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': False}), ({'crossing_ft': 100, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 35}, {'walk': 10, 'fdw': 29, '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': 36, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 17}, {'walk': 5, 'fdw': 9, 'green': 5, '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': 100, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 25}, {'walk': 10, 'fdw': 34, 'green': 10, 'fits': True}), ({'crossing_ft': 55, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 25}, {'walk': 7, 'fdw': 14, 'green': 15, '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': 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': 30, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 32}, {'walk': 7, 'fdw': 9, 'green': 11, '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': 69, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': False, 'split': 31}, {'walk': 10, 'fdw': 20, 'green': 15, 'fits': True}), ({'crossing_ft': 92, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 22}, {'walk': 6, 'fdw': 27, 'green': 27, 'fits': False})], [({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 44}, {'walk': 7, 'fdw': 26, 'green': 28, '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': 68, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 15, 'ped_call': False, 'split': 20}, {'walk': 10, 'fdw': 20, 'green': 15, 'fits': True}), ({'crossing_ft': 85, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 40}, {'walk': 9, 'fdw': 22, 'green': 5, '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': 47, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 18}, {'walk': 10, 'fdw': 16, 'green': 21, 'fits': False}), ({'crossing_ft': 80, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 43}, {'walk': 6, 'fdw': 23, 'green': 23, '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'] + 3) * 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': 53, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': True, 'split': 43}, {'walk': 7, 'fdw': 16, 'green': 19, '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': 85, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 26}, {'walk': 6, 'fdw': 25, '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': 74, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 8, 'ped_call': False, 'split': 41}, {'walk': 4, 'fdw': 25, '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': 58, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 31}, {'walk': 7, 'fdw': 17, 'green': 18, 'fits': True}), ({'crossing_ft': 49, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 19}, {'walk': 5, 'fdw': 14, '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}), ({'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': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 39}, {'walk': 10, 'fdw': 17, 'green': 10, 'fits': True}), ({'crossing_ft': 78, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 42}, {'walk': 8, 'fdw': 20, 'green': 10, 'fits': True}), ({'crossing_ft': 49, 'walk_speed_tenths': 30, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 15, 'ped_call': False, 'split': 30}, {'walk': 5, 'fdw': 17, 'green': 15, 'fits': True}), ({'crossing_ft': 104, 'walk_speed_tenths': 40, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 5, 'ped_call': False, 'split': 27}, {'walk': 11, 'fdw': 26, 'green': 5, 'fits': True}), ({'crossing_ft': 45, 'walk_speed_tenths': 30, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 33}, {'walk': 4, 'fdw': 15, 'green': 15, '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': 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': 66, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 25}, {'walk': 7, 'fdw': 19, 'green': 21, 'fits': False}), ({'crossing_ft': 73, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 33}, {'walk': 7, 'fdw': 25, 'green': 27, 'fits': True}), ({'crossing_ft': 87, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 24}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': False}), ({'crossing_ft': 100, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 35}, {'walk': 10, 'fdw': 29, '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': 36, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 5, 'ped_call': False, 'split': 17}, {'walk': 5, 'fdw': 9, 'green': 5, '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': 100, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 35, 'red_tenths': 10, 'min_green': 10, 'ped_call': False, 'split': 25}, {'walk': 10, 'fdw': 34, 'green': 10, 'fits': True}), ({'crossing_ft': 55, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 25}, {'walk': 7, 'fdw': 14, 'green': 15, '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': 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': 30, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 32}, {'walk': 7, 'fdw': 9, 'green': 11, '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': 69, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': False, 'split': 31}, {'walk': 10, 'fdw': 20, 'green': 15, 'fits': True}), ({'crossing_ft': 92, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 22}, {'walk': 6, 'fdw': 27, 'green': 27, 'fits': False})], [({'crossing_ft': 91, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 44}, {'walk': 7, 'fdw': 26, 'green': 28, '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': 68, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 15, 'ped_call': False, 'split': 20}, {'walk': 10, 'fdw': 20, 'green': 15, 'fits': True}), ({'crossing_ft': 85, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 40}, {'walk': 9, 'fdw': 22, 'green': 5, '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': 47, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 15, 'ped_call': True, 'split': 18}, {'walk': 10, 'fdw': 16, 'green': 21, 'fits': False}), ({'crossing_ft': 80, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 43}, {'walk': 6, 'fdw': 23, 'green': 23, '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 the total-crossing check omits the pushbutton setback.

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 // sp)
    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': 110, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 19}, {'walk': 7, 'fdw': 32, 'green': 10, 'fits': True}), ({'crossing_ft': 42, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 17}, {'walk': 7, 'fdw': 12, 'green': 14, 'fits': False}), ({'crossing_ft': 45, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 27}, {'walk': 7, 'fdw': 15, 'green': 18, 'fits': True}), ({'crossing_ft': 76, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 27}, {'walk': 6, 'fdw': 22, 'green': 23, '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': 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': 41, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 5, 'fdw': 11, 'green': 11, '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': 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': 102, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 27}, {'walk': 7, 'fdw': 34, 'green': 35, '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': 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': 88, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 16}, {'walk': 6, 'fdw': 26, 'green': 28, 'fits': False}), ({'crossing_ft': 83, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 15}, {'walk': 6, 'fdw': 24, 'green': 10, 'fits': False}), ({'crossing_ft': 45, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 29}, {'walk': 7, 'fdw': 13, 'green': 5, 'fits': True}), ({'crossing_ft': 56, 'walk_speed_tenths': 35, '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': 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': 83, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 25}, {'walk': 6, 'fdw': 24, 'green': 10, 'fits': True}), ({'crossing_ft': 86, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 24}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': False}), ({'crossing_ft': 94, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 28}, {'walk': 10, 'fdw': 27, 'green': 32, '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': 90, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 33}, {'walk': 10, 'fdw': 26, 'green': 8, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 10, 'fdw': 31, 'green': 37, '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': 88, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 35}, {'walk': 10, 'fdw': 22, 'green': 27, 'fits': True}), ({'crossing_ft': 67, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 32}, {'walk': 8, 'fdw': 17, 'green': 19, 'fits': True}), ({'crossing_ft': 72, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 45}, {'walk': 7, 'fdw': 21, 'green': 22, 'fits': True}), ({'crossing_ft': 25, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 24}, {'walk': 7, 'fdw': 8, 'green': 15, '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': 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': 77, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 17}, {'walk': 6, 'fdw': 22, 'green': 23, 'fits': False})], [({'crossing_ft': 67, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 26}, {'walk': 10, 'fdw': 20, 'green': 24, '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': 28, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 43}, {'walk': 10, 'fdw': 10, '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': 79, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 21}, {'walk': 6, 'fdw': 23, 'green': 24, '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': 38, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 37}, {'walk': 7, 'fdw': 11, 'green': 13, 'fits': True}), ({'crossing_ft': 107, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 20}, {'walk': 7, 'fdw': 31, 'green': 32, 'fits': False})]]
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 // 35)
    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': 110, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 19}, {'walk': 7, 'fdw': 32, 'green': 10, 'fits': True}), ({'crossing_ft': 42, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 17}, {'walk': 7, 'fdw': 12, 'green': 14, 'fits': False}), ({'crossing_ft': 45, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 30, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 27}, {'walk': 7, 'fdw': 15, 'green': 18, 'fits': True}), ({'crossing_ft': 76, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 27}, {'walk': 6, 'fdw': 22, 'green': 23, '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': 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': 41, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 10, 'ped_call': True, 'split': 20}, {'walk': 5, 'fdw': 11, 'green': 11, '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': 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': 102, 'walk_speed_tenths': 30, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 27}, {'walk': 7, 'fdw': 34, 'green': 35, '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': 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': 88, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 16}, {'walk': 6, 'fdw': 26, 'green': 28, 'fits': False}), ({'crossing_ft': 83, 'walk_speed_tenths': 35, 'min_walk': 5, 'yellow_tenths': 40, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 15}, {'walk': 6, 'fdw': 24, 'green': 10, 'fits': False}), ({'crossing_ft': 45, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 5, 'ped_call': False, 'split': 29}, {'walk': 7, 'fdw': 13, 'green': 5, 'fits': True}), ({'crossing_ft': 56, 'walk_speed_tenths': 35, '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': 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': 83, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': False, 'split': 25}, {'walk': 6, 'fdw': 24, 'green': 10, 'fits': True}), ({'crossing_ft': 86, 'walk_speed_tenths': 40, 'min_walk': 7, 'yellow_tenths': 45, 'red_tenths': 10, 'min_green': 8, 'ped_call': True, 'split': 24}, {'walk': 9, 'fdw': 22, 'green': 26, 'fits': False}), ({'crossing_ft': 94, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 28}, {'walk': 10, 'fdw': 27, 'green': 32, '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': 90, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 8, 'ped_call': False, 'split': 33}, {'walk': 10, 'fdw': 26, 'green': 8, 'fits': True}), ({'crossing_ft': 91, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 15, 'min_green': 10, 'ped_call': True, 'split': 23}, {'walk': 10, 'fdw': 31, 'green': 37, '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': 88, 'walk_speed_tenths': 40, 'min_walk': 5, 'yellow_tenths': 35, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 35}, {'walk': 10, 'fdw': 22, 'green': 27, 'fits': True}), ({'crossing_ft': 67, 'walk_speed_tenths': 40, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 32}, {'walk': 8, 'fdw': 17, 'green': 19, 'fits': True}), ({'crossing_ft': 72, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 10, 'ped_call': True, 'split': 45}, {'walk': 7, 'fdw': 21, 'green': 22, 'fits': True}), ({'crossing_ft': 25, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 40, 'red_tenths': 10, 'min_green': 15, 'ped_call': True, 'split': 24}, {'walk': 7, 'fdw': 8, 'green': 15, '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': 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': 77, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 8, 'ped_call': True, 'split': 17}, {'walk': 6, 'fdw': 22, 'green': 23, 'fits': False})], [({'crossing_ft': 67, 'walk_speed_tenths': 35, 'min_walk': 10, 'yellow_tenths': 40, 'red_tenths': 20, 'min_green': 5, 'ped_call': True, 'split': 26}, {'walk': 10, 'fdw': 20, 'green': 24, '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': 28, 'walk_speed_tenths': 30, 'min_walk': 10, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 10, 'ped_call': False, 'split': 43}, {'walk': 10, 'fdw': 10, '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': 79, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 30, 'red_tenths': 20, 'min_green': 8, 'ped_call': True, 'split': 21}, {'walk': 6, 'fdw': 23, 'green': 24, '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': 38, 'walk_speed_tenths': 35, 'min_walk': 7, 'yellow_tenths': 35, 'red_tenths': 15, 'min_green': 5, 'ped_call': True, 'split': 37}, {'walk': 7, 'fdw': 11, 'green': 13, 'fits': True}), ({'crossing_ft': 107, 'walk_speed_tenths': 35, 'min_walk': 4, 'yellow_tenths': 45, 'red_tenths': 15, 'min_green': 15, 'ped_call': True, 'split': 20}, {'walk': 7, 'fdw': 31, 'green': 32, 'fits': False})]]
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 the total-crossing check reuses the clearance walking speed.

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