Puzzles, riddles, logical questions, and lateral thinking questions are
integral part of any programming job interviews. I missed to include some
puzzles, when I shared my list of top 30 programming interview questions
earlier, and couple of my friends requested to share some puzzles as well.
These puzzles and lateral thinking questions are mostly collected from various Java programming interviews on
Investment banks, but they are equally useful to any programming job
interviews. I have seen more puzzles and logical questions at junior level i.e.
2 to 4 years. These kinds of puzzles, if asked at the beginning of interview,
can make or break the interview. It’s not easy to solve them, especially when
you see them first time, but what is surely not to do is give up without try,
even if you can't think of answer, try to show rational approach. Remember it's OK, if you don't answer any puzzle question, but your approach towards unknown
problem get noticed. At the same time lateral thinking questions offers several
answers, and you can give your own explanation as well, but make sure it must
look genuine and seems logical. Puzzles and riddles also forms a big chunk of
Microsoft and Google Interview questions as
well, and they are some really nasty and tough to answer. Anyway, I have not
provided answers of these puzzles and logical questions, so that you can at
least give it a try. Immediate answers kill the purpose of puzzles and riddles,
and it's fun to solve them by yourself. By the way, you can easily find answers
of these puzzles using Google, as they have asked numerous times on various
programming interviews on software and technology companies.

##
__10 puzzles, riddles, logical and lateral
thinking question__

Here is my list of

*10 riddles, puzzles, logical and lateral thinking questions*. Try to solve it by yourself before searching for answers in Google, they are not that tough or difficult. Easy answers spoils purpose of puzzles, so don’t look at them, until you are going for interview very next day.
1) There are 27 coins and a two-pan balance. All coins has same weight
except for one, which is heavier than all others. All coins looks identical.
What is the minimum number of weighing required to certainly find out heavier
coin?

2) There are two sticks which takes one hour to burn from one end to
other. The sticks do not burn at a constant rate i.e. some part may burn faster
than others. You need to measure 45 minutes by using these two sticks and a
lighter.

3) Two persons are walking into a railway tunnel. Upon crossing 2/3rd of
the tunnel, they saw train is coming from opposite direction. Each person ran
for a different end of tunnel with speed of 10 km per hour. Fortunately, both
persons escaped from the tunnel just right time i.e.. at the time train would
have run through them. Assuming train was running with a constant speed and
both persons reacted immediately, Find out speed of train.

4) There are thee switches outside of a closed room to operate three
different light bulb inside the room. You can only go into the room once and
you need to determine which switch belongs to which bulb. Just to make it
clear, room is perfectly locked and its not possible to determine whether
lights are on from outside the room.

5) You have 10 Jars filled with marbles. Each marble weighs 10 gm, except
one Jar which contains defective marbles which weighs 9 gm. Given a scale to
weigh, How do you find Jar with defective marbles in just one measurement. Here
scale is modern day electronic scale to measure weight.

6) A person shoots her wife. Then holds her under water for 5 minutes.
Finally, he hangs her. But after 10 minutes they both go out together and enjoy
a wonderful dinner together. How can this be?

7) A father and son are going in a car and suddenly there car met
accident. Father died on the spot but the child rushed to the hospital. When he
arrives in the hospital, doctor says, "I can't operate on this child, he
is my son!" How can this be?

8) You have a 5 liter Jug and a 3 liter Jug and unlimited supply of
water. You need to measure exactly 4 liter of water but there is no measuring
instrument or cup. Also Jugs are oddly shaped and doesn't contain any mark.

9) There are Four people needs to cross the bridge during night. The
bridge can hold the weight of two people at a time and can not be crossed
without a torch. Each person walk with different speed, first can cross the
bridge in 1 minutes, second in 2 minutes, third in 5 minutes and fourth take 10
minutes to cross the bridge. If two persons go together, they walk with the
speed of slower person. What is the least amount in which all four people cross
the bridge.

10) A person's age is many days as his father's age in weeks and as many
month as his grand father's age in years. If you combine age of all three it
comes 120 years. What is the age of all three?

That's all on this list of

