Monday, January 26, 2009

Inteview Puzzle

Important Interview Puzzle Questions

The Rope Bridge:
Q->Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time.

Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes 10 minutes to cross. How do the campers make it across in 17 minutes?

Sol->To get everyone across in 17 minutes, we need get the two slowest people across together; otherwise we are wasting too much time. Once we get them across, how do we not make one of them walk back with the flashlight? Just have one of the faster people already there waiting to sprint the flashlight back across.

The Rope Bridge Solution

To get everyone across in 17 minutes, we need get the two slowest people across together; otherwise we are wasting too much time. Once we get them across, how do we not make one of them walk back with the flashlight? Just have one of the faster people already there waiting to sprint the flashlight back across.

person A: 1 minute
person B: 2 minutes
person C: 6 minutes
person D:10 minutes

1. A & B cross. total time: 2 minutes.

C || A
D || B
|| flashlight

2. B comes back. total time: 4 minutes.

C || A
D ||
B ||
flashlight

3. C & D cross. total time: 14 minutes.

B || A
|| C
|| D
flashlight

4. A comes back. total time: 15 minutes.

A || C
B || D
||
flashlight

5. A & B cross. total time: 17 minutes.

|| A
|| B
|| C D
flashlight

Another valid solution is to have A bring the flashlight back in step 2.

Q*** 10 10 2 1***    Sol- 17
Q*** 10 9 2 1 ***    Sol- 17
Q*** 10 7 2 1 ***    Sol- 17
Q*** 10 7 2 1 ***    Sol- 17
Q*** 10 6 2 1 ***    Sol- 17
Q*** 10 5 2 1 ***    Sol- 17
Q*** 10 4 2 1 ***    Sol- 17
Q*** 10 3 2 1 ***    Sol- 17
Q*** 10 2 2 1 ***    Sol- 17

**Quick Sol**- Suppose a,b,c,d are the take time one can cross the bridge such that a>b>c>d or a>b=c>d or a=b>c>d or a=b=c>d or a=b=c=d

Genreric Sol- a+3*c+d (independent of b. :) )

Weight Puzzle:

Q->8 Balls,Odd ball being heavier or Lighter.
question is to find out the minimum number of weighings required to spot the odd heavier ball among 8 identically looking balls using a common balance.

Sol->For simplicity let us name the balls as A1,A2,A3,B1,B2,B3,C1 and C2.We weigh with A's on one side and B's on the other side of the balance.If both sides are equal this means the heavier odd ball is among C1 and C2.We can figure out the heavier ball with one more weighing.If A's are heavier than B's then the heavier odd ball is among A's.Now we balance A1 and A2.If both are same then A3 is the odd ball or else the heavier one of A1 and A2 .Thus, we can find out the heavier ball using only 2 weighings.

Q->8 Balls,Odd ball can be either heavier or lighter than the rest.

Sol->This is a little trickier to solve.Let us name the 8 balls as A1,A2,A3,B1,B2,B3,C1 and C2.Now weigh with A1,A2,A3 on one side and B1,B2,B3 on the other side.If both weigh equal then the odd ball is among C1 and C2.Now we know that A's and B's are all normal ones we can weigh C1 with A1 and check whether C1 weighs the same as the normal ball.In this way, we can figure out in one weigh which of C1 and C2 is odd.Now if A's weighed more than B's then we know for sure C's are normal ones.Now lets assume A's heavier than B's and we still don't know whether the odd is among A's or B's.

We know
A1 A2 A3 < B1 B2 B3

Now we compare
A1 B2 B3 to B1 C1 C2 .
Now if the A1 B2 B3 is heavier than B1 C1 C2 Then it means the odd ball is among A1 and B1.If A1 B2 B3 is lighter than B1 C1 C2 then the odd ball is among B2 and B3.If A1 B2 B3 equal to B1 C1 C2 then odd ball is among A2 and A3.So we have zeroed down to 2 balls.Now its very easy as we can compare any of the normal ball with one of the 2 balls.So answer is 3,ie in 3 weighings we can find out the odd ball.

