Thursday, September 8, 2011

Solution for calculating the distance

Question:  http://good-interview-puzzles.blogspot.com/2011/09/calculate-distance.html

It is given that the platoon and the last person moved with uniform speed. Also,they both moved for the identical amount of time. Hence, the ratio of the distancethey covered - while person moving forward and backword - are equal.Let's assume that when the last person reached the first person, the platoonmoved X meters forward.Thus, while moving forward the last person moved (50+X) meters whereas theplatoon moved X meters
Similarly, while moving back the last person moved [50-(50-X)] X meterswhereas the platoon moved (50-X) meters.
 Now, as the ratios are equal,(50+X)/X = X/(50-X)(50+X)*(50-X) = X*XSolving, X=35.355 metersThus, total distance covered by the last person= (50+X) + X= 2*X + 50= 2*(35.355) + 50= 120.71 metersNote that at first glance, one might think that the total distance covered by thelast person is 100 meters, as he ran the total lenght of the platoon (50 meters)twice. TRUE, but that's the relative distance covered by the last person i.e.assuming that the platoon is stationary 

calculate the distance


There is a 50m long army platoon marching ahead. The last person in the platoonwants to give a letter to the first person leading the platoon. So while the platoon ismarching he runs ahead, reaches the first person and hands over the letter to him andwithout stopping he runs and comes back to his original position.In the mean time the whole platoon has moved ahead by 50m.The question is how much distance did the last person cover in that time. Assuming that  
he ran the whole distance with uniform speed.

Solution is   http://good-interview-puzzles.blogspot.com/2011/09/solution-for-calculating-distance-it-is.html

Monday, August 1, 2011

Solution: Puzzle : Prisoners and Five - hats.

Question: http://good-interview-puzzles.blogspot.com/2011/08/puzzle-prisoners-and-five-hats.html


The solution

Assuming that A wears a black hat.

• If B wears a black hat as well, C can immediately tell that he is wearing a white hat after looking at the two black hats in front of him.

• If B does not wear a black hat, C will be unable to tell the colour of his hat (since there is a black and a white). Hence, B can deduce from A's black hat and C's response that he (B) is not wearing a black hat (otherwise the above situation will happen) and is therefore wearing a white hat.

This therefore proves that A must not be wearing a black hat.

Puzzle : Prisoners and Five - hats.


Another different condition. only three prisoners and five hats (supposedly two black and three white) are involved. The three prisoners are ordered to stand in a straight line facing the front, with A in front and C at the back. They are told that there will be two black hats and three white hats. One hat is then put on each prisoner's head; each prisoner can only see the hats of the people in front of him and not on his own's. The first prisoner that is able to announce the colour of his hat correctly will be released. No communication between the prisoners is allowed. After some time, only A is able to announce (correctly) that his hat is white. Why is that so?

Solution: Puzzle : Prisoners and Four - hats.


Question: http://good-interview-puzzles.blogspot.com/2011/08/puzzle-prisoners-and-four-hats.html

There are two cases:
In first case, one of the three prisoners (in A, B, C) wears the single off-colour hat, thus the other two can easily deduce the colour of theirs. For example if A is single color then B can see that C and A have different color hats. From this he concludes that his color is not single so he shouts his color.

In second case, the three prisoners wear hats of the same colour, while D wears the off-colour hat. After a while, all four prisoners should be able to deduce that, since none of the others was able to state the colour of his own hat, D must wear the off-colour hat.

Puzzle : Prisoners and Four - hats.



Now the same puzzle with different condition. Instead of two red and two blue hats there are 3 hats of one colour and only 1 hat of another, and the 3 prisoners can see each other i.e. A sees B & C, B sees A & C and C sees A & B. D again not to be seen and only there to wear the last hat.

Answer: http://good-interview-puzzles.blogspot.com/2011/08/solution-puzzle-prisoners-and-four-hats.html

solution: puzzle: prisioners and three hats

Question: http://good-interview-puzzles.blogspot.com/2011/08/puzzle-prisoners-and-three-hats.html

Answer:


For the sake of explanation let's label the prisoners in line order A B and C. Thus B can see A (and his hat colour) and C can see A and B.

The prisoners know that there are only two hats of each colour. So if C observes that A and B have hats of the same colour, C would deduce that his own hat is the opposite colour. However, If A and B have hats of different colours, then C can say nothing. The key is that prisoner B, after allowing an appropriate interval, and knowing what C would do, can deduce that if C says nothing the hats on A and B must be different. Being able to see A's hat he can deduce his own hat colour. (The fourth prisoner is irrelevant to the puzzle: his only purpose is to wear the fourth hat).