20 Challenging Job Interview Puzzles Whichevery Analyst Should Solve Atleast Once
20 Challenging Job Interview Puzzles Whichevery Analyst Should Solve Atleast Once
Introduction
In current scenario, getting your first break into analytics can be difficult. Around 30% of
analytics companies (specially the top ones) evaluate candidates on their prowess at
solving puzzles. It implies that you are logical, creative and good with numbers.
The ability to bring unique perspective into solving business problems can provide you a
huge advantage over other candidates. Such abilities can only be develop with regular
practice and consistent efforts.
For me, solving puzzles is like mental exercise. I do it everyday and have fairly improved
over period of time. To help you achieve this skill, I am sharing some of the trickiest &
head scratching questions Ive come across in my journey. These questions have been
asked at companies like Goldman Sachs, Amazon, Google, JP Morgan etc.
P.S I want you to try solving them before checking the solution. Do share your logic &
solutions in the comments. Id love to see how uniquely can someone think!
#1 Bag of Coins
Answer: 1 reading.
1/17
#2 Prisoners and hats
The executioner will ask each prisoner what colour of hat they are wearing one by one,
starting from the last in the line. The prisoner can only speak Red or Blue. He cannot
say anything else. If he gets it right, he lives otherwise he is shot instantly. All the
prisoners standing in front of him can hear the answers and gunshots.
Assuming that the prisoners are intelligent and would stick to the plan, what strategy
would the prisoners make over the night to minimize the number of deaths?
Answer:
The strategy is that the last person will say red if the number of red hats in front of him
are odd and blue if the number of red hats in front of him are even. Now, the 99th guy
will see the if the red hats in front of him are odd or even. If it is odd then obviously the
hat above him is blue, else it is red. From now on, its pretty intuitive.
#3 Blind games
Answer:
2/17
Divide the group into two groups of 40 coins and 10 coins. Flip all coins of the group with
10 coins.
#4 Sand timers
You have two sand timers, which can show 4 minutes and
7 minutes respectively. Use both the sand timers(at a time
or one after other or any other combination) and measure a
time of 9 minutes.
Answer:
So effectively 8 + 1 = 9.
Answer:
The final answer is the probability that the last person ends in up in his proper seat is
exactly 1/2
3/17
First, observe that the fate of the last person is determined the moment either the first or
the last seat is selected! This is because the last person will either get the first seat or the
last seat. Any other seat will necessarily be taken by the time the last guy gets to
choose.
Since at each choice step, the first or last is equally probable to be taken, the last person
will get either the first or last with equal probability: 1/2.
Answer:
Write 100 in binary, which is 1100100 and take the complement which is 11011 and it is
27. Subtract the complement from the original number. So 100 27 = 73.
For the number in form 2^n, it will be the first person. Lets take an example:
64 = 1000000
64-63 = 1.
4/17
Four glasses are placed on the corners of a
square Lazy Susan (a square plate which
can rotate about its center). Some of the
glasses are upright (up) and some upside-
down (down).
The glasses may be rearranged in turns with subject to the following rules: Any two
glasses may be inspected in one turn and after feeling their orientation the person may
reverse the orientation of either, neither or both glasses. After each turn the Lazy Susan
is rotated through a random angle.
The puzzle is to devise an algorithm which allows the blindfolded person to ensure that all
glasses have the same orientation (either up or down) in a finite number of turns. (The
algorithm must be deterministic, i.e. non-probabilistic )
Answer:
This algorithm guarantees that the bell will ring in at most five turns:
1. On the first turn, choose a diagonally opposite pair of glasses and turn both glasses
up.
2. 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.
3. 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.
4. 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.
5. On the fifth turn, choose a diagonally opposite pair of glasses and reverse both.
The bell will ring.
5/17
There are 10 incredibly smart boys at
school: A, B, C, D, E, F, G, H, I and Sam.
They run into class laughing at 8:58 am,
just two minutes before the playtime ends
and are stopped by a stern looking
teacher: Mr Rabbit.
Silence!, he shouts. Nobody will talk. All of you who have mud on your faces, get out of
the class!. The kids look at each other. Each kid could see whether the other kids had
mud on their faces, but could not see his own face. Nobody goes out of the class.
I said, all of you who have mud on your faces, get out of the class!
Still nobody leaves. After trying 5 more times, the bell rings at 9 and Mr
Rabbit exasperatedly yells: I can clearly see that at least one of you kids has mud on his
face!.
The kids grin, knowing that their ordeal will be over soon. Sure enough, after a few more
times bawling of All of you who have mud on your faces, get out of the class!, A, B, C
and D walk out of the class.
Explain how A, B, C and D knew that they had mud on their faces. What made the kids
grin? Everybody knew that there was at least one kid with mud on his face. Support with a
logical statement that a kid did not know before Mr Rabbits exasperated yell at 9, but that
the kid knew right after it.
Answer:
After Mr Rabbits first shout, they understood that at least one boy has mud on his face.
So, if it was exactly one boy, then the boy would know that he had mud on his face and
go out after one shouting.
Since nobody went out after one shouting, they understood that at least two boys have
mud on their faces. If it were exactly two boys, those boys would know (they would see
only one others muddy face and theyd understand their face is muddy too) and go out
after the next shouting.
Since nobody went out after the second shouting, it means there are atleast three muddy
faces And so on, after the fourth shouting, A, B, C and D would go out of the class.
This explanation does leave some questions open. Everybody knew at least three others
had mud on their faces, why did they have to wait for Mr. Rabbits shout at the first place?
Why did they have to go through the all four shoutings after that as well?
6/17
In multi-agent reasoning, an important concept arises of common knowledge. Everybody
knows that there are at least three muddy faces but they cannot act together on that
information without knowing that everybody else knows that too. And that everybody
knows that everybody knows that and so on. This is what well be analyzing. It requires
some imagination, so be prepared.
A knows that B, C and D have mud on their faces. A does not know if B knows that three
people have mud on their faces. A knows that B knows that two people have mud on their
faces. But A cant expect people to act on that information because A does not know if B
knows that C knows that there are two people with mud on their faces. If you think this is
all uselessly complicated, consider this:
A can imagine a world in which he does not have mud on his face. (Call this world A) In
As world, A can imagine B having a world where both A and B do not have mud on their
faces. (Call this world AB)
A can imagine a world where B imagines that C imagines that D imagines that nobody
has mud on their faces. (Call this world ABCD). So when Mr Rabbit shouted initially, it
could have been that nobody was going out because a world ABCD was possible in
which nobody should be going out anyway.
So heres a statement that changes after Mr. Rabbits yell. World ABCD is not possible
i.e. A cannot imagine a world where B imagines that C imagines that D imagines that
nobody has mud on their faces. So now in world ABC, D knows he has mud on his face.
And in world ABD, C knows he has mud on his face and so on.
Answer:
Assign to each of the 7 colours a unique number from 0-6. Henceforth, we will only be
doing modular arithmetic (modulo 7).
7/17
Assign to each of the 7 prisoners a unique number from 0-6. If the number assigned to
prisoner P is N, then P always guesses that the sum of the colours assigned to all
prisoners is M (modulo 7). Thus, he calculates his own colour under this assumption ( =
(M - sum(colours of the 6 prisoners he can see))%7 ).
There will always be a prisoner who guesses the correct sum (as the sum lies in 0-6), and
this prisoner therefore correctly guesses his own colour.
If there is a solution, then exactly one prisoner is correct (no more). This is because there
are 7^7 scenarios.
Each prisoners response is a function of the colours of the other 6, so if you fix their
colours and vary his colour, you can see that he will be correct in exactly one-seventh of
the cases (=7^6). The sum (across all scenarios) of the number of prisoners who are
correct is 7*(7^6)=7^7.
If each scenario is to have at least one person right, this implies that each scenario
cannot have more than one person who is right.
Being right about ones colour is equivalent to being right about the sum of colours of all
prisoners (modulo 7). (The colours of the other 6 are known.) So guessing ones colour is
the same as guessing the sum. How do we make sure that at least one person guesses
the correct sum? By making sure that everybody guesses a different sum.
Answer:
The answer is 2 1.
Then for n aliens, the probability of eventually dying out is xn because we consider
every alien as a separate colony. Now, if we compare aliens before and after the first day,
we get:
(x 1)(x 2 + 2x 1) = 0
We get, x = 1, 1 2 , or 1 + 2
We claim that x cannot be 1, which would mean that all aliens eventually die out. The
number of aliens in the colony is, on average, multiplied by 0+1+2+3 4 = 1.5 every
minute, which means in general the aliens do not die out. (A more rigorous line of
reasoning is included below.) Because x is not negative, the only valid solution is x = 2
1.
Let x n be the probability that a colony of one bacteria will die out after at most n minutes.
Then, we get the relation:
xn + 1 = 1/4 (1 + x n + x n + xn)
xk+1 1/4 (1 + x k + x k + x k )
1/4 ( 1 + ( 2 1) + ( 2 1) + ( 2 1) )
= 2 1
which completes the proof that xn 2 1 for all n. Now, we note that as n becomes
large, xn approaches x. Using formal notation, this is:
x = lim (n ) xn 2 1 , so x cannot be 1.
#11 Lumos
Answer:
d1 = x cosec ()
d2 = (3 - x) cosec ()
d3 = (3 - y) cosec ()
9/17
d4 = y cosec ()
= 6 cosec ()
Answer:
(For centre to lie in the tetrahedron D should lie in the triangle i.e the opposite
hemisphere of ABC)
10/17
In a country in which people only want boys, every
family continues to have children until they have a
boy. If they have a girl, they have another child. If
they have a boy, they stop. What is the proportion
of boys to girls in the country?
Answer:
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
11/17
that 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 wedding
party in 5 weeks time.
Explain what is in mind of the king, how will he be able to do so ? (he has only 10
prisoners in his prisons)
Answer:
The number the bottles are 1 to 1000. Now, write the number in binary format. We can
write it as:
bottle 2 = 0000000010
Now, take 10 prisoners and number them 1 to 10. Let prisoner 1 take a sip from every
bottle that has a 1 in its least significant bit. And, this process will continue for every
prisoner until the last prisoner is reached. For example:
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. We know, 1000 is less than 1024 (2^10). Therefore, if there were 1024 or
more bottles of wine it would take more than 10 prisoners.
12/17
You and your friend are caught by
gangsters and made to play a game to
determine if you should live or die. The
game is simple.
What is the probability of you surviving if you and your friend play the game optimally?
Answer:
We know, A and B have picked a card at random from a deck. A can see Bs card and
vice versa. So, A knows (s)he has not picked Bs card, but apart from that, (s)he knows
that the card is equally probable to be any of the other 51 cards. So, if A guesses Bs
card, they lose. But if A guesses any other card, theres a 1/51 chance that A is right. This
also implies that total probability of success <= 1/51.
As aim now is to tell any card apart from Bs card that gives B the most information about
Bs own card. So they can plan beforehand as follows:
Consider the sequence of cards Clubs 1-13, Diamonds 1-13, Hearts 1-13, Spades 1-13.
A will tell the card after Bs card in this sequence. (If A says 4 of Hearts, it means B has 3
of Hearts. If A says Ace of Clubs, it means B has King of Spades)
With As guess, which is always different from Bs card, B gets to know exactly which card
(s)he has and can always guess correctly. So the probability of success is 1/51, which is
the maximum achievable.
Answer:
If {8, 9} is heavier, then either 9 is heavy or 10 is light or 11 is light. Weigh {10} and {11}. If
they balance, 9 is fake (heavier). If they dont balance then whichever one is lighter is fake
(lighter).
If {8, 9} is lighter, then either 9 is light or 10 is heavy or 11 is heavy. Weigh {10} and {11}.
If they balance, 9 is fake (lighter). If they dont balance then whichever one is heavier is
fake (heavier).
If {1,2,3,4} is heavier, we know either one of {1,2,3,4} heavier or one of {5,6,7,8} is lighter
but it is guarantees that {9,10,11,12} are not fake. This is where it gets really tricky, watch
carefully. Weigh {1,2,5} and {3,6,9} (Note: 9 is surely not fake).
If they balance, then either 4 is heavy or 7 is light or 8 is light. Following the last step from
the previous case, we weigh {7} and {8}. If they balance, 4 is fake(heavier). If they dont
balance then whichever one is lighter is fake (lighter).
If {1,2,5} is heavier, then either 1 is heavy or 2 is heavy or 6 is light. Weigh {1} and {2}. If
they balance, 6 is fake (lighter). If they dont balance then whichever one is heavier is fake
(heavier).
If {3,6,9} is heavier, then either 3 is heavy or 5 is light. Weigh {5} and {9}. They wont
balance. If {5} is lighter, 5 is fake (lighter). If they balance, 3 is fake (heavier).
If {5,6,7,8} is heavier, it is the same situation as if {1,2,3,4} was heavier. Just perform the
same steps using 5,6,7 and 8. Unless maybe you are too lazy to try and reprocess the
steps, then you continue reading the solution. Weigh {5,6,1} and {7,2,9} (Note: 9 is surely
not fake).
If they balance, then either 8 is heavy or 3 is light or 4 is light. Following the last step from
the previous case, we weigh {3} and {4}. If they balance, 8 is fake(heavier). If they dont
balance then whichever one is lighter is fake (lighter).
If {5,6,1} is heavier, then either 5 is heavy or 6 is heavy or 2 is light. Weigh {5} and {6}. If
they balance, 2 is fake (lighter). If they dont balance then whichever one is heavier is fake
(heavier).
If {7,2,9} is heavier, then either 7 is heavy or 1 is light. Weigh {1} and {9}. If they balance,
7 is fake (heavier). If they dont balance then 1 is fake (lighter).
14/17
Robin and Williams are playing a game. An unbiased
coin is tossed repeatedly. Robin wins as soon as the
sequence of tosses HHT appears. Williams wins as
soon as the sequence of tosses HTH appears. The
game ends when one of them wins. What are the
probabilities of winning for each player?
p = (1/2)*p + .
Let the first toss be heads. If the second toss is heads, then Robin definitely wins. Since
HH has occurred, and at some point, tails will occur, so HHT will occur. Hence Robin
wins with probability 1 for HH.
Let the second toss be tails. If the third toss is heads, Robin loses as HTH occurs. If the
third toss is tails (HTT) since two tails have occurred in a row, now it is as good as the
game has started from the beginning, so the chances of Robin winning are back to p.
T HH HTH HTT
15/17
On an island live 13 purple, 15 yellow and
17 maroon chameleons. When two
chameleons of different colors meet, they
both change into the third color. Is there a
sequence of pairwise meetings after which
all chameleons have the same color?
Answer:
An interesting property of X is that its value does not change after any pairwise meeting
because
X(p, y, m) = X(p-1, y-1, m+2) = X(p-1, y+2, m-1) = X(p+2, y-1, m-1)
This means that there is no sequence of pairwise meetings after which all chameleons
will have identical colour.
Hints:
16/17
1. The British man lives in a red house.
2. The Swedish man keeps dogs as pets.
3. The Danish man drinks tea.
4. The Green house is next to, and on the left of the White house.
5. The owner of the Green house drinks coffee.
6. The person who smokes Pall Mall rears birds.
7. The owner of the Yellow house smokes Dunhill.
8. The man living in the center house drinks milk.
9. The Norwegian lives in the first house.
10. The man who smokes Blends lives next to the one who keeps cats.
11. The man who keeps horses lives next to the man who smokes Dunhill.
12. The man who smokes Blue Master drinks beer.
13. The German smokes Prince.
14. The Norwegian lives next to the blue house.
15. The Blends smoker lives next to the one who drinks water.
End Notes
I hope these questions would have dared you enough to get your brain rolling. I
understand these question might appear as challenging to a lot of you, but believe me,
they arent difficult. If you find any trouble in understanding any solution or question, feel
free to drop me a message below.
Ive obtained the solution from various sources. Also, Ive answered some on my own. Try
to understand these questions well. Once you do it, youd find it easier to solve similar
questions during interviews.
Did you like solving these puzzles? Do let me know your experience, suggestions &
solutions in the comments below. I am excited to see if you can think any different!
You can test your skills and knowledge. Check out Live Competitions and
compete with best Data Scientists from all over the world.
17/17