The physics tripped me up more than the code did.
Clarify the physics model first: constant deceleration after a reaction time delay. Then derive the stopping distance formula and implement a function that returns a tuple with the decision, braking start time, and stopping distance, handling edge cases like zero speed or negative values.
Pro tip: Mention that in real autonomous driving, sensor latency and actuator delays are critical, so the reaction time parameter should be configurable and validated. Also, consider using SI units consistently and document assumptions.
Ask about units, whether deceleration is constant, and if the obstacle is stationary. Confirm that reaction time is the delay before braking starts.
Compute distance traveled during reaction time (speed * reaction_time) and braking distance (speed^2 / (2 * max_deceleration)). Sum them for total stopping distance.
Write a Python function that takes speed, distance_to_obstacle, max_deceleration, and reaction_time. Return a tuple: (should_brake, braking_start_time, stopping_distance).
Check for non-positive speed, negative inputs, or zero deceleration. If speed is zero, no braking needed. If deceleration is zero, cannot stop.
Provide test cases (e.g., just enough distance, too close). Discuss real-world factors like sensor noise, varying deceleration, and safety margins.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.