Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Stopping Distance From Deceleration
00:00
5 left

Stopping Distance From Deceleration

EasyPython

Problem

A Zoox autonomous vehicle must estimate how far it will travel while braking to a complete stop. Given its current velocity and a constant deceleration magnitude, calculate the stopping distance using one-dimensional kinematics.

Assume the vehicle begins braking immediately, deceleration remains constant, and there is no reaction delay. The supplied deceleration is a positive magnitude, not a signed acceleration.

Formal Specification

Implement stopping_distance(velocity, deceleration):

  • velocity is a nonnegative floating-point value in meters per second.
  • deceleration is a positive floating-point value in meters per second squared.
  • Return the distance in meters as a floating-point value.
  • Use the relationship v² = u² + 2as, where the final velocity is zero and acceleration is -deceleration.

Constraints

  • 0.0 <= velocity <= 100.0
  • 0.1 <= deceleration <= 20.0
  • Inputs are finite numbers
  • Return values within 1e-6 absolute or relative error are accepted

Function Signature

def stopping_distance(velocity, deceleration):
Interviewer

Your question is Stopping Distance From Deceleration. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.