Python- Cab and Walk | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python- Cab and Walk

Can someone please help me understand the following question? Arunworking in an office which is N blocks away from his house. He wants to minimize the time it takes him to go from his house to the office. He can either take the office cab or he can walk to the office. Arun's velocity is V1 m/s when he is walking. The cab moves with velocity V2 m/s but whenever he calls for the cab, it always starts from the office, covers N blocks, collects Arun and goes back to the office. The cab crosses a total distance of N meters when going from office to Arun's house and vice versa, whereas Arun covers a distance of (√2)(2)*N while walking. Help Arun to find whether he should walk or take a cab to minimize the time. Input Format: A single line containing three integer numbers N, V1, and V2 separated by a space. Output Format: Print 'Walk' or 'Cab' accordingly Constraints: 1<=V1, V2 <=100 1<=N<=200 Example-1: Input: 5 10 15 Output: Cab Example-2: Input: 2 10 14 Output: Walk

5th Mar 2019, 9:26 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar
2 Answers
+ 1
Based on the formula your function has to calculate how much time it takes to walk and to go by taxi, and determine which is smaller. Hint: V = S / T speed = distance / time
9th Mar 2019, 4:33 AM
Tibor Santa
Tibor Santa - avatar
- 2
Tibor Santa thank a lot. I did figure it out.
9th Mar 2019, 4:41 AM
Nilutpol Kashyap
Nilutpol Kashyap - avatar