**top 10 puzzles, riddles, logical questions and lateral thinking questions**asked in programmer interviews. These question has maximum impact when programmer doesn't heard about it, and it means they may appear differently in actual interview. As a candidate, you can prepare all these question to get your mind working and knowing some techniques to solve them, but be prepare for surprise in actual Interview. Key of solving puzzles, logical questions or riddles are keeping your cool and not panicking. Even if you don't know answer you should start explaining your way and logic and if you have any answer which is out of box then better say it. Many times it happen when candidates are selected even if they don't solve the puzzles but in the process show some promise.
## 30 comments :

In Question6, Is he a Photographer?

@Kapil, that's correct mate. Good answer. He is photographer, here shot means taking photos :)

@Jarvin why don't you make another blog post with just the answers? I couldn't find the answer for question 3 anywhere...

tRain -> [A, B, C] <- tunel

A = B = C, A+B+C = 3A = 3B = 3C

Time T0 = 0

persons P1 and P2 are between A, B, tRain is far away.

Time T1 = t

Person P1 is out of the tunel right in time. tRain is at the start of the tunel. Person P2 is between B and C

Time T2 = 2t

Person P2 made it out of the tunle right in time. tRain is at the end of the tunel.

S = V*T (s = length, v = speed, T = time)

For person P1

A = 10*T

for Person P2

B = 10*t <==> C = 10*t <==> A = 10*t

B + C = 10*2t <==> 2A = 10*2t <==> A = 10t

for Train

A + B + C = x*t <==> 3A = x*t

From P1 or from p1 we can get

A = 10*t

t = A/10

And this we will put in equation of train

3A = x*(A/10)

3A = xA/10

3 = x / 10

30 = x

x = 30 km/h

What is the answer for question 4 and 5?

Answers

1. require 3 weighing

step 1 take 9 each on each side of balance

eliminate the two sets ;remaining 9

step 2 take 3 each on each side of balance

eliminate the two sets; remaining 3

step 3 take 1 each on each side of balance

eliminate the two sets

2. burn 1st stick from both sides and second from one side. When 1st stick finishes(half an hr) ,ignite the other end of second stick.

3.

4. switch on switch one and two. then turn two off. After entering the room, one bulb will be on(switch one). one bulb will be hot and off(switch 2) and the third will be off and cool

5.take one marble from jar one, two from jar two, three from jar three etc... and weigh.

total weight if all jar contained 10 g each should be 550. Subtract the actual weight from 550, and that will be the index of the jar(eg, if 5th jar contain 9 g marbles, then total weight would be 545; 550-545=5(5th jar)

6.

7. the Doctor is the mother of the boy

8.fill the three-litter jug with water and pour it into the five-litter jug. Repeat. one litter will be left over in the three-litter jug. Empty out the five-littr jug and pour in the one litter. Now just fill the three-litter jug again and pour it into the five-litter jug. . (Mathematically, this can be represented 3 + 3 - 5 + 3 = 4)

9. 17 minutes

A(1) and B(2) cross the bridge, takes 2 mins

B comes back takes 2 mins(total 4)

C(5) and D(10) cross the bridge takes 10 mins (total 14)

A comes back take 1 min (total 15)

A and B cross the brodge again takes 2 mins (total 17 mins)

Answer to Question 1 : Key here is to understand that 27 is cube of 3, which means it will take minimum 3 weighing attempts to find defective coin. Let's assume defective coin is heavier than normal coins, now divide 27 coins into group of 9. Out of three groups, weigh two of them in balance. The group with heavier coin, will go down, which means you can discard two groups right that time. Now further divide those 9 coins into 3 groups of 3 coins, and repeat the process, this will give you a group of 3 coins, now divide them into group of 1 coins, at this time (which is third weighing attempt), you will find out exactly which coin is defective. This puzzle can be generalized further, e.g. if interviewer gives you 8 coins or 64 coins

@Anonymous, Answer of puzzle 4 is very easy. You can keep one bulb on for couple of minutes and then switch that off and on another switch. Now you can go into room, the one, which is hot is associated with previous switch you pressed, current bulb is the switch you just pressed and the remaining third one is, well you know.

Please correct me if I am wrong.

For the third question, I think the speed of train is 30 km/h.

At the moment when train enters the tunnel, the first runner runned 1/3 of the tunnel and safely escaped. The second runner runned 1/3 of tunnel in oposite direction, so he has another 1/3 of tunnel to run when the train has complete tunnel length to pass. The time is equal, so we have t1=t2, meaning third of tunnel lenght devidid by 10km/h is equal as complete tunnel lenght devided by the train speed. That means train speed is 3 times more than 10km/h

Answer of Questions 8:

1) Completely fill 5 liter Jug with water.

2) Pour water from 5 litter Jug to 3 liter Jug, which means you will left with 2L of water.

3) Now empty 3L jug and pour 2L into them. Now your 3L jug contains 2L of water and 5L jug is empty.

4) Now refill 5L jug and pour into 3L jug which contains 2L water already. Once you fill 3L jug, you will left with 4L of water in 5L jug.

Ahh, lots of juggling but I think this answer the puzzle number 8, anyone has better answers, I mean less steps?

Answers to 10. 6 years, 42 years and 72 years. classic Solve the equations with three variables problem...

answer for 7th is.....

doctor is childs mother.

answer for 6 is

He is taking and developing a photograph of his wife.

answer to first question is 1.

They asked the minimun no of measures. Keep one aside and weigh 13 each on two pans. If they balance out, you have the answer

fill up the 5 liter jug and 3 litre jug to its half portion..that is 2.5 + 1.5=4litres ...thats it

ya 30kmph is correct for quest 3...

gns

Fill the 3lit jug and pour water into 5 liter.again fill 3lt and pour water into 5 liter.

So 1 lt is left in 3lt.

Throw the water from 5lt.and fill the 1lt water in 5lt.now again fill 3lt and pour in 5 lt.

1+3=4...done

ans 3; train speed is 30 kmph

v=d/t first u have to caliculate the time to travel from the 1/3 of the tunnel to one person who travelled towards to train is 10=(1/3)/t from this equation u will get t value is 1/30 hrs and now should go the second person who is the running away from the train.(1/v)=(1/3)/10 from this equation u will get the v value means train speed is 30 kmph

answer of the 3 one is 30 kmph

Q6 says a person shooted HER wife. Then later , it says HE hang her. So i think that the he and her are two different people and the two of them went for dinner. This is just my opinion.

Number 9 should be 12 mins.

first A(1) and B(2) cross the bridge in 2 mins

then C(5) and D(10) cross the bridge in 10 mins.

Nobody said there was only one torch.

answer of question4

first switch on any switch from those 3 and keep it ON for 15 mins and then switch it off . Now switch on any other switch and keep it ON ,Now you enter the room .Touch any one of the bulbs ,if any of those are hot means it belongs to the first switch you turned on and then off . The second bulb is already ON so you know the switch implicitly. The third bulb was always off so you know its switch.

Ans. of Que 10 .

child's age 6 years

father's age 42 years

grand father's age 72 years

This does not proof that three is the minimum, only that it is possible in three times, so it does not solve the problem

Answer to Puzzle 7

The Father from Church travels with a son who is not his biological son!

Answer to Puzzle 7

May be the child and father hit a church father.And may be that doctor is actual mother of the church father.

Answer to Question No 3:

Let Length of tunnel = x

When they saw the train, distances to the ends of tunnel: x/3 and 2x/3

Time taken (TT) by 2x/3 person = TT by train to reach the first end + TT by the train inside the tunnel

Time taken (TT) by 2x/3 person = TT by x/3 person + TT by the train inside the tunnel

ie (2x/3)/10 = (x/3)/10 + x/Y (time = distance/velocity: Y = train speed)

2/30 = 1/30 + 1/Y

Y = 30 Km/Hr

Answer to Qustion No 1 is 4

1. 13, 13. Remaining 1

2. 6, 6. Remaining 1

3. 3,3. Remaining 0

4. 1,1. Remaining 1

Answer to Question No 4. Switch on first switch. Wait for 2 minutes. Switch on second switch. Go inside the room and touch the bulbs to find out which bulb belongs to which switch.

Answer to question 7. The doctor is the father of the dead person. the dead person's son brings him to the hospital immediately after the accident. Grand father is the doctor, father is the dead person. His son remains alive.

## Post a Comment