Wednesday, August 27, 2008

One Interview Question

This is a story about an interview question.


The technical guy asked this question.

“There are three colleagues who don’t want to reveal their salary to anyone, but they want to calculate the average of their salary. They have a calculator. How can u help them to find the average salary?”

Well this is good question. I thought for some time. Suddenly my mind remembered one of problem which I had solved earlier.


That puzzle goes like this.

“A car can travel at a speed of 63 miles/hour in straight road, 56 miles/ hour in uphill and 72 miles/hour in downhill. This car starts from A and reaches B after 4 hours. Then starts from B towards A and reaches A after 4 hours 40 minutes. What’s the distance between A and B?”


This problem I had solved like this…

Let Xu be the total uphill distance from A to B( which becomes downhill on the return trip) Xd be the total downhill distance from A to B( which becomes uphill on the return trip), and Xs be the total distance of straight road between A and B in miles.

Then problem reduces to form.

Xu / 56 + Xs / 63+ Xd / 72 = 4 hours

Xd / 56 + Xs / 63+ Xu / 72 = 4 hours 40 minutes.

Adding these two equations, will give

(Xu+Xd)(1/56+1/72) + 2Xs/63 = 8 hours and 40 minutes.

Now though finding the answer looks little tricky. And the trick is noticing 1/56,1/ 63, 1/72 are the terms of HP.


That is 1/63 – 1/56 = 1/72 – 1/63.

Hence (1/56+1/72) = 2/63

This will simplify the above equation as

2/63(Xu+Xd+ Xs) = 8 hours 40 minutes.

Which gives the (Xu+Xd+ Xs), that is distance between A and B. Pretty simple isn’t it?

Well I applied the same logic to solve the aptitude in the interview.

Lets say the salary of people be X1, X2, X3

I will choose three different numbers in HP lets say a,b,c. I will tell 1st and the 3rd person a and c, for the 2nd person b. The logic goes like this. 1st person will divide his salary by ‘a’ in the calculator and give it to 2nd person.

Sum in the calculator now = X1/a

2nd person (who is unaware of ‘a’ hence can’t decode what’s the salary of 1st person) will add (2/b* X2) to the number in calculator and pass it to the third person.

Sum in the calculator now = X1/a + (2/b* X2)

Third person will add(X3*(1/a+1/c)) and pass it to the first person.

Sum in the calculator now = X1/a + (2/b* X2) + (X3*(1/a+1/c))

Now first person will add X1/c to it.

Sum in the calculator now = X1/a + (2/b* X2) + (X3*(1/a+1/c))+ X1/c

Using the HP property this simplifies to

(X1+ X2+X3)*2/b

To calculate the averages multiply this by b/6. There you go.

Well this is how sharp minds works.!!!

You may guess i got that job. But your guess is wrong. J

I wasn’t selected in that interview. But im still proud of this answer as this answer came as out of box solution.

Recently I was thinking about this method. And I questioned myself why concept of HP came into my mind but not of AP or GP, though the same result can be achieved by any of the sequence. I realized it’s because my mind had already seen similar problem and it related the puzzle to it. That’s what pattern recognition power of mind.

Geniuses are not born. They observe things, record in their subconscious mind and use it whenever required.

Well enough of boosting myself. The simple answer to that question is

Let first person add some random number Y to his salary and pass it to the second

Sum in calculator = X1+ Y

Let other second and third person add their actual salary and pass it to the first.

Sum in calculator = X1+ Y+ X2+X3

First person who is aware of Y will now remove Y from this sum and divide by three to get the average of their salary.

No wonder I wasn’t selected in that interview..!!

Always there are plenty of methods to solve anything in life. But finding the simple one really makes the difference to anyone.

I remain
The J.

1 comment:

Rosh said...

Awesome solution dude :)

Cheers,
Rosh
(http://roshabraham.blogsome.com)