Technical Interview Puzzles
Technical Interview Puzzles
Puzzle:
The owner of a banana plantation has a camel. He wants to transport his 3000 bananas to the market, which is
located after the desert. The distance between his banana plantation and the market is about 1000 kilometer. So
he decided to take his camel to carry the bananas. The camel can carry at the maximum of 1000 bananas at a
time, and it eats one banana for every kilometer it travels.
What is the most bananas you can bring over to your destination?
Solution:
First of all, the brute-force approach does not work. If the Camel starts by picking up the 1000 bananas and try
to reach point B, then he will eat up all the 1000 bananas on the way and there will be no bananas left for him
to return to point A.
So we have to take an approach that the Camel drops the bananas in between and then returns to point A to
pick up bananas again.
Since there are 3000 bananas and the Camel can only carry 1000 bananas, he will have to make 3 trips to carry
them all to any point in between.
<---p1---><--------p2-----><-----p3---->
A---------------------------------------->B
When bananas are reduced to 2000 then the Camel can shift them to another point in 2 trips and when the
number of bananas left are <= 1000, then he should not return and only move forward.
In the first part, P1, to shift the bananas by 1Km, the Camel will have to
1. Move forward with 1000 bananas – Will eat up 1 banana in the way forward
2. Leave 998 banana after 1 km and return with 1 banana – will eat up 1 banana in the way back
3. Pick up the next 1000 bananas and move forward – Will eat up 1 banana in the way forward
4. Leave 998 banana after 1 km and return with 1 banana – will eat up 1 banana in the way back
5. Will carry the last 1000 bananas from point a and move forward – will eat up 1 banana
Note: After point 5 the Camel does not need to return to point A again.
After moving to 200 km the Camel would have eaten up 1000 bananas and is now left with 2000 bananas.
Now in the Part P2, the Camel needs to do the following to shift the Bananas by 1km.
1. Move forward with 1000 bananas – Will eat up 1 banana in the way forward
2. Leave 998 banana after 1 km and return with 1 banana – will eat up this 1 banana in the way back
3. Pick up the next 1000 bananas and move forward – Will eat up 1 banana in the way forward
Note: After point 3 the Camel does not need to return to the starting point of P2.
So to shift 2000 bananas by 1km, the Camel will eat up 3 bananas.
After moving to 333 km the camel would have eaten up 1000 bananas and is now left with the last 1000
bananas.
The Camel will actually be able to cover 333.33 km, I have ignored the decimal part because it will not make a
difference in this example.
Now, for the last part, P3, the Camel only has to move forward. He has already covered 533 (200+333) out of
1000 km in Parts P1 & P2. Now he has to cover only 467 km and he has 1000 bananas.
He will eat up 467 bananas on the way forward, and at point B the Camel will be left with only 533 Bananas.
****************************************************************
Three ants are sitting at the three corners of an equilateral triangle. Each ant starts randomly picks a direction
and starts to move along the edge of the triangle. What is the probability that none of the ants collide?
Answer:
So let’s think this through. The ants can only avoid a collision if they all decide to move in the same direction
(either clockwise or anti-clockwise). If the ants do not pick the same direction, there will definitely be a
collision. Each ant has the option to either move clockwise or anti-clockwise. There is a one in two chance that
an ant decides to pick a particular direction. Using simple probability calculations, we can determine the
probability of no collision.
P(No collision) = P(All ants go in a clockwise direction) + P( All ants go in an anti-clockwise direction) = 0.5
* 0.5 * 0.5 + 0.5 * 0.5 * 0.5 = 0.25
****************************************************************
****************************************************************
Solution:
He will burn one of the rope at both the ends and the second rope at one end. After half an hour, the first one
burns completely and at this point of time, he will burn the other end of the second rope so now it will take 15
mins more to completely burn. so total time is 30+15 i.e. 45mins.
****************************************************************
Solution:
The question you should ask is “If I ask the other guard about which side leads to heaven, what would he
answer?”. It should be fairly easy to see that irrespective of whom do you ask this question, you will always
get an answer which leads to hell. So you can chose the other path to continue your journey to heaven.
Similarly, if you ask the liar about which path leads to heaven, he would say “right”. As the truth teller speaks
nothing but the truth, he would say “right” when he is asked what “the other guard( liar ) ” would answer. So
in any case, you would end up having the path to hell as an answer. So you can chose the other path as a way
to heaven.
****************************************************************
6) 10 Coins Puzzle
Problem: You are blindfolded and 10 coins are place in front of you on table. You are allowed to touch the
coins, but can’t tell which way up they are by feel. You are told that there are 5 coins head up, and 5 coins tails
up but not which ones are which. How do you make two piles of coins each with the same number of heads
up? You can flip the coins any number of times.
This puzzle was asked in Yahoo Interview.
Solution:
Make 2 piles with equal number of coins. Now, flip all the coins in one of the pile.
Case:
P1 : H H T T T
P2 : H H H T T
Now when P1 will be flipped
P1 : T T H H H
P1(Heads) = P2(Heads)
Another case:
P1 : H T T T T
P2 : H H H H T
Now when P1 will be flipped
P1 : H H H H T
P1(Heads) = P2(Heads)
****************************************************************
7) King and Wine Bottles
Problem:
A bad king has a cellar of 1000 bottles of delightful and very expensive wine. A neighboring queen plots to
kill the bad king and sends a servant to poison the wine. Fortunately (or say unfortunately) the bad king’s
guards catch the servant after he has only poisoned one bottle. Alas, the guards don’t know which bottle but
know that the poison is so strong that even if diluted 100,000 times it would still kill the king. Furthermore, it
takes one month to have an effect. The bad king decides he will get some of the prisoners in his vast dungeons
to drink the wine. Being a clever bad king he knows he needs to murder no more than 10 prisoners – believing
he can fob off such a low death rate – and will still be able to drink the rest of the wine (999 bottles) at his
anniversary party in 5 weeks time. Explain what is in mind of the king, how will he be able to do so ? (of
course he has less then 1000 prisoners in his prisons)
Solution:
Think in terms of binary numbers. (now don’t read the solution, give a try).
Number the bottles 1 to 1000 and write the number in binary format.
bottle 2 = 0000000010
Now take 10 prisoners and number them 1 to 10, now let prisoner 1 take a sip from every bottle that has a 1 in
its least significant bit. Let prisoner 10 take a sip from every bottle with a 1 in its most significant bit. etc.
prisoner = 10 9 8 7 6 5 4 3 2 1
bottle 924 = 1 1 1 0 0 1 1 1 0 0
For instance, bottle no. 924 would be sipped by 10,9,8,5,4 and 3. That way if bottle no. 924 was the poisoned
one, only those prisoners would die.
After four weeks, line the prisoners up in their bit order and read each living prisoner as a 0 bit and each dead
prisoner as a 1 bit. The number that you get is the bottle of wine that was poisoned.
1000 is less than 1024 (2^10). If there were 1024 or more bottles of wine it would take more than 10 prisoners.
****************************************************************
8) 3 Mislabeled Jars
Problem:
This problem is also called Jelly Beans problem. This is the most commonly asked interview puzzle.
You have 3 jars that are all mislabeled. One jar contains Apple, another contains Oranges and the third jar
contains a mixture of both Apple and Oranges.
You are allowed to pick as many fruits as you want from each jar to fix the labels on the jars. What is the
minimum number of fruits that you have to pick and from which jars to correctly label them?
Solution:
Let’s take a scenario. Suppose you pick from jar labelled as Apple and Oranges and you got Apple from it.
That means that jar should be Apple as it is incorrectly labelled. So it has to be Apple jar.
Now the jar labelled Oranges has to be Mixed as it cannot be the Oranges jar as they are wrongly labelled and
the jar labelled Apple has to be Oranges.
Similar scenario applies if it’s a Oranges taken out from the jar labelled as Apple and Oranges. So you need to
pick just one fruit from the jar labelled as Apple and Oranges to correctly label the jars.
****************************************************************
You would try different combinations, such as 25 of each colored marble in a jar or putting all red marbles in
one jar and all the blue in the other. You would still end up with a chance of 50%.
What if you put a single red marble in one jar and the rest of the marbles in the other jar? This way, you are
guaranteed at least a 50% chance of getting a red marble (since one marble picked at random, doesn’t leave
any room for choice). Now that you have 49 red marbles left in the other jar, you have a nearly even chance of
picking a red marble (49 out of 99).
So the maximum probability will be :
jar A : (1/2)*1 = 1/2 (selecting the jar A = 1/2, red marble from jar A = 1/1)
jar B : (1/2)*(49/99) = 0 (selecting the jar B = 1/2, red marble from jar B = 49/99)
Total probability = 74/99 (~3/4)
****************************************************************
Trick: Whenever it is said that you have to measure 15kg and minimum number of weights
required for this?
Then always start with 2^0 and go to less than 15 i.e. {1,2,4,8}. Hence these four weights can
measure any weight from 1-15 kg.
****************************************************************
What state are the doors in after the last pass? Which are open which are closed?
****************************************************************
Note: Assume you have a big supply of Blue and Red balls for this purpose. When you take the two balls out,
you don’t put them back in, so the number of balls in the bag keeps decreasing.
Once you tackle that, what if there are 20 blue balls and 11 red balls to start with?
Solution:
There can be 3 possible cases taking off 2 balls from bag.
a) If we take off 1 Red and 1 Blue, in fact we will take off 1 Blue
b) If we take off 2 Red, in fact we will take off 2 Red (and add 1 Blue)
c) If we take off 2 Blue, in fact we will take off 1 Blue
So In case of (a) or (c), we are only take off one Blue ball. Also, we always take off Red balls two by two.
How about all the squares that are formed by combining smaller squares on the chess board (2×2, 3×3, 4×4
squares and so on)?
A 1×1 square can be placed on the chess board in 8 horizontal and 8 vertical positions, thus making a total of 8
x 8 = 64 squares. Let’s consider a 2×2 square. There are 7 horizontal positions and 7 vertical positions in
which a 2×2 square can be placed. Why? Because picking 2 adjacent squares from a total of 8 squares on a
side can only be done in 7 ways. So we have 7 x 7 = 49 2×2 squares. Similarly, for the 3×3 squares, we have 6
x 6 = 36 possible squares. So here’s a break down.
Assume there are C number of couples so there would be C boys. The number of girls can be
calculated by the following method.
****************************************************************
What is the minimum number of days to guarantee in which cops can catch the thief?
Note:
Thief may or may not move to adjacent cave.
Cops can check any two caves, not necessarily be adjacent.
Solution (not confirmed):
Lets assume the thief is in cave C1 and going clockwise and cops start searching from cave C13 and C12 on
your first day.
Cave C13 and C11 on second day,
C13 and C10 on third day and so on till C13 and C1 on 12th day.
So basically the aim is to check C13 everyday so that if thief tries to go anti clockwise you immediately catch
it and if goes clockwise cops will catch him in maximum 12 days (this include the case where he remains in
Cave C1).
Answer is 12.
Another solution: one move clockwise another anti-clock, hence minimum days 7
****************************************************************
16) Prisoners and Hats Puzzle
Problem:
Four prisoners are arrested for a crime, but the jail is full and the jailer has nowhere to put them. He eventually
comes up with the solution of giving them a puzzle so if they succeed they can go free but if they fail they are
executed.
The jailer puts three of the men sitting in a line. The fourth man is put behind a screen (or in a separate room).
He gives all four men party hats. The jailer explains that there are two black and two white hats; that each
prisoner is wearing one of the hats; and that each of the prisoners is only to see the hats in front of them but not
on themselves or behind. The fourth man behind the screen can’t see or be seen by any other prisoner. No
communication between the prisoners is allowed.
If any prisoner can figure out and say to the jailer what color hat he has on his head all four prisoners go free.
If any prisoner suggests an incorrect answer, all four prisoners are executed. The puzzle is to find how the
prisoners can escape, regardless of how the jailer distributes the hats.
Solution:
Prisoner A and B are in the same situation – they have no information to help them determine their hat colour
so they can’t answer. C and D realise this.
Prisoner D can see both B and C’s hats. If B and C had the same colour hat then this would let D know that he
must have the other colour.
When the time is nearly up, or maybe before, C realises that D isn’t going to answer because he can’t. C
realises that his hat must be different to B’s otherwise D would have answered. C therefore concludes that he
has a black hat because he can see B’s white one.
****************************************************************
Solution:
This is a very good logical problem. To do it, first write down all the real possibilities that the number on that
building might have been. Assuming integer ages one get get the following which equal 72 when multiplied:
2, 2, 18 – sum = 22
2, 4, 9 – sum = 15
2, 6, 6 – sum = 14
2, 3, 12 – sum = 17
3, 4, 6 – sum = 13
3, 3, 8 – sum = 14
1, 8, 9 – sum = 18
1, 3, 24 – sum = 28
1, 4, 18 – sum = 23
1, 2, 36 – sum = 39
1, 6, 12 – sum = 19
The sum of their ages is the same as your birth date. That could be anything from 1 to 31 but the fact that Jack
was unable to find out the ages, it means there are two or more combinations with the same sum. From the
choices above, only two of them are possible now. For any other number, the answer is unique and the Jack
would have known after the second clue. So he asked for a third clue. The clue that the eldest kid just started
taking piano lessons is really just saying that there is an “oldest”, meaning that the younger two are not twins.
2, 6, 6 – sum(2, 6, 6) = 14
3, 3, 8 – sum(3, 3, 8 ) = 14
Hence, the answer is that the elder is 8 years old, and the younger two are both 3 years old.
The answer is 3, 3 and 8.
****************************************************************
Solution:
2 Cakes
How?
At each bridge you are required to give half of your cakes, and you receive one back. Which leaves you with 2
cakes after every bridge.
****************************************************************
Solution:
Lets say there are n persons
1st person shakes hand with everyone else: n-1 times(n-1 persons)
2nd person shakes hand with everyone else(not with 1st as its already done): n-2 times
3rd person shakes hands with remaining persons: n-3So total handshakes will be = (n-1) + (n-2) + (n-3) +……
0
= (n-1)*(n-1+1)/2 = (n-1)*n/2 = 66
= n^2 -n = 132
=(n-12)(n+11) = 0;
= n = 12 OR n =-11
-11 is ruled out so the answer is 12 persons.
****************************************************************
Solution:
Most of us will proceed like that if a rider goes a mile in 2 minutes with the wind, and returns against the wind
in 3 minutes, that 2 and 3 equal 5, should give a correct average, so that time taken should be two and half
minutes. We find this answer to be incorrect, because the wind has helped him for only 2 minutes, while it has
worked adversely for 3 minutes.
If he could ride a mile in 2 minutes with the wind, it is clear that he could go a 1.5 mile 3 minutes, and 1 mile
in 3 minutes against the wind.
Therefore 2.5 miles in 6 minutes gives his actual speed, because the wind helped him just as much as it has
retarded him, so his actual speed for a single mile without any wind would be (2.5)/6 = 5/12 miles/sec
****************************************************************
Answers:
Case I: Let the first coin removed be one rupee coin One rupee coins left = (x – 1) Fifty paise coins left = y.
Probability of getting a one rupee coin in the first and second draw = x/(x + y) × (x – 1)/(x – 1 + y)
Case II: Let the first coin removed be fifty paise coin One rupee coins left = x Fifty paise coins left = y – 1.
Probability of getting a fifty paise coin in the first and one rupee coin in second draw
= y / (x + y) × x / (x + y – 1)
Total probability = sum of these two = x/(x + y) [after simplification].
****************************************************************
Solution:
The trick to this puzzle is that you can keep wolf and cabbage together. So the solution would be
The sailor will start with the goat. He will go to the other side of the river with the goat. He will keep goat
there and will return back and will take cabbage with him on the next turn. When he reaches the other side he
will keep the cabbage there and will take goat back with him.
Now we will take wolf and will keep the wolf at the other side of the river along with the cabbage. He will
return back and will take goat along with him. This way they all will cross the river.
****************************************************************
Solution:
According to probability 1/3 of the time, the door to heaven will be chosen, so 1/3 of the time it will take 0
days. 1/3 of the time, the 1-day door is chosen, of those, the right door will be chosen the next day. Similarly,
1/3 of the time, the 2 day door is chosen, of those, the right door will be chosen after the 2 days.
So lets say it will take N days. 1/3 of the cases are done in 0 days as before. 1/3 of the cases are 1+N. 1/3 are 2
+ N.
N = 1/3 * 0 + 1/3 * (1 + N) + 1/3 * (2 + N)
N = 1 + 2N/3
Therefore, N/3 = 1 ; N = 3.
****************************************************************
This solution has a limitation that information is partially passed and there needs some trust level.
Salary of A: i
Salary of B: j
Salary of C: k
Salary of D: l
A passes to B (i + a) where a is a number that A knows B takes this a passes to C (i + j + a + b). C takes this
and passes to D (i + j + k + a + b + c). D takes this and passes to A (i + j + k + l + a + b + c + d)
Thus Finally D gets x + y + z + u + d. He takes away his constant and now he has i + j + k + l.
Other solution:
Instead of each one passing a constant, only A can pass his salary + constant. Finally when D passes back the
total + constant to A again, then A can deduct the constant from the total and compute the average.
****************************************************************
Solution:
Ways to pick any 2 socks from 24 socks = 24C2
Ways to pick 2 BLACK socks from 12 BLACK socks = 12C2
Probability of picking any 2 same color socks = P1+P2 = 66/276 + 66/276 = 11/23
****************************************************************
Solution:
On the first turn choose a diagonally opposite pair of glasses and turn both glasses up.
On the second turn choose two adjacent glasses. At least one will be up as a result of the previous step. If
the other is down, turn it up as well. If the bell does not ring then there are now three glasses up and one
down(3U and 1D).
On the third turn choose a diagonally opposite pair of glasses. If one is down, turn it up and the bell will
ring. If both are up, turn one down. There are now two glasses down, and they must be adjacent.
On the fourth turn choose two adjacent glasses and reverse both. If both were in the same orientation then
the bell will ring. Otherwise there are now two glasses down and they must be diagonally opposite.
On the fifth turn choose a diagonally opposite pair of glasses and reverse both. The bell will ring for sure.
****************************************************************
A duck, pursued by a fox, escapes to the center of a perfectly circular pond. The fox cannot swim, and the duck
cannot take flight from the water. The fox is four times faster than the duck. Assuming the fox and duck pursue
optimum strategies, is it possible for the duck to reach the edge of the pond and fly away without being eaten?
If so, how?
Solution:
From the speed of the fox it is obvious that duck cannot simply swim to the opposite side of the fox to escape.
Fox can travel 4r in the time duck covers r distance. Since fox have to travel half of the circumference Pi*r
and Pi*r < 4r
So how could the duck make life most difficult for the fox? If the duck just tries to swim along a radius, the
fox could just sit along that radius and the duck would continue to be trapped.
At a distance of r/4 from the center of the pond, the circumference of the pond is exactly four times the
circumference of the duck’s path.
Let the duck rotate around the pond in a circle of radius r/4. Now fox and duck will take exact same time to
make a full circle. Now reduce the radius the duck is circling by a very small amount (Delta). Now the Fox
will lag behind, he cannot stay at a position as well.
Say, the duck circles the pond at a distance r/4 – e, where e is an infinitesimal amount. So as the duck
continues to swim along this radius, it would slowly gain some distance over the fox. Once the duck is able to
gain 180 degrees over the fox, the duck would have to cover a distance of 3r/4 + e to reach the edge of the
pond. In the meanwhile, the fox would have to cover half the circumference of the pond (i.e the 180 degrees).
At that point,
So time taken to travel 3r/4 is quicker than 3.14*r at four times the speed.(0.14*r distance is left)
****************************************************************
29) 8 Balls Puzzle Find Defective One
(Trick: Always Divide into 3 equal or nearly equal parts)
Problem:
You have 8 balls. One of them is defective and weighs less than others. You have a balance to measure balls
against each other. In 2 weighing, how do you find the defective one?
Solution:
Defective ball is light
****************************************************************
Puzzle: You have 2 ball of each A,B,C colors and each color have 1 light and 1 heavy ball. All light balls are
of same weight same goes for heavy. Find out weight type of each ball in minimum chances. You can use a
two sided balance system (not the electronic one).
This puzzle was asked in many interviews – Drishti-soft, Yahoo, Infoedge.
Solution:
Simply, you can check by taking 2 balls of same color. Now, comparing those balls with other balls but this
will take 3 chances for each color type ball.
Answer is 2 chances.
So, Make a table for all conditions for all 6 balls that will help in understanding and solving this problem.
A1,A2,B1,B2,C1,C2
First weight A1,B1 and B2,C1 -> 3 cases equal ,left is heavy or left is light.
Case 1:
Equal, if equal weight simply B1,B2 will solve the problem.
Case 2:
If A1+B1 > B2+C1, then we know B1 > B2. Also just that A1>=C1.
Case 3:
****************************************************************
Behind each door is either a lady or a tiger. They may be both tigers, both ladies or one of each.
If the criminal opens a door to find a lady he will marry her and if he opens a door to find a tiger he will be
eaten alive. Of course, the criminal would prefer to be married than eaten alive.
The statement on door one says, “In this room there is a lady, and in the other room there is a tiger.”
The statement on door two says,“In one of these rooms there is a lady, and in one of these rooms there is a
tiger.”
The criminal is informed that one of the statements is true and one is false. Which door should the criminal
open?
Solution:
Criminal should open door number 2.
How?
Lets assume statement on the first door is true then second statement will also be true(as there will be a lady in
one door and a tiger in other door), but as we already know that only one statement can be true, so first
statement can not be true.
Door 1 Door 2
Tiger Tiger
Lady Lady
Tiger Lady
But as second statement is true, so it means behind one of the door there is a lady and in other door there is a
tiger so options with both lady and both tigers are ruled out and only third option remains valid, thus the
criminal should choose door number 2.
****************************************************************
Problem:
You have two sand timers with you. One can measure 7 minutes and the other sand timer can measure 11
minutes. This means that it takes 7 minutes for the sand timer to completely empty the sand from one portion
to the other.
You have to measure 15 minutes using both the timers. How will you measure it ?
Solution:
Mathematically
Reversing the 7 minutes timer – 4 minutes will elapse. 3 Minutes will left.
Once 11 minutes gets over reverse the 11 minutes timer again to use that 3 minutes. 8 Minutes left.
****************************************************************
After you choose one of the doors angel reveals one of the other two doors behind which there is a nothing.
Angel gives you an opportunity to change the door or you can stick with your chosen door.
You don’t know behind which door we have nothing. Should you switch or it doesn’t matter?
Soltuion:
You choose one of the door. So probability of getting the jackpot – 1/3.
Let’s say that the jackpot is in Door no 1 and you choose Door no 1. So the angel will either open door no 2 or
door no 3. Let’s look at the sample space of this Puzzle.
Problem :
We have 10 identical bottles of identical pills (each bottle contain hundred of pills). Out of 10 bottles 9 have 1
gram of pills but 1 bottle has pills of weight of 1.1 gram. Given a measurement scale, how would you find the
heavy bottle? You can use the scale only once.
Answer:
First, arrange the bottles on shelf and now take, 1 pill from the first bottle, 2 pills from the second bottle, 3 pills
from the third bottle, and so on. Ideally you would have (10)*(11)/2=55 pills weighing 55 grams, when you
put the entire pile of pills on the weighing scale.The deviation from 55 g would tell you which bottle contains
the heavy pills.
If it is .1 gram more, it is 1st bottle which has heavy pill, if it is .2 more, gram 2nd bottle has heavy pills, if it is
.3 more, gram 3rd bottle has heavy pills.
****************************************************************
Solution:
****************************************************************
Puzzle: Albert and Bernard just became friends with Cheryl, and they want to know when her birthday is.
Cheryl gives them a list of 10 possible dates.
May 15 May 16 May 19
June 17 June 18
July 14 July 16
August 14 August 15 August 17
Cheryl then tells Albert and Bernard separately the month and the day of her birthday respectively.
Albert: I don’t know when Cheryl’s birthday is, but I know that Bernard does not know too.
Bernard: At first I don’t know when Cheryl’s birthday is, but I know now.
Albert: Then I also know when Cheryl’s birthday is.
Solution:
The solution involves using logic to deduce the dates which can’t possibly be Cheryl’s birthday.
The dates range from 14 to 19 among the 10 that are given with only 18 and 19 occurring once.
Albert, having seemingly been told the month rather than the day, first says he doesn’t know when her birthday
is – eliminating both 18 and 19 as possible days.
If Cheryl had told Albert that the month was May or June, then the day could have been May 19 or June 18,
and Bernard may have known the right day. But, as the question says, Albert knows Bernard does not,
meaning that Cheryl has said her birthday is in either July or August.
Out of the five remaining days in July and August, the day ranges from 14 to 17, with 14 appearing twice.
If Cheryl told Bernard her birthday was on the 14th, then he would not have known but, he does, meaning it
can’t be on the 14th.
That leaves only 3 possible days: July 16, August 15, and August 17.
After Bernard speaks, saying he knows the birthday given that information, it eliminates August from being a
contender since he still wouldn’t have known
whether it was August 15 or 17.
****************************************************************
Solution:
The green one is telling the truth.
Lets assume that one of them is telling the truth and then try to prove that. Since the four are disagreeing then 3
must be lying.
Lets say blue is telling the truth: so the blue one has either 6 or 8 legs. And each of the other octopus is lying
hence has 7 legs. So our total legs becomes: 6 + 7 + 7 + 7 = 27 legs or 8 + 7 + 7 + 7 = 29 legs. But since blue
said altogether we have 28 legs, we know he is lying.
If you follow this same logic for all of them, you realize that only the Green octopus can be telling the truth as
the number of legs adds up.
****************************************************************
Solution:
100th statement is definitely wrong because it says at least 100 are wrong.
But if that is correct, then 100 statement itself cannot be right.
=> 100th statement is wrong and
=> 1st statement is correct.
99th statement cannot be correct because if it were correct,
then two statements would become correct (1st and 99th itself.)
But 99th statement says that atleast 99 are wrong.
=> 99th is wrong and
=> 2nd is correct.
calculating so on…
50 statements are right (the first 50 ones)
remaining 50 statements are wrong.
****************************************************************
****************************************************************
Solution:
Let’s think of this like a decision tree. Each rand3() will be a decision.
If we somehow generate integers from 1 to a-multiple-of-8 (like 8, 16, 24, …) with equal probability, we can
use modulo division by 8 followed by adding 1 to get the numbers from 1 to 8 with equal probability.
We try to get maximum bunches of 8 as we can (1 – 16, 2 sets of 8). If we get any of the other values, we just
try again. Since the probability of getting each of 16 values are the same every time, trying again won’t affect
their probabilities.
We can generate from 1 to 16 with equal probability using the following expression.
6*rand3() + rand3() – 3
See, how this can be used?
1. For each value of first rand3(), there can be 6 possible combinations for values of second rand3(). So, there
are total 18 combinations possible.
2. The range of values returned by the above equation is 1 to 18, each integer occurring exactly once.
3. If the value of the equation comes out to be less than 17, return modulo division by 8 followed by adding 1.
Else, again call the method recursively. The probability of returning each integer thus becomes 1/8.
****************************************************************
****************************************************************
Solution:
There are 64 different possible outcomes, and in 9 of these, exactly 2 of the balls will be red. There is thus a
slightly better than 14% chance [(9/64)*100] that exactly 2 balls will be red.
A other way to solve the problem is to look at it this way.
There are 3 scenarios where exactly 3 balls are red:
123
———–
RRX
RXR
XRR
Take the first one, for example: 25% chance the first ball is red, multiplied by a 25% chance the second ball is
red, multiplied by a 75% chance the third ball is not red. Because there are 3 scenarios where this outcome
occurs, you multiply the 4.6875% chance of any one occurring by 3, & you get 14.0625%
****************************************************************
If we see realtive speed of the dog1 (v1), w.r.t dog 2, it changes perpendicularly. So it’ll not affect the time
taken along the direction of the dog1 to dog2 and the speed will be only v always.
So if they have started at corners with the distance of the length of the square (d).
****************************************************************
Solution:
The smallest amount of one-dollar and two-dollar bills the cashier may give to the old man is 1×1 + 10×2 = 21.
He must give the old man a multiple of 21 i.e. 21 or 42 or 63 or 84 or 105 or 126 or 147 or 168 or 187 without
exceeding 200. Out of all these numbers only 105 can be added to a multiple of 5 to sum up to make 200
altogether.
Therefore, the cashier must give 5 one-dollar bills, 50 two-dollar bills and 19 five-dollar bills.
****************************************************************
We made the totally unreasonable assumption that job offers are given at random, that if there are 3 people
interviewed, exactly one, chosen at random, will get an offer. That’s not quite the way the world works!
****************************************************************
Solution:
In problems like this, it helps tremendously to create some sort of visual aid that you can refer to. With that in
mind, we have created this table where each entry represents a different horse.
X1 X2 X3 X4 X5
X6 X7 X8 X9 X10
X11 X12 X13 X14 X15
X16 X17 X18 X19 X20
X21 X22 X23 X24 X25
Let’s say that we have 5 races of 5 horses each, so each row in the table above represents a race. So, “X1 X2
X3 X4 X5 ” represents a race, and “X6 X7 X8 X9 X10 ” represents another race, etc. In each row, the fastest
horses are listed in descending order, from the fastest (extreme left) to the slowest (extreme right). The fastest
horses in each race are the ones on the left – so in the first race X1 was the fastest and X5 was the slowest. In
the second race X6 was the fastest, X7 was the second fastest and so on.
Well, now that we’ve had 5 different races, we can eliminate the slowest 2 horses in each group since those
horses are definitely not in the top 3. This would leave these horses:
X1 X2 X3
X6 X7 X8
X11 X12 X13
X16 X17 X18
X21 X22 X23
We also know the 5 fastest horses from each group – but it’s important to remember that the 5 group leaders
are not necessarily the 5 fastest horses. So what can we do with that information?
Well, we can race those 5 horses against each other (X1, X6, X11, X16, and X21) and that would be the 6th
race. Let’s say that the 3 fastest in that group are X1, X6, and X11 – automatically we can eliminate X16 and
X21 since those 2 are definitely not in the top 3.
What other horses can we eliminate after this 6th race? Well, we can automatically eliminate all the horses that
X16 and X21 competed against in the preliminary races – since X16 and X21 are not in the top 3 then we also
know that any horse that’s slower than those 2 is definitely not in the top 3 either. This means we can eliminate
X17 X18 X22 and X23 along with X16 and X21.
Now, we also know that X1 is the fastest horse in the group since he was the fastest horse out of the 5 group
leaders. So, we don’t need to race X1 anymore. Are there any other horses that we can eliminate from further
races? Well, actually there are. Think about it – if X6 and X11 are the 2nd and 3rd fastest in the group leaders,
then we should be able to eliminate X8 since X6 raced against him and he was in 3rd place in that race. X7
could only possibly be the 3rd fastest, and since X8 is slower than X7, we can safely eliminate X8. We can
also eliminate X12 and X13 since X11 was the 3rd fastest in the group leaders, and X12 and X13 were slower
than X11.
So, all together we can eliminate these horses after the 6th race: X17 X18 X22 X23 X16 X21, X12, X13, X8
and X1. This leaves us with the following horses to determine the 2nd and 3rd fastest horses:
X2 X3
X6 X7
X11
This means we only have 5 horses left! Now we race those horses one more time – in the seventh (7th) race –
and we can take out the top 2 horses and that would mean we have the 2nd and 3rd place horses! So, we have
found our answer! It takes 7 races to find the top 3 horses in this problem.
****************************************************************
****************************************************************
On their ship, they decide to split the coins using this scheme:
The oldest pirate proposes how to share the coins, and ALL pirates (including the oldest) vote for or against it.
If 50% or more of the pirates vote for it, then the coins will be shared that way. Otherwise, the pirate proposing
the scheme will be thrown overboard, and the process is repeated with the pirates that remain.
As pirates tend to be a bloodthirsty bunch, if a pirate would get the same number of coins if he voted for or
against a proposal, he will vote against so that the pirate who proposed the plan will be thrown overboard.
Assuming that all 5 pirates are intelligent, rational, greedy, and do not wish to die, (and are rather good at math
for pirates) what will happen?
Answer :
we need to reduce this problem to only 2 pirates. So what happens if there are only 2 pirates. Pirate 2 can
easily propose that he gets all the 100 gold coins. Since he constitutes 50% of the pirates, the proposal has to
be accepted leaving Pirate 1 with nothing.
Now let’s look at 3 pirates situation, Pirate 3 knows that if his proposal does not get accepted, then pirate 2
will get all the gold and pirate 1 will get nothing. So he decides to bribe pirate 1 with one gold coin. Pirate 1
knows that one gold coin is better than nothing so he has to back pirate 3. Pirate 3 proposes {pirate 1, pirate 2,
pirate 3} {1, 0, 99}. Since pirate 1 and 3 will vote for it, it will be accepted.
If there are 4 pirates, pirate 4 needs to get one more pirate to vote for his proposal. Pirate 4 realizes that if he
dies, pirate 2 will get nothing (according to the proposal with 3 pirates) so he can easily bribe pirate 2 with one
gold coin to get his vote. So the distribution will be {0, 1, 0, 99}.
Smart right? Now can you figure out the distribution with 5 pirates? Let’s see. Pirate 5 needs 2 votes and he
knows that if he dies, pirate 1 and 3 will get nothing. He can easily bribe pirates 1 and 3 with one gold coin
each to get their vote. In the end, he proposes {1, 0, 1, 0, 98}. This proposal will get accepted and provide the
maximum amount of gold to pirate 5.
****************************************************************
50) 17 Horses Puzzle
Problem:
A farmer wants to divide his 17 horses among his three sons. According to farmer the oldest son should get
half of the horses,the middle son should get one third of the horses and the youngest son should get one ninth
of the horses.
When their father died they were not able to divide the horses as the result was coming in fractions. As the
sons were fighting on how to divide the horses a traveling mathematician came and heard their problem. He
proposed a solution with which all the sons got their share in the property without harming any animal.
What was the advice given and how the group of horses were divided?
Solution:
Well, this puzzle is interesting. you have to think such that with the solution everybody is happy and no body
will suffer a loss.
Let’s see the problem first.
we have 17 horses to be divided among three sons with the ratio as given.
Now all the results are in fraction so the horses cannot be distributed like this. What will the traveling
mathematician do to solve it.
It’s simple. He will add his horse to the group of horses. So in total we have 18 horses now. Now let’s see the
scenario again.
So in total 17 horses will get distributed among the three sons and the traveling mathematician will take his
horse and leave.
****************************************************************
The prisoners elect a leader and stablish the following rules and behaviours:
– Only the leader can turn the switch #1 off.
– Only the leader can announce that they all visited the room.
– Leader’s behavior:
If the switch #1 is on, turn off the switch #1 and count 1 visit more ( # of visits starts from zero).
If the # of visits is equal to 23 (22 prisoners plus the case were the switch #1 was already on),warns: “We have
all visited the switch room”
If not, flips the switch #2.
– Other’s behavior:
If the switch #1 is turned off and I never turned the switch #1 on, then turn the switch #1 on.
If not, flips the switch #2.
****************************************************************
Solution:
OR,
****************************************************************
Let us name the boxes with a number - Box1, Box 2..., Box10. Now you must be familiar with the weights of
the balls precisely. By saying that we are not implying that you will have to take one ball from every box and
judge the weight of every ball.
What you have to do is pick one ball from Box 1, 2 balls from Box 2, 3 balls from Box 3, ...., 10 balls from
Box 10. Thus after taking balls from every box in such a manner, you will finally have 55 balls in total. There
comes the time to use the weighing machine.
If all the balls were weighing adequate, the combined weight should be 55 x 10 grams = 550 grams. But since
one of the box has defected balls, the weight will be less than that. Here is the tricky part and explains why we
took different number of balls from each box.
If the total weight is less than 1 gram, then the defective box is the Box 1 since we took 1 ball from that box. If
the Box 2 is defective, the total weight will be less than 2 grams. In similar fashion you can identify the
defective box by analyzing the total weight that is calculated by the weighing machine.
****************************************************************
2n - 1
where n is the number of disks. Each binary number is read from the right until the first "1" is
encountered. The position of that "1" from the right indicates the disk to move. If there is no
other "1" in the binary number, that disk is moved to an empty peg. The second "1" from the
right indicates the location of the reference disk. If there are no or an even number of zeros
between these two "1"s (the first two "1"s from the right), the moving disk is moved so as to
cover the reference disk. If there is an odd number of zeros between these two "1"s, the
moving disk is moved so as NOT to cover the reference disk.
The table below lists the 25- 1 = 31 sequential moves required for a tower with five
disks. Try it with the interactive tower in Towers of Hanoi Puzzle. Before you begin,
reset the number of blocks (disks) to five (5).
**************************************************************
Answer:
49*(6*5+3)+(6*6)= 1653
From Over 1 to 49:
1st ball:- 6 runs(hit six)
2nd ball:- 6 runs(hit six)
3rd ball:- 6 runs(hit six)
4th ball:- 6 runs(hit six)
5th ball:- 6 runs(hit six)
6th ball:- 3 runs(took 3 runs between the wickets and take back the strike)
= >49*(6*5+3)
50th Over:
Hit six sixes in a row.
= >6*6
****************************************************************
We strongly recommend you to minimize your browser and try this yourself first
Answer:
The Prisoner said, ‘I will be shot dead’
If Policeman says the statement is true, the Prisoner will be hanged to death which will make his statement false.
If Policeman says the statement is false, the Prisoner will be shot dead which will make the statement true.
****************************************************************
Answer:
One year can have only one palindrome as the year fixes the month and date too, so the year has to be less than
2001 since we already have the palindrome for 10/02. It can’t be any year in 1900 because that would result in a day
of 91, same for 1800 down to 1400. it could be a year in 1300 because that would be the 31st day.
Answer: 25000
Divide the lifetime of spare tire into 4 equal part i.e., 5000 and swap it at each completion of 5000 miles distance.
Let four tyres be A, B, C and D and spare tyre be S.
5000 KMs: Replace A with S.
10000 KMs: Put A back to its original position and replace B with S
15000 KMs: Put B back to its original position and replace C with S
20000 KMs: Put C back to its original position and replace D with S
All tyres are used upto their full strength.
****************************************************************
66) Newspaper Puzzle
Question: A newspaper made of 16 large sheets of paper folded in half. The newspaper has 64 pages altogether.
The first sheet contains pages 1, 2, 63, 64.
If we pick up a sheet containing page number 45. What are the other pages that this sheet contains?
Answer:
On the back of 45, it is 46.
Then,
64-45=19
66-46 = 20
So the four pages in this sheet are 19, 20, 45, 46.
So the four pages in this sheet are 19, 20, 45, 46.
****************************************************************
Answer:
No
Explanation:
At first it seems that there were 8*8 = 64 squares
then 2 have been cut off so Squares remaining= 64-2 = 62
And there are 31 dominos, so they will cover the remaining chessboard coz = 31*2 = 62
But this is not the answer:
Lets visualize it:
Each domino we set on the chessboard will always take 1 Black and 1 White square.Therefore, 31 dominos will
take 31 white square and 31 black squares exactly. On this chessbord however, we must have 32 black and 30
white squares. Hence it is not possible to do so.
****************************************************************
****************************************************************
20 15 30 10 14
Second player picks 20, now row of coins is
15 30 10 14
30 10 14
10
Solution:
The idea is to count sum of values of all even coins and odd coins, compare the two values. The player that makes
the first move can always make sure that the other player is never able to choose an even coin if sum of even coins is
higher. Similarly, he/she can make sure that the other player is never able to choose an odd coin if sum of odd coins
is higher.
Example
18 20 15 30 10 14
Sum of odd coins = 18 + 15 + 10 = 43
Sum of even coins = 20 + 30 + 14 = 64.
Since the sum of even coins is more, the first
player decides to collect all even coins. He first
picks 14, now the other player can only pick a coin
(10 or 18). Whichever is picked the other player,
the first player again gets an opportunity to pick
an even coin and block all even coins.
****************************************************************
Solution:
We can represent any decimal number as weights of binary system. For example, if we want to measure upto 7, first
three bags are sufficient.
1 = 2^0
2 = 2^1
3 = 2^0 + 2^1
4 = 2^2
5 = 2^2 + 2^0
6 = 2^2 + 2^1
7 = 2^2 + 2^1 + 2^0
It can be easily generalized. We can measure upto 2^n – 1.
Fun is, we can also measure the same using powers of 3. For example, we have bags with 1, 3 and 9 coins,
1=1
2 = 3-1
3=3
4 = 3+1
5 = 9-3-1
6 = 9-3
7 = 9+1-3
8 = 9 -1
9=9
10 = 9+1
11 = 9+3-1
12 = 9+3
13 = 9+3+1
From 14 onwards next bag comes into picture.
Factorization algorithms other than powers of 2 are costly on computer systems. Please share any other information.
Any person working on cryptography can share more details.
****************************************************************
Solution:
O will win the game. The sixth mark was X in square 9.
Explanation:
The 7th mark must be placed in square 5 which is the win situation for both X and O. Hence, the 6th mark must be
placed in a line already containing two of the opponents marks. There are two such possibilities – the 6th mark would
have been either O in square 7 or X in square 9.
As we know both the players are intelligent enough, the 6th mark could not be O in square 7. Instead, he would have
placed O in square 5 and would have won.
Hence, the sixth mark must be X placed in square 9. And the seventh mark will be O. Thus O will win the game.