Thursday 19 May 2011

Enigma 
(Without the spiritual world the material world is a disheartening enigma.)

Whether you like or dislike "Puzzle solving", today's IT interviewer will must ask you to solve some of them during your interview. Followings are some tips to solve logical puzzles.

  • Take notes. Write down on sheet.
  • Read and think to establish a plan.
  • Do not over think.
  • Look for patterns, its great if you find one.
  • Do not give up unless interviewer ask you to stop solving it.
  • If you do not come up with the solution at the end then put a wild guess at least(guess within context of problem).
Followings are some most commonly asked puzzles in IT interviews. Happy reading :). 


1. The Camels

Camel Puzzle
Four tasmanian camels traveling on a very narrow ledge encounter four tasmanian camels coming the other way. Tasmanian camels never go backwards, especially when on a precarious ledge. The camels will climb over each other, but only if there is a camel sized space on the other side. The camels didn’t see each other until there was only exactly one camel’s width between the two groups. How can all camels pass, allowing both groups to go on their way, without any camel reversing?



2. The Waiter
Three men in a cafe order a meal the total cost of which is $15. They each contribute $5. The waiter takes the money to the chef who recognizes the three as friends and asks the waiter to return $5 to the men. The waiter is not only poor at mathematics but dishonest and instead of going to the trouble of splitting the $5 between the three he simply gives them $1 each and pockets the remaining $2 for himself. Now, each of the men effectively paid $4, the total paid is therefore $12. Add the $2 in the waiters pocket and this comes to $14…..where has the other $1 gone from the original $15?

Answer


The payments should equal the receipts. It does not make sense to add what was paid by the men ($12) to what was received from that payment by the waiter ($2).

Although the initial bill was $15 dollars, one of the five dollar notes gets changed into five ones. The total the three men ultimately paid is $12, as they get three ones back. So from the $12 the men paid, the owner receives $10 and the waiter receives the $2 difference. $15 – $3 = $10 + $2.



3. The Boxes
There are three boxes. One is labeled “APPLES” another is labeled “ORANGES”. The last one is labeled “APPLES AND ORANGES”. You know that each is labeled incorrectly. You may ask me to pick one fruit from one box which you choose. How can you label the boxes correctly?
Answer

Pick from the one labeled “Apples & Oranges”. This box must contain either only apples or only oranges. if you find an Orange, label the box Orange, then change the Oranges box to Apples, and the Apples box to “Apples & Oranges”.

4. The Cannibals
Three cannibals and three anthropologists have to cross a river. The boat they have is only big enough for two people. The cannibals will do as requested, even if they are on the other side of the river, with one exception. If at any point in time there are more cannibals on one side of the river than anthropologists, the cannibals will eat them. What plan can the anthropologists use for crossing the river so they don’t get eaten? Note: One anthropologist can not control two cannibals on land, nor can one anthropologist on land control two cannibals on the boat if they are all on the same side of the river. This means an anthropologist will not survive being rowed across the river by a cannibal if there is one cannibal on the other side.
Answer
First, two cannibals go across to the other side of the river, then the rower gets called back. Next, the rowing cannibal takes the second across and then gets called back, so now there are two cannibals on the far side. Two anthropologists go over, then one anthropologist accompanies one cannibal back, so now there is one anthropologist and one cannibal on the far side. The last two anthropologists go over to the far side, so now all the anthropologists are across the other side, along with the boat and one cannibal. In two trips, the cannibal on the far side takes the boat and ferries the other two cannibals across the river.

5. The Age Puzzle
A mother is 21 years older than her child. In exactly 6 years from now, the mother will be exactly 5 times as old as the child. Where’s the father?
Answer
With the mother. If you do the math, you find out the child will be born in 9 months.

6. The Double Jeopardy Doors
You are trapped in a room with two doors. One leads to certain death and the other leads to freedom. You don’t know which is which. There are two robots guarding the doors. They will let you choose one door but upon doing so you must go through it. You can, however, ask one robot one question. The problem is one robot always tells the truth ,the other always lies and you don’t know which is which. What is the question you ask?
Answer
Ask one robot what the other robot would say, if it was asked which door was safe. Then go through the other door.
7. The Frog
A frog is at the bottom of a 30 meter well. Each day he summons enough energy for one 3 meter leap up the well. Exhausted, he then hangs there for the rest of the day. At night, while he is asleep, he slips 2 meters backwards. How many days does it take him to escape from the well? Note: Assume after the first leap that his hind legs are exactly three meters up the well. His hind legs must clear the well for him to escape.
Answer
Each day he makes it up another meter, and then on the twenty seventh day he can leap three meters and climb out.