Q->You are given 13 balls.The odd ball may be either heavier or lighter.Find out the odd ball in 3 weightings.

Sol->If u have solved above two weighing problem than u can simply slove this(R&D required).

Q->If shopkeeper can only place the weights in one side of the common balance. For example if shopkeeper has weights 1 and 3 then he can measure 1,3 and 4 only. Now the question is how many minimum weights and name the weights you will need to measure all weights from 1 to 1000. This is a fairly simple problem and very easy to prove also.

Sol->This is simply the numbers 2^0,2^1,2^2 ….. that is 1,2,4,8,16 ……….
So for making 1000 kg we need up to
1, 2, 4, 8, 16, 32, 64, 128, 512

Q->This is same as the first problem with the condition of placing weights on only side of the common balance being removed. You can place weights on both side and you need to measure all weights between 1 and 1000.F
or example if you have weights 1 and 3,now you can measure 1,3 and 4 like earlier case, and also you can measure 2,by placing 3 on one side and 1 on the side which contain the substance to be weighed. So question again is how many minimum weights and of what denominations you need to measure all weights from 1kg to 1000kg.

Sol->For this answer is 3^0,3^1,3^2 …. That is 1,3,9,27,81,243,729

Door Problem

Q->There are 100 doors in a row numbered from 1 to N. Initially all are closed.
Then you make 100 passes by the 100 doors. In pass 1 you toggle the all the doors (1,2,3,4....)starting from the first door. In the second pass you toggle every second door(2,4,6,8,...). In the third pass you toggle all third doors(3,6,9...).what state are the doors in after the last pass? which are open which are closed?

Sol->?

Q->If a bear walks one mile south, turns left and walks one mile to the east and then turns left again and walks one mile north and arrives at its original position, what is the color of the bear.

Sol->color White

Q->Color of bear.... if it falls from 1m height in 1s.

Sol->We get 'g' perfect 10 which is only in poles...hence polar bear...color White

Q->You are given a cake; one of its corner is broken. How will u cut the rest into Two equal parts?

Sol->Slice the cake(Horigentally).

Q->How it is possible to place four points that are equidistance from each other?

Sol->place points in the shape of a pyramid.

Q->Why is a manhole cover round?

Sol->Round covers can be transported by one person, because they can be rolled on their edge. 2. A round cover doesn’t need to be rotated to fit over a hole.The diagonal of a square hole is larger than the side of a cover!

Q->If you have 5 quart and 3 quart pot, how would you measure exactly 4 quarts?

Fill 5 quarts pot and use that water to fill the 3 quarts pot. now there are 2 quarts in the 5 quart pot. repeat this twice to get 4 quarts.

If there is no extra pot available to hold these 2 quarts + 2 quarts, then the following is the solution.

Fill the 5 quart pot and pour it into the 3 quart pot. now there are 2 quarts remaining in the 5 quart pot. empty the 3 quart pot and pour these 2 quarts into the 3 quarts pot. now the 3 quart pot is 1 less to be filled up. now fill the 5 quarts pot and pour 1 quart into the 3 quarts pot to fill it. the 5 quarts pot has 4 quarts in it now.

Q->If one tyre of a car suddenly gets stolen.... and after sometime u find the tyre
without the screws how will u make ur journey complete?

Sol->Open 3 screws, 1 from each tyre and fix the tyre.

Q->You are given two candles of equal size, which can burn 1 hour each. You have to measure 90 minutes with these candles. (There is no scale or clock). Also u r given a lighter.

Sol->First light up the two ends of the 1st candle. When it will burn out light up one end of the second candle. (30+60=90)

Q->In the above q how you will measure 45 minutes.

Sol->First light-up the two ends of the 1st candle and one end of the 2nd candle.
When the 1st candle will burn out ,then light up the both ends of the 2nd candle (15+30=45).

Q->Can u make 120 with 5 zeros?

Sol-> Factorial (factorial (0)+factorial (0)+factorial (0)+factorial (0)+factorial (0)) = 120

No comments:

Post a Comment