Posts

Showing posts with the label end-sort

Python3 hackerRank exercise with solutions (Set 2)

Image
  1.  Cab and Walk Arun is working in an office which is N blocks away from his house. He wants to minimize the time it takes him to the from his house to the office. He can either take the office cab or he can walk to the office. While walking Arun's velocity is V1 m/s  and V2 m/s  is the velocity of cab. But when he calls 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*N while walking. Help Arun to decide whether he has to walk or to take the cab to save the time. Input format : A single line containing three integers N, V1 and V2 separated by space. Output format : Print "Walk" or "Cab" accordingly. Sample input 1 : 5  10  15 Sample output 1 : Cab Sample input 2 : 2  10  14 Sample output 2 : Walk Code : Output : 2.  End - Sort Given a list A of N distinct numbers we