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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + x['distance_m'] // x['speed_kmh']
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = exit_down if x['four_quadrant'] else entry_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle) if obstacle is not None else None
    warning = arrive - red
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 8', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 42, 'proved': 18, 'signal_clear': 30, 'warning_ok': False}), ('regression: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('sampled regression 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('sampled regression 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True})], [('regression: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 3', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 221, 'proved': 22, 'signal_clear': 22, 'warning_ok': True}), ('sampled regression 27', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 117, 'proved': 18, 'signal_clear': 30, 'warning_ok': True}), ('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('sampled regression 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('sampled regression 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 10', {'strike_in_s': 5, 'distance_m': 1000, 'speed_kmh': 40, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 95, 'proved': 26, 'signal_clear': 26, 'warning_ok': True}), ('sampled regression 69', {'strike_in_s': 12, 'distance_m': 1250, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 124, 'proved': 25, 'signal_clear': 25, 'warning_ok': True}), ('regression: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 17', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 135, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('sampled regression 14', {'strike_in_s': 12, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 45, 'proved': 33, 'signal_clear': 33, 'warning_ok': False}), ('regression: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('sampled regression 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('sampled regression 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('sampled regression 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('regression: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 24', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 18, 'proved': 15, 'signal_clear': 15, 'warning_ok': False}), ('sampled regression 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False}), ('regression: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('sampled regression 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('sampled regression 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + -(-x['distance_m'] * 36 // (x['speed_kmh'] * 10))
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = exit_down if x['four_quadrant'] else entry_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle) if obstacle is not None else None
    warning = arrive - red
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 8', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 42, 'proved': 18, 'signal_clear': 30, 'warning_ok': False}), ('regression: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('sampled regression 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('sampled regression 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True})], [('regression: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 3', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 221, 'proved': 22, 'signal_clear': 22, 'warning_ok': True}), ('sampled regression 27', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 117, 'proved': 18, 'signal_clear': 30, 'warning_ok': True}), ('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('sampled regression 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('sampled regression 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 10', {'strike_in_s': 5, 'distance_m': 1000, 'speed_kmh': 40, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 95, 'proved': 26, 'signal_clear': 26, 'warning_ok': True}), ('sampled regression 69', {'strike_in_s': 12, 'distance_m': 1250, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 124, 'proved': 25, 'signal_clear': 25, 'warning_ok': True}), ('regression: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 17', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 135, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('sampled regression 14', {'strike_in_s': 12, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 45, 'proved': 33, 'signal_clear': 33, 'warning_ok': False}), ('regression: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('sampled regression 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('sampled regression 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('sampled regression 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('regression: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('regression: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 24', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 18, 'proved': 15, 'signal_clear': 15, 'warning_ok': False}), ('sampled regression 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False}), ('regression: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('sampled regression 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('sampled regression 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, 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:
The predicted train arrival is far too early or rounded later than the train can arrive.

Strike-in at t0 starts amber; red follows 3 s later; entrance barriers are down 4 s after red plus lower_s; exit barriers 4 s after that. Half-barrier crossings are proven at entrance-down, four-quadrant crossings at exit-down. Train arrival is t0 + floor(distance*3.6/speed). The protecting signal clears at max(proven, obstacle clear) and never without an obstacle confirmation (None). warning_ok needs arrival-red >= min_warning_s and a clear time no later than arrival - sighting_s.

split: open-access


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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + (x['distance_m'] * 36) // (x['speed_kmh'] * 10)
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = entry_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle) if obstacle is not None else None
    warning = arrive - red
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('control 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True}), ('sampled regression 10', {'strike_in_s': 5, 'distance_m': 1000, 'speed_kmh': 40, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 95, 'proved': 26, 'signal_clear': 26, 'warning_ok': True})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 14', {'strike_in_s': 12, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 45, 'proved': 33, 'signal_clear': 33, 'warning_ok': False}), ('boundary: late obstacle confirmation', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 60, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 77, 'proved': 20, 'signal_clear': 60, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('sampled regression 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('control 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 32', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 23, 'proved': 26, 'signal_clear': 26, 'warning_ok': False}), ('control 16', {'strike_in_s': 12, 'distance_m': 2000, 'speed_kmh': 60, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 132, 'proved': 25, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('control 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 44', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 30, 'warning_ok': True}), ('control 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('sampled regression 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('sampled regression 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: warning measured from red', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 30, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 63', {'strike_in_s': 12, 'distance_m': 1250, 'speed_kmh': 60, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 87, 'proved': 29, 'signal_clear': 29, 'warning_ok': True}), ('control 28', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 90, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 37, 'proved': 18, 'signal_clear': 20, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('control 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('sampled regression 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + (x['distance_m'] * 36) // (x['speed_kmh'] * 10)
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = exit_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle) if obstacle is not None else None
    warning = arrive - red
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('control 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True}), ('sampled regression 10', {'strike_in_s': 5, 'distance_m': 1000, 'speed_kmh': 40, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 95, 'proved': 26, 'signal_clear': 26, 'warning_ok': True})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('sampled regression 14', {'strike_in_s': 12, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 45, 'proved': 33, 'signal_clear': 33, 'warning_ok': False}), ('boundary: late obstacle confirmation', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 60, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 77, 'proved': 20, 'signal_clear': 60, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('sampled regression 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('control 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('sampled regression 32', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 23, 'proved': 26, 'signal_clear': 26, 'warning_ok': False}), ('control 16', {'strike_in_s': 12, 'distance_m': 2000, 'speed_kmh': 60, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 132, 'proved': 25, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('control 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 44', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 30, 'warning_ok': True}), ('control 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('sampled regression 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('sampled regression 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('regression: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: warning measured from red', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 30, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 63', {'strike_in_s': 12, 'distance_m': 1250, 'speed_kmh': 60, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 87, 'proved': 29, 'signal_clear': 29, 'warning_ok': True}), ('control 28', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 90, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 37, 'proved': 18, 'signal_clear': 20, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('control 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('sampled regression 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, 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:
A four-quadrant crossing is proven before its exit barriers are down.

Strike-in at t0 starts amber; red follows 3 s later; entrance barriers are down 4 s after red plus lower_s; exit barriers 4 s after that. Half-barrier crossings are proven at entrance-down, four-quadrant crossings at exit-down. Train arrival is t0 + floor(distance*3.6/speed). The protecting signal clears at max(proven, obstacle clear) and never without an obstacle confirmation (None). warning_ok needs arrival-red >= min_warning_s and a clear time no later than arrival - sighting_s.

split: open-access


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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + (x['distance_m'] * 36) // (x['speed_kmh'] * 10)
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = exit_down if x['four_quadrant'] else entry_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle or 0)
    warning = arrive - red
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 42', {'strike_in_s': 12, 'distance_m': 2400, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 66, 'proved': 29, 'signal_clear': None, 'warning_ok': False}), ('control 9', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 40, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 5}, {'arrive': 72, 'proved': 19, 'signal_clear': 19, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('control 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('control 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 76', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 142, 'proved': 47, 'signal_clear': 47, 'warning_ok': True}), ('boundary: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('control 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('control 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('control 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 13', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 40, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': None, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 210, 'proved': 49, 'signal_clear': None, 'warning_ok': False}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('boundary: warning measured from red', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 30, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('control 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('control 24', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 18, 'proved': 15, 'signal_clear': 15, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('boundary: late obstacle confirmation', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 60, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 77, 'proved': 20, 'signal_clear': 60, 'warning_ok': True}), ('control 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('control 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('control 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 80', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 54, 'proved': 49, 'signal_clear': None, 'warning_ok': False}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('control 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('control 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + (x['distance_m'] * 36) // (x['speed_kmh'] * 10)
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = exit_down if x['four_quadrant'] else entry_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle) if obstacle else None
    warning = arrive - red
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 42', {'strike_in_s': 12, 'distance_m': 2400, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 66, 'proved': 29, 'signal_clear': None, 'warning_ok': False}), ('control 9', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 40, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 5}, {'arrive': 72, 'proved': 19, 'signal_clear': 19, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('control 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('control 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 76', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 40, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 142, 'proved': 47, 'signal_clear': 47, 'warning_ok': True}), ('boundary: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('control 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('control 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('control 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 13', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 40, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': None, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 210, 'proved': 49, 'signal_clear': None, 'warning_ok': False}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('boundary: warning measured from red', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 30, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('sampled regression 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('control 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('control 24', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 18, 'proved': 15, 'signal_clear': 15, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('boundary: late obstacle confirmation', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 60, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 77, 'proved': 20, 'signal_clear': 60, 'warning_ok': True}), ('control 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('control 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('control 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('regression: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('sampled regression 80', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 54, 'proved': 49, 'signal_clear': None, 'warning_ok': False}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('control 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('control 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, 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:
The protecting signal clears although the obstacle detector never confirmed the crossing empty.

Strike-in at t0 starts amber; red follows 3 s later; entrance barriers are down 4 s after red plus lower_s; exit barriers 4 s after that. Half-barrier crossings are proven at entrance-down, four-quadrant crossings at exit-down. Train arrival is t0 + floor(distance*3.6/speed). The protecting signal clears at max(proven, obstacle clear) and never without an obstacle confirmation (None). warning_ok needs arrival-red >= min_warning_s and a clear time no later than arrival - sighting_s.

split: open-access


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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + (x['distance_m'] * 36) // (x['speed_kmh'] * 10)
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = exit_down if x['four_quadrant'] else entry_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle) if obstacle is not None else None
    warning = arrive - t0
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 19', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 50, 'proved': 26, 'signal_clear': 26, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('control 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('control 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('control 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('boundary: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('control 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('control 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('control 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 39', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 90, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 44, 'proved': 29, 'signal_clear': 29, 'warning_ok': True}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('boundary: warning measured from red', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 30, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('control 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 25', {'strike_in_s': 5, 'distance_m': 1500, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 50, 'proved': 22, 'signal_clear': 30, 'warning_ok': True}), ('boundary: late obstacle confirmation', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 60, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 77, 'proved': 20, 'signal_clear': 60, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('control 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('control 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('boundary: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('control 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('control 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    t0 = x['strike_in_s']
    arrive = t0 + (x['distance_m'] * 36) // (x['speed_kmh'] * 10)
    red = t0 + 3
    entry_down = red + 4 + x['lower_s']
    exit_down = entry_down + 4
    proved = exit_down if x['four_quadrant'] else entry_down
    obstacle = x['obstacle_clear_s']
    clear_sig = max(proved, obstacle) if obstacle is not None else None
    warning = arrive - entry_down
    ok = warning >= x['min_warning_s'] and clear_sig is not None and clear_sig <= arrive - x['sighting_s']
    return {'arrive': arrive, 'proved': proved, 'signal_clear': clear_sig, 'warning_ok': ok}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 19', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 50, 'proved': 26, 'signal_clear': 26, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('control 1', {'strike_in_s': 5, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 53, 'proved': 26, 'signal_clear': 40, 'warning_ok': True}), ('control 4', {'strike_in_s': 0, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 72, 'proved': 21, 'signal_clear': 60, 'warning_ok': True}), ('control 7', {'strike_in_s': 30, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 40, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 75, 'proved': 43, 'signal_clear': 43, 'warning_ok': True})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('boundary: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('boundary: obstacle detector silent', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': None, 'warning_ok': False}), ('control 12', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 60, 'proved': 31, 'signal_clear': 31, 'warning_ok': True}), ('control 15', {'strike_in_s': 5, 'distance_m': 2000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 15}, {'arrive': 65, 'proved': 24, 'signal_clear': 30, 'warning_ok': True}), ('control 18', {'strike_in_s': 30, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 52, 'proved': 43, 'signal_clear': 43, 'warning_ok': False})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 39', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 90, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 44, 'proved': 29, 'signal_clear': 29, 'warning_ok': True}), ('boundary: obstacle confirmed at strike-in', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 15, 'signal_clear': 15, 'warning_ok': True}), ('boundary: warning measured from red', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 30, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 23', {'strike_in_s': 0, 'distance_m': 800, 'speed_kmh': 60, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': None, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 48, 'proved': 17, 'signal_clear': None, 'warning_ok': False}), ('control 26', {'strike_in_s': 0, 'distance_m': 1500, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 20, 'sighting_s': 10}, {'arrive': 33, 'proved': 17, 'signal_clear': 25, 'warning_ok': False}), ('control 29', {'strike_in_s': 5, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 60, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 42, 'proved': 24, 'signal_clear': 60, 'warning_ok': False})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('control 25', {'strike_in_s': 5, 'distance_m': 1500, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 50, 'proved': 22, 'signal_clear': 30, 'warning_ok': True}), ('boundary: late obstacle confirmation', {'strike_in_s': 5, 'distance_m': 2400, 'speed_kmh': 120, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 60, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 77, 'proved': 20, 'signal_clear': 60, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('control 34', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 45, 'proved': 17, 'signal_clear': 20, 'warning_ok': True}), ('control 37', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 48, 'proved': 49, 'signal_clear': 49, 'warning_ok': False}), ('control 40', {'strike_in_s': 12, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 6, 'four_quadrant': True, 'obstacle_clear_s': 40, 'min_warning_s': 35, 'sighting_s': 15}, {'arrive': 30, 'proved': 29, 'signal_clear': 40, 'warning_ok': False})], [('sampled regression 59', {'strike_in_s': 30, 'distance_m': 1250, 'speed_kmh': 120, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 20, 'min_warning_s': 35, 'sighting_s': 5}, {'arrive': 67, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('boundary: clear exactly at the sighting point', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 40, 'proved': 15, 'signal_clear': 30, 'warning_ok': True}), ('boundary: fast train on a short approach', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 160, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 22, 'proved': 15, 'signal_clear': 25, 'warning_ok': False}), ('boundary: arrival rounding', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': False, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 50, 'proved': 15, 'signal_clear': 25, 'warning_ok': True}), ('boundary: four-quadrant proving', {'strike_in_s': 0, 'distance_m': 2000, 'speed_kmh': 90, 'lower_s': 8, 'four_quadrant': True, 'obstacle_clear_s': 25, 'min_warning_s': 27, 'sighting_s': 10}, {'arrive': 80, 'proved': 19, 'signal_clear': 25, 'warning_ok': True}), ('control 45', {'strike_in_s': 0, 'distance_m': 1000, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 0, 'min_warning_s': 35, 'sighting_s': 10}, {'arrive': 40, 'proved': 17, 'signal_clear': 17, 'warning_ok': True}), ('control 48', {'strike_in_s': 30, 'distance_m': 800, 'speed_kmh': 160, 'lower_s': 10, 'four_quadrant': False, 'obstacle_clear_s': 30, 'min_warning_s': 20, 'sighting_s': 15}, {'arrive': 48, 'proved': 47, 'signal_clear': 47, 'warning_ok': False}), ('control 51', {'strike_in_s': 0, 'distance_m': 1250, 'speed_kmh': 90, 'lower_s': 10, 'four_quadrant': True, 'obstacle_clear_s': 20, 'min_warning_s': 20, 'sighting_s': 5}, {'arrive': 50, 'proved': 21, 'signal_clear': 21, 'warning_ok': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, 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:
The road warning time is overstated.

Strike-in at t0 starts amber; red follows 3 s later; entrance barriers are down 4 s after red plus lower_s; exit barriers 4 s after that. Half-barrier crossings are proven at entrance-down, four-quadrant crossings at exit-down. Train arrival is t0 + floor(distance*3.6/speed). The protecting signal clears at max(proven, obstacle clear) and never without an obstacle confirmation (None). warning_ok needs arrival-red >= min_warning_s and a clear time no later than arrival - sighting_s.

split: open-access