8. The Bobber
You can paddle your canoe seven miles per hour through any placid lake. The stream flows at three miles per hour. The moment you start to paddle up stream a fisherman looses one of his bobbers in the water fourteen miles up stream of you. How many hours does it take for you and the bobber to meet?

Answer
2 hours. Ignore the speed of the stream, as the cork will be carried along at three miles per hour as will you. It takes two hours to travel fourteen miles, at a rate of seven miles per hour.

9. The Socks
Cathy has six pairs of black socks and six pairs of white socks in her drawer. In complete darkness, and without looking, how many socks must she take from the drawer in order to be sure to get a pair that match?

Answer
Socks do not come in in left and right, so any black will pair with any other black and any white will pair with any other white. If you have three socks and they are either colored black or white, then you will have at least two socks of the same color, giving you one matching pair.

10. The Fake Coin
You have twelve coins. You know that one is fake. The only thing that distinguishes the fake coin from the real coins is that its weight is imperceptibly different. You have a perfectly balanced scale. The scale only tells you which side weighs more than the other side. What is the smallest number of times you must use the scale in order to always find the fake coin? Use only the twelve coins themselves and no others, no other weights, no cutting coins, no pencil marks on the scale. etc. These are modern coins, so the fake coin is not necessarily lighter. Presume the worst case scenario, and don’t hope that you will pick the right coin on the first attempt.

Answer
3 is the answer.
If you knew the fake coin was lighter, then the solution would have an easy explanation. But you do not. So…. Number the coins 1 through 12.
1. Weigh coins 1,2,3,4 against coins 5,6,7,8.
1.1. If they balance, then weigh coins 9 and 10 against coins 11 and 8 (we know from the first weighing that 8 is a good coin).
1.1.1. If the second weighing also balances, we know coin 12 (the only one not yet weighed) is the counterfeit. The third weighing indicates whether it is heavy or light.
1.1.2. If (at the second weighing) coins 11 and 8 are heavier than coins 9 and 10, either 11 is heavy or 9 is light or 10 is light. Weigh 9 against 10. If they balance, 11 is heavy. If they don’t balance, you know that either 9 or 10 is light, so the top coin is the fake.
1.1.3 If (at the second weighing) coins 11 and 8 are lighter than coins 9 and 10, either 11 is light or 9 is heavy or 10 is heavy. Weigh 9 against 10. If they balance, 11 is light. If they don’t balance, you know that either 9 or 10 is heavy, so the bottom coin is the fake.
1.2. Now if (at first weighing) the side with coins 5,6,7,8 are heavier than the side with coins 1,2,3,4. This means that either 1,2,3,4 is light or 5,6,7,8 is heavy. Weigh 1,2, and 5 against 3,6, and 9.
1.2.1. If (when we weigh 1,2, and 5 against 3,6 and 9) they balance, it means that either 7 or 8 is heavy or 4 is light. By weighing 7 and 8 we obtain the answer, because if they balance, then 4 has to be light. If 7 and 8 do not balance, then the heavier coin is the counterfeit.
1.2.2. If (when we weigh 1,2, and 5 against 3,6 and 9) the right side is heavier, then either 6 is heavy or 1 is light or 2 is light. By weighing 1 against 2 the solution is obtained.
1.2.3. If (when we weigh 1,2, and 5 against 3, 6 and 9) the right side is lighter, then either 3 is light or 5 is heavy. By weighing 3 against a good coin the solution is easily arrived at.
1.3 If (at the first weighing) coins 1,2,3,4 are heavier than coins 5,6,7,8 then repeat the previous steps 1.2 through 1.2.3 but switch the numbers of coins 1,2,3,4 with 5,6,7,8.

11. Birthday Cake Problem

You have a birthday cake and have exactly 3 cuts to cut it into 8 equal pieces. How do you do it?

Answer
The “correct” answer is to cut the cake in quarters (4 pieces) using 2 of the cuts, then stack all 4 of the pieces and then split all four of the stacked pieces with the third cut.














2 comments:

  1. Answer: 28
    Each day he makes it up another meter, and then on the twenty seventh day he can leap three meters and climb out.

    ReplyDelete