## Amazon Interview Question

**Country:**United States

The equation can not be solved.

Eq1+Eq2-Eq3=Eq4.

Therefore there are four variables but only three independent equations.

@Nascent: what do you mean by synchronizing the clock? Can we calculate how much time it takes from top to bottom and from bottom to top?

We cannot solve this by using four equations as 4 equations in 4 variables are solvable iff none of the equation is linear combination of others.

Alternative logical approach :

Send the horse up the hill ( now horses can be trained easily )

Go down and call/whistle the horse.

Note the time taken by horse to come down i.e HT.

Now send the horse up again.

When the horse is at the top, note the time of bottom clock i.e. T1. Now, start climbing the hill. When you reach at the top, ride on the horse down the hill.

Note the time at the bottom clock again i.e. T2

=> Time taken by you to climb up the hill and come down on horse = T2-T1

=> time taken by you to climb the hill = T2-T1-time taken to come down on horse = X = T2-T1-HT

Now start from bottom of hill. Note down the time of clock there i.e T. Climb up and set the clock at

the top to T+X.

After calculating the round trip time with the help of the bottom clock, the rider goes up again and sets the clock with an arbitrary time less than the round trip time.

eg:- lets say the round trip time is 35 mins and it takes 20 mins uphill and 15 mins downhill. The rider notes the time at the bottom before he starts say 10:00 . He rides up and assumes it takes 25 mins for him to reach. So he sets the clock to 10.25 and heads down. After coming down the clock reads 10.35 as expected. The top clock now reads 10:40 but since he assumed 10 mins downhill time he thinks its 10:35 and is in sync. To check he goes up again expecting to see a time of 11:00 but surprise he sees 11:05 instead. So he knows he has stepped it up by 5 mins extra the last time and the actual uptime is 20 mins. So he sets 20 mins from 10:35 which is 10:55.

Looks to be working on first look. But after thinking about it a bit, I guess there seems to be a mistake.

1. Lets say, The person assumes up/down times as 25/10 instead of the actual 20/15 mins.

2. He Notes the time as 10:00 and starts uphill. Actual time taken is 20mins but he assumes it took 25mins. On reaching he sets the Top clock to 10:25. The Bot clock reads 10:20.

3. He starts downhill and it actually takes 15mins but he assumes it as 10mins. On reaching Bot Clock he finds it to be 10:35 just as expected. The Top Clock should show 10:25+15 = 10:40.

At this point, He may assume that the Top Clock should be 10:25 + 10 = 10:35mins, but its 10:40.

3. Now here's the catch in your solution.

He notes the Bot Clock value as 10:35 and goes up hill which actually takes 20mins.

Now he expects the Top Clock to show 10:35(Bot Reference) + 25mins(assumed uphill time) = 11:00.

The actual Top Clock value will be 10:40(actual value before start of uphill) + 20mins(actual uphil time) = 11:00.

Both his expectation and actual value match which is 11:00, but the actual time shown by the Bot Clock will be 10:35 + 20mins = 10:55.

Not sure how he actually sees 11:05.

Please check and let me know if I missed something.

Otherwise, good thought process.

I presume the clock has a seconds hand......synchronize the seconds movement with the snap of your finger....start walking up....keep the time taken in terms of snaps....climb down...keep the count.....verify with the clock once again....climb up and the set the time.....verify once again....if u feel u need more oxygen ....climb up again and the validate the clock on the top of the hill....fare enough....

There is a solution if one can look at time of top clock from bottom.

Lets say man starts with horse @10 and reaches top and set clock @11 (randomly greater than 10) and starts coming down.

On reaching bottom note the time of the clock at hill top (say its 11:45) to get time taken to come down (which is 45min)

Also note the time of bottom clock which will give him a round trip time (top and back bottom). Say if time now is 12. So round trip time is 2 hrs.

So if round trip time is 2 hrs and time for top to bottom is 45min then time to reach top of hill will be 1hr15min.

He can note the current time and start again climbing the hill and set the correct time.

Correct me if wrong.

Let h1 be the time required to climb up to the top of the mountain on the horseback and h2 be the time required to climb down to the bottom on the horseback.

- Murali Mohan July 01, 2013Let p1 and p2 be times required for the person to climb up and climb down on foot.

The person has to make four different kinds of round-trips and measure the round trip times.

1. Climb up and climb down on horseback. The round trip time would be: h1 + h2 = t1 (t1 is measured accurately using the clock at the bottom)

2. Climb up and climb down on foot. The round trip time would be: p1 + p2 = t2

3. Climb up on horseback and climb down on foot. The round trip time would be: h1 + p2 = t3

4. Climb up on foot and climb down on horseback. The round trip time would be: p1 + h2 = t4

Now we have four equations and four unknowns:

h1 + h2 = t1

p1 + p2 = t2

h1 + p2 = t3

p1 + h2 = t4

(t1 to t4 are measured values and hence are known). Solving the system of linear equations gives the values of h1, h2, p1 & p2.

Now start from the bottom of the hill, record the time, call it t, using the clock at the bottom and climb up either on horseback or on foot.

Once you reach the top, correct the clock's time at the top to be either t + h1(if you have climbed up the hill on horseback) or t + p1(if you have climbed up the hill on foot).