Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Friday, March 14, 2014

Trick Math Problem

There is a jar in which there are two types of candies – 20 blueberry and 16 strawberry. You perform the following steps:
1) You take out two candies.
2) If the two candies are of same flavor, you add a blueberry one otherwise, you add the strawberry one.

You repeat these two steps till there is just one candy remaining in the jar. Which flavored candy will be left?

Also, if you began with 100 blueberry candies and 93 strawberry candies, which flavor would have been the last one to remain?



Answer:
Let us suppose that there are x blueberry candies and y strawberry candies. While removing the candies, there can be three possibilities:
1) 2 blueberry candies. In this case, you will replace one blueberry candy and so the jar will have x+1 blueberry and y-2 strawberry candies.
2) 2 strawberry candies. In this case, you will replace 1 blueberry candy and so the jar will have x-1 blueberry candies and y strawberry candies.
3) 1 blueberry and 1 strawberry. In this case, you will replace a strawberry candy and so the jar will have x-1 blueberry candies and y strawberry candies.

In this way at each step, we are either removing a blueberry candy or replacing 2 strawberry candies by 1 blueberry candy irreversibly till there is only one candy left. Thus each strawberry candy is equivalent to 2 blueberry candies.

Therefore, if there are odd number of strawberry candies, the last candy will be strawberry and if there are even number of strawberry candies, the last one will be a blueberry one.

Wednesday, March 12, 2014

Infosys Interview Puzzle

The king of Octopuses has servants who have six, seven or eight legs. The distinguishing characteristics of the servants is that the one with seven legs always lie but the one with either six or eight legs speak the truth always.

On a certain night, four servants meet and converse:
The black one says, 'We have 28 legs altogether.'
The green one says, 'We have 27 legs altogether.'
The yellow one says, 'We have 26 legs altogether.'
The red one says, 'We have 25 legs altogether.'

Can you identify the color of the servant who is speaking the truth?


Answer: 

The green servant is telling the truth.
To prove it, let us first assume that one of them is telling the truth. It is obvious that three of the four servants are lying as they are disagreeing with each other.

Suppose if the black servant is telling the truth. In that case, the black one is having either 6 or 8 legs. And each of the other octopus is lying will then have 7 legs. In this case, the total number of legs will be 6 + 7 + 7 + 7 = 27 legs or 8 + 7 + 7 + 7 = 29 legs. But the black servant said that they have 28 legs all together. Thus he is lying.

Now follow the same logic with the remaining three servants as well assuming all of them truthful one by one. You will realize that only the Green octopus is telling the truth