Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Meeting Two Walkers

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Meeting Two Walkers. Start with the requirements on the right.

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.

Problem

Epic's campus wayfinding interface needs to identify where two employees walking toward each other will meet. Given their starting offices and constant walking speeds, calculate the office where they meet.

Person A starts at start_a and walks toward Person B at speed_a offices per minute. Person B starts at start_b and walks toward Person A at speed_b offices per minute. Both begin at the same time and continue walking directly toward each other. The input guarantees that their meeting location is an integer office.

Formal Specification

Implement meeting_office(start_a, start_b, speed_a, speed_b).

  • Input: four positive integers representing starting office numbers and walking speeds.
  • Output: an integer representing the office where the two people meet.

You should calculate the result mathematically rather than simulating each minute.

Constraints

  • 1 <= start_a < start_b <= 10^9
  • 1 <= speed_a, speed_b <= 10^6
  • Both people start walking at the same time
  • Both people walk directly toward each other at constant speeds
  • The meeting office is guaranteed to be an integer

Function Signature

def meeting_office(start_a, start_b, speed_a, speed_b):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output