Cab and Walk using Python

                                            Cab and Walk


import math

user_input = input()
data = user_input.split(" ")

N = int(data[0])
V1 = int(data[1])
V2 = int(data[2])

walking_distance = (2 - math.sqrt(N))*(2 * N)
walking_time = walking_distance/V1;

cab_distance = 2 * ((2 - math.sqrt(N))*(2 * N))
cab_time = cab_distance/V2;

if(walking_time < cab_time):
    print("Walk")
else:
    print("Cab")



Output:

 5 10 15
 Cab 

 2 10 14
 Walk

Comments

Post a Comment