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(1)
    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']) / 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': 70, 'grade_pct': -3, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 108, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 13}), ({'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': 35, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 103, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 31, 'red_tenths': 27}), ({'speed_mph': 35, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 51, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 38, 'red_tenths': 16}), ({'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': 35, 'grade_pct': 5, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 105, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 25}), ({'speed_mph': 70, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 94, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 12})], [({'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': 35, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 139, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 31}), ({'speed_mph': 20, 'grade_pct': 0, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 130, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'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': 20, 'grade_pct': -5, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 138, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 20, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 52, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'speed_mph': 55, 'grade_pct': 8, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 77, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 43, 'red_tenths': 16}), ({'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': -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': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 68, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 51, 'red_tenths': 13}), ({'speed_mph': 35, 'grade_pct': -5, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 60, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 37, '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': 30, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 121, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 35}), ({'speed_mph': 30, 'grade_pct': -3, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 122, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 44, 'red_tenths': 32}), ({'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': 55, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 137, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 22})], [({'speed_mph': 20, 'grade_pct': 5, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 134, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 60, 'grade_pct': -6, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 70, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 59, 'red_tenths': 11}), ({'speed_mph': 30, 'grade_pct': -1, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 61, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 39, 'red_tenths': 21}), ({'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': 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': 50, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 68, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 44, 'red_tenths': 15}), ({'speed_mph': 30, 'grade_pct': -3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 74, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 25}), ({'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': 12, 'decel': 10, 'width_ft': 140, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 65, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 68, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 48, 'red_tenths': 10}), ({'speed_mph': 40, 'grade_pct': -8, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 134, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 50, 'red_tenths': 27}), ({'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': 50, 'grade_pct': 7, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 55, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 11}), ({'speed_mph': 25, 'grade_pct': 4, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 112, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 40})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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(447, 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']) / 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': 70, 'grade_pct': -3, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 108, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 13}), ({'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': 35, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 103, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 31, 'red_tenths': 27}), ({'speed_mph': 35, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 51, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 38, 'red_tenths': 16}), ({'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': 35, 'grade_pct': 5, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 105, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 25}), ({'speed_mph': 70, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 94, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 12})], [({'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': 35, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 139, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 31}), ({'speed_mph': 20, 'grade_pct': 0, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 130, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'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': 20, 'grade_pct': -5, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 138, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 20, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 52, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'speed_mph': 55, 'grade_pct': 8, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 77, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 43, 'red_tenths': 16}), ({'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': -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': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 68, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 51, 'red_tenths': 13}), ({'speed_mph': 35, 'grade_pct': -5, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 60, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 37, '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': 30, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 121, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 35}), ({'speed_mph': 30, 'grade_pct': -3, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 122, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 44, 'red_tenths': 32}), ({'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': 55, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 137, 'veh_len_ft': 40, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 22})], [({'speed_mph': 20, 'grade_pct': 5, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 134, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 60, 'grade_pct': -6, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 70, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 59, 'red_tenths': 11}), ({'speed_mph': 30, 'grade_pct': -1, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 61, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 39, 'red_tenths': 21}), ({'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': 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': 50, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 68, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 44, 'red_tenths': 15}), ({'speed_mph': 30, 'grade_pct': -3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 74, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 25}), ({'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': 12, 'decel': 10, 'width_ft': 140, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 60}), ({'speed_mph': 65, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 68, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 48, 'red_tenths': 10}), ({'speed_mph': 40, 'grade_pct': -8, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 134, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 50, 'red_tenths': 27}), ({'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': 50, 'grade_pct': 7, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 55, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 11}), ({'speed_mph': 25, 'grade_pct': 4, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 112, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 40})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Yellow and all-red intervals returns a wrong result when approach speed in mph is used as ft/s.

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'])
    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']) / 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': 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': 8, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 48, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 15}), ({'speed_mph': 40, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 49, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 12}), ({'speed_mph': 30, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 134, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 35}), ({'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': 50, 'grade_pct': -7, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 105, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 50, 'red_tenths': 18}), ({'speed_mph': 35, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 96, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 25}), ({'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': -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': -2, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 66, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 38, 'red_tenths': 20}), ({'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': 12, 'decel': 12, 'width_ft': 42, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 15}), ({'speed_mph': 65, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 59, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, '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': 25, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 102, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 36}), ({'speed_mph': 65, 'grade_pct': 8, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 131, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 58, 'red_tenths': 18})], [({'speed_mph': 30, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 116, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 30}), ({'speed_mph': 20, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 83, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 34, 'red_tenths': 36}), ({'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': 25, 'grade_pct': 0, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 72, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 34}), ({'speed_mph': 70, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 137, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 16}), ({'speed_mph': 20, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 100, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 45}), ({'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': -3, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 87, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 11}), ({'speed_mph': 60, 'grade_pct': -5, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 64, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 59, 'red_tenths': 12}), ({'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': 0, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 95, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 13}), ({'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': 20, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 90, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 45}), ({'speed_mph': 25, 'grade_pct': 5, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 50, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 24})], [({'speed_mph': 20, 'grade_pct': -1, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 79, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 41}), ({'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': 25, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 58, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 31, 'red_tenths': 22}), ({'speed_mph': 35, 'grade_pct': -7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 130, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 42, 'red_tenths': 32}), ({'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': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 115, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 14}), ({'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': 25, 'grade_pct': 8, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 125, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 45})]]
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(abs(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']) / 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': 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': 8, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 48, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 15}), ({'speed_mph': 40, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 49, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 12}), ({'speed_mph': 30, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 134, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 35}), ({'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': 50, 'grade_pct': -7, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 105, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 50, 'red_tenths': 18}), ({'speed_mph': 35, 'grade_pct': 3, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 96, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 25}), ({'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': -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': -2, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 66, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 38, 'red_tenths': 20}), ({'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': 12, 'decel': 12, 'width_ft': 42, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 15}), ({'speed_mph': 65, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 59, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 48, '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': 25, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 102, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 36}), ({'speed_mph': 65, 'grade_pct': 8, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 131, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 58, 'red_tenths': 18})], [({'speed_mph': 30, 'grade_pct': 2, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 116, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 30}), ({'speed_mph': 20, 'grade_pct': -4, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 83, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 34, 'red_tenths': 36}), ({'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': 25, 'grade_pct': 0, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 72, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 34}), ({'speed_mph': 70, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 137, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 57, 'red_tenths': 16}), ({'speed_mph': 20, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 100, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 45}), ({'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': -3, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 87, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 11}), ({'speed_mph': 60, 'grade_pct': -5, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 64, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 59, 'red_tenths': 12}), ({'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': 0, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 95, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 13}), ({'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': 20, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 90, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 45}), ({'speed_mph': 25, 'grade_pct': 5, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 50, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 24})], [({'speed_mph': 20, 'grade_pct': -1, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 79, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 41}), ({'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': 25, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 58, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 31, 'red_tenths': 22}), ({'speed_mph': 35, 'grade_pct': -7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 130, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 42, 'red_tenths': 32}), ({'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': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 115, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 14}), ({'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': 25, 'grade_pct': 8, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 125, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 45})]]
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 grade percent is used as a decimal fraction.

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'] + 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']) / 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': 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': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 130, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 32, 'red_tenths': 41}), ({'speed_mph': 50, 'grade_pct': 1, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 71, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 41, 'red_tenths': 13}), ({'speed_mph': 20, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 31}), ({'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': 5, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 44, 'red_tenths': 14}), ({'speed_mph': 45, 'grade_pct': -2, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 61, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 12})], [({'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': 1, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 35, 'grade_pct': 7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 133, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 30}), ({'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': 3, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 91, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 42}), ({'speed_mph': 35, 'grade_pct': -5, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 129, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 40, 'red_tenths': 36}), ({'speed_mph': 60, 'grade_pct': -8, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 53, 'veh_len_ft': 20, 'crosswalk_ft': 8, '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': 40, 'grade_pct': 5, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 98, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 34, 'red_tenths': 21}), ({'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': -6, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 101, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 13}), ({'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': -8, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 119, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 15}), ({'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': 12, 'decel': 12, 'width_ft': 116, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 15}), ({'speed_mph': 70, 'grade_pct': -3, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 53, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 55, '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': 6, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 131, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 34, 'red_tenths': 25}), ({'speed_mph': 20, 'grade_pct': -5, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 83, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 38}), ({'speed_mph': 25, 'grade_pct': -5, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 121, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 41}), ({'speed_mph': 20, 'grade_pct': 1, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 133, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 51}), ({'speed_mph': 65, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 133, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 18}), ({'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': 25, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 48, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 18}), ({'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': 1, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 71, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 37, 'red_tenths': 25}), ({'speed_mph': 70, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 104, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 57, 'red_tenths': 14}), ({'speed_mph': 25, 'grade_pct': -5, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 59, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 23}), ({'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': 40, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 126, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 25}), ({'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})]]
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(98, 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']) / 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': 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': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 130, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 32, 'red_tenths': 41}), ({'speed_mph': 50, 'grade_pct': 1, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 71, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 41, 'red_tenths': 13}), ({'speed_mph': 20, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 31}), ({'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': 5, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 70, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 44, 'red_tenths': 14}), ({'speed_mph': 45, 'grade_pct': -2, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 61, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 12})], [({'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': 1, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 10}), ({'speed_mph': 35, 'grade_pct': 7, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 133, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 30}), ({'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': 3, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 91, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 42}), ({'speed_mph': 35, 'grade_pct': -5, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 129, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 40, 'red_tenths': 36}), ({'speed_mph': 60, 'grade_pct': -8, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 53, 'veh_len_ft': 20, 'crosswalk_ft': 8, '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': 40, 'grade_pct': 5, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 98, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 34, 'red_tenths': 21}), ({'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': -6, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 101, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 13}), ({'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': -8, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 119, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 15}), ({'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': 12, 'decel': 12, 'width_ft': 116, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 15}), ({'speed_mph': 70, 'grade_pct': -3, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 53, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 55, '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': 6, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 131, 'veh_len_ft': 25, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 34, 'red_tenths': 25}), ({'speed_mph': 20, 'grade_pct': -5, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 83, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 38}), ({'speed_mph': 25, 'grade_pct': -5, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 121, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 41}), ({'speed_mph': 20, 'grade_pct': 1, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 133, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 51}), ({'speed_mph': 65, 'grade_pct': 8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 133, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 48, 'red_tenths': 18}), ({'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': 25, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 48, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 18}), ({'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': 1, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 71, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 37, 'red_tenths': 25}), ({'speed_mph': 70, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 104, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 57, 'red_tenths': 14}), ({'speed_mph': 25, 'grade_pct': -5, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 59, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 23}), ({'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': 40, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 126, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 39, 'red_tenths': 25}), ({'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})]]
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 grade term omits the factor of two.

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, int((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']) / 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': 65, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 53, 'veh_len_ft': 20, 'crosswalk_ft': 15, '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': 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': -8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 44, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 20}), ({'speed_mph': 25, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 111, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 42}), ({'speed_mph': 35, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 81, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 36, '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': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 70, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 55, 'grade_pct': 7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 96, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 15}), ({'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': 60, 'grade_pct': -3, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 79, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 11}), ({'speed_mph': 40, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 55, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 42, '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': 25, 'grade_pct': -5, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 43, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 30, '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': 65, 'grade_pct': -6, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 55, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 70, 'grade_pct': 2, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 119, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 15}), ({'speed_mph': 30, 'grade_pct': -1, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 59, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 41, 'red_tenths': 25}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 132, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 49, 'red_tenths': 24}), ({'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': 20, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 114, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 46}), ({'speed_mph': 65, 'grade_pct': -6, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 69, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 30, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 130, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 38}), ({'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': 20, 'grade_pct': -6, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 58, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 33}), ({'speed_mph': 70, 'grade_pct': -5, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 92, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 11}), ({'speed_mph': 20, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 25}), ({'speed_mph': 40, 'grade_pct': 6, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 56, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 37, 'red_tenths': 14}), ({'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': 12, 'decel': 10, 'width_ft': 98, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 14}), ({'speed_mph': 70, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 113, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 50, 'red_tenths': 15}), ({'speed_mph': 50, 'grade_pct': -7, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 106, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 50, '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': -3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 51, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 23}), ({'speed_mph': 30, 'grade_pct': -2, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 101, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'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})]]
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'] 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': 65, 'grade_pct': 0, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 53, 'veh_len_ft': 20, 'crosswalk_ft': 15, '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': 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': -8, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 44, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 40, 'red_tenths': 20}), ({'speed_mph': 25, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 111, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 42}), ({'speed_mph': 35, 'grade_pct': 0, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 81, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 36, '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': 70, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 70, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 55, 'grade_pct': 7, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 96, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 15}), ({'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': 60, 'grade_pct': -3, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 79, 'veh_len_ft': 16, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 11}), ({'speed_mph': 40, 'grade_pct': 4, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 55, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 42, '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': 25, 'grade_pct': -5, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 43, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': True}, {'yellow_tenths': 30, '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': 65, 'grade_pct': -6, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 55, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 70, 'grade_pct': 2, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 119, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 15}), ({'speed_mph': 30, 'grade_pct': -1, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 59, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 41, 'red_tenths': 25}), ({'speed_mph': 50, 'grade_pct': 6, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 132, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 49, 'red_tenths': 24}), ({'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': 20, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 114, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 46}), ({'speed_mph': 65, 'grade_pct': -6, 'reaction_tenths': 8, 'decel': 8, 'width_ft': 69, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 10})], [({'speed_mph': 30, 'grade_pct': 3, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 130, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 35, 'red_tenths': 38}), ({'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': 20, 'grade_pct': -6, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 58, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 33}), ({'speed_mph': 70, 'grade_pct': -5, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 92, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 11}), ({'speed_mph': 20, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 47, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 25}), ({'speed_mph': 40, 'grade_pct': 6, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 56, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 37, 'red_tenths': 14}), ({'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': 12, 'decel': 10, 'width_ft': 98, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 14}), ({'speed_mph': 70, 'grade_pct': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 113, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 50, 'red_tenths': 15}), ({'speed_mph': 50, 'grade_pct': -7, 'reaction_tenths': 12, 'decel': 12, 'width_ft': 106, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 50, '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': -3, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 51, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 23}), ({'speed_mph': 30, 'grade_pct': -2, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 101, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'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})]]
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 yellow interval is truncated to tenths.

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'], 100)
    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']) / 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': 55, 'grade_pct': -7, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 81, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 59, 'red_tenths': 17}), ({'speed_mph': 30, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 62, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 18}), ({'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': -2, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 95, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 40}), ({'speed_mph': 30, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 97, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'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': -4, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 61, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'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': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 63, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 23}), ({'speed_mph': 20, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 49, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 31}), ({'speed_mph': 20, 'grade_pct': -8, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 61, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 40}), ({'speed_mph': 45, 'grade_pct': 2, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 65, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 44, 'red_tenths': 14}), ({'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': 25, 'grade_pct': 3, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 74, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 31, 'red_tenths': 26}), ({'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': 6, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 78, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 10}), ({'speed_mph': 60, 'grade_pct': -6, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 103, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 18}), ({'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': -6, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 114, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 14}), ({'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': 5, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 120, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 51, 'red_tenths': 21}), ({'speed_mph': 20, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 118, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 48}), ({'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': 20, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 112, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 51}), ({'speed_mph': 45, 'grade_pct': -8, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 44, 'veh_len_ft': 20, 'crosswalk_ft': 15, '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': 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': 8, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 117, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 51}), ({'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': 6, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 56, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 55, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -4, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 126, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 58, 'red_tenths': 18})], [({'speed_mph': 25, 'grade_pct': -6, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 126, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 46, 'red_tenths': 45}), ({'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': 8, 'decel': 10, 'width_ft': 66, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 41}), ({'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': 0, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 55, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 55, 'red_tenths': 10}), ({'speed_mph': 25, 'grade_pct': 7, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 93, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 33}), ({'speed_mph': 25, 'grade_pct': 7, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 96, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 32})]]
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'] 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': 55, 'grade_pct': -7, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 81, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 59, 'red_tenths': 17}), ({'speed_mph': 30, 'grade_pct': 4, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 62, 'veh_len_ft': 16, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 33, 'red_tenths': 18}), ({'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': -2, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 95, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 40}), ({'speed_mph': 30, 'grade_pct': 4, 'reaction_tenths': 8, 'decel': 10, 'width_ft': 97, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'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': -4, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 61, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 27}), ({'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': 6, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 63, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 23}), ({'speed_mph': 20, 'grade_pct': -4, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 49, 'veh_len_ft': 25, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 31}), ({'speed_mph': 20, 'grade_pct': -8, 'reaction_tenths': 10, 'decel': 11, 'width_ft': 61, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 40}), ({'speed_mph': 45, 'grade_pct': 2, 'reaction_tenths': 12, 'decel': 10, 'width_ft': 65, 'veh_len_ft': 25, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 44, 'red_tenths': 14}), ({'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': 25, 'grade_pct': 3, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 74, 'veh_len_ft': 20, 'crosswalk_ft': 8, 'ped': False}, {'yellow_tenths': 31, 'red_tenths': 26}), ({'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': 6, 'reaction_tenths': 8, 'decel': 12, 'width_ft': 78, 'veh_len_ft': 16, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 43, 'red_tenths': 10}), ({'speed_mph': 60, 'grade_pct': -6, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 103, 'veh_len_ft': 40, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 60, 'red_tenths': 18}), ({'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': -6, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 114, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 60, 'red_tenths': 14}), ({'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': 5, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 120, 'veh_len_ft': 16, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 51, 'red_tenths': 21}), ({'speed_mph': 20, 'grade_pct': 1, 'reaction_tenths': 10, 'decel': 10, 'width_ft': 118, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 48}), ({'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': 20, 'grade_pct': -7, 'reaction_tenths': 10, 'decel': 12, 'width_ft': 112, 'veh_len_ft': 20, 'crosswalk_ft': 15, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 51}), ({'speed_mph': 45, 'grade_pct': -8, 'reaction_tenths': 12, 'decel': 8, 'width_ft': 44, 'veh_len_ft': 20, 'crosswalk_ft': 15, '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': 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': 8, 'reaction_tenths': 15, 'decel': 10, 'width_ft': 117, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 51}), ({'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': 6, 'reaction_tenths': 15, 'decel': 11, 'width_ft': 56, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 55, 'red_tenths': 10}), ({'speed_mph': 65, 'grade_pct': -4, 'reaction_tenths': 8, 'decel': 11, 'width_ft': 126, 'veh_len_ft': 40, 'crosswalk_ft': 15, 'ped': False}, {'yellow_tenths': 58, 'red_tenths': 18})], [({'speed_mph': 25, 'grade_pct': -6, 'reaction_tenths': 15, 'decel': 8, 'width_ft': 126, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 46, 'red_tenths': 45}), ({'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': 8, 'decel': 10, 'width_ft': 66, 'veh_len_ft': 40, 'crosswalk_ft': 12, 'ped': True}, {'yellow_tenths': 30, 'red_tenths': 41}), ({'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': 0, 'reaction_tenths': 15, 'decel': 12, 'width_ft': 55, 'veh_len_ft': 20, 'crosswalk_ft': 10, 'ped': True}, {'yellow_tenths': 55, 'red_tenths': 10}), ({'speed_mph': 25, 'grade_pct': 7, 'reaction_tenths': 12, 'decel': 11, 'width_ft': 93, 'veh_len_ft': 25, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 33}), ({'speed_mph': 25, 'grade_pct': 7, 'reaction_tenths': 10, 'decel': 8, 'width_ft': 96, 'veh_len_ft': 20, 'crosswalk_ft': 12, 'ped': False}, {'yellow_tenths': 30, 'red_tenths': 32})]]
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 reaction time in tenths is read as hundredths.

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