Commonly asked interview puzzles – Part II

Kunal Jain 25 Jun, 2019
6 min read

Introduction

Most of the analysts love solving and asking puzzles. Some of the best analysts I know, have a glean in their eyes at mention of a difficult logic puzzle. While these puzzles are fun to solve in free time, they might look scary to other people facing them in an interview backdrop.

As Tavish mentioned in his article, use of puzzles to select candidates may not be the best way to do the recruitment. But, the reality is that puzzles get asked as part of many interviews. This also turns out to be an advantage for you, if you have solved these kind of puzzles before hand. This article will lay out a few more puzzles, which are commonly asked in interviews.

Puzzles are one aspect of the entire data science interview process. We have listed down a comprehensive 7-step framework to crack data science interviews and land your dream role in the ‘Ace Data Science Interviews‘ course. Head over to the portal and enroll today!

I have divided the puzzles in 3 Stages (sort of gamification). Puzzles in stage 1 are simple. Hence, I’ll not give the solution to them. If you are not getting solution to them, you are not applying yourself. You should spend some time thinking about them and you would be able to get the answer. Stage 2 are tougher than Stage 1 and should be more interesting as well. I have included some common approaches people take and the right solution to these interview puzzles. Stage 3 is the most difficult out of these 3 stages and I’ll release the solution to the puzzle next week.

If you have come across any other puzzle in analytics interviews, please feel free to share them through comments and let us try and solve them as a community.

 

Stage 1 – Simple Puzzles

Puzzle 1 – 3 switches and a light

You have 3 switches in a room. One of them is for a bulb in next room. You can not see whether the bulb is on or off, until you enter the room. What is the minimum number of times you need to go in to the room to determine which switch corresponds to the bulb in next room.

 3switch and bulb

Answer – 1

 

Puzzle 2 – Mis-labeled bags

You have 3 bags with you – one with pink toys only, one with blue toys only and one with a mix of two colors. But, the labels on all three bags are wrong. What is the minimum number of draws you would need to make, in order to identify all three bags correctly.

Answer – 1

Hint – All the bags carry wrong label

 

Stage 2 – Let’s make it interesting

Puzzle 3: Find the defective coin

There are 10 stacks of 10 coins each. Each coin weights 10 gms. However, one stack of coins is defective and each coin in that stack weights only 9 gms. What is the minimum number of weights you need to take to find which stack is defective? How?

 10 coin stacks

Typical Solution:

The dumbest answer in this situation would be 10 (or 9) attempts, when you weigh each stack. A few people try to arrive at a solution with divide and rule method – divide the stacks in 2 groups of 5 each and weigh any one of them – if it weighs 500 gms then the other group has defective stack. In the next turn you divide the remaining stacks in 2 groups and weigh again. In this manner, you can get to the defective coin in a maximum of 4 measurements at your weighing machine. While this approach is smarter than 10 attempts, it is still not the most efficient way.

 

Correct solution:

The trick in solving this puzzle lies in creating a weighted stack for measurement. You can find the defective stack in one measurement. How? You take 1 coin from the first stack, 2 coins from the second, 3 from the third and so on. In total you will have 55 coins. If all of them were non-defective, they would weigh 550 gms. If stack 1 is defective, the measure would read 549 gms. If stack 2 is defective, you will read 548 gms. and so on. So by taking one measurement you can identify, which is the defective stack.

A variation – How many measuring attempts would you need, if there were 11 stacks of 10 coins each and one was defective? 

 

Puzzle 4: Finding the Fastest horses

You have 25 horses and you can race only 5 of them simultaneously. Assuming you do not have access to stop-watch, how many times would you need to race the horses to find the 3 fastest horses.

 

Typical solutions:

This puzzle typically sees some wide variety of responses. One popular answer is to race all 25 horses through 5 races, then pick the 3 winners from each round – that leaves you with 15 horses. You race them in three rounds to find the 9 fastest and then race 9 to find 6 fastest and then do 2 races with replacement of slow horses from first race to find out the fastest horses. That gives us a total of 12 races. Some answers, I have heard even say 11 races.

 

Correct solution:

You need 7 races to find out the fastest horses. First do 5 races and identify all the winners, then make them run simultaneously to identify top 3 horses among the winners. The winner of the 6th race is the fastest horse of the bunch. Now, we need to find the second and third – so we take second and third position horses from the group of fastest horse along with the second position horse from the group of horse who came 2nd in sixth race and race them along with the position 2 and position 3 horses from 6th race. The winner and runner up of this race are your second and third best horses.

 

 

Puzzle 5: Red and Blue balls in a bag

You have 20 blue and 13 red balls in a bag. You pull out 2 balls one after another. If the balls are of same color, then you replace them with a Blue ball – but if they are of different color, you replace them with a Red ball. Once you take out the balls, you do not put them back in the bag – so the balls keep reducing. What would be the color of the last ball remaining in the bag.

 

Typical solution:

A lot of people start calculating probabilities and try to create some sort of a series out of the pattern. I got a similar puzzle in one of the interviews and I tried doing that as well. But, if you go down that route, this becomes very tough and unmanageable. The key to solving this puzzle is to realize that there are odd number of red balls in the bag.

 

Correct solution:

The right answer is Red. This puzzle looks like a difficult one, till you find out the solution. But, the minute you get the solution, you feel that this was dead simple. If you pull out 2 red balls, you replace them with a blue ball. On the other hand, if you pull out one red and one blue – you replace it with a red ball. So, the red balls would always be odd in numbers – either you remove 2 together or remove 1 and add 1 – so they remain odd always. Hence, the last ball to stay in the bag would be a red ball.

 

Stage 3 – Only for the pros

This puzzle is meant to be solved, if you have done all of the ones above. Again, I won’t release the solution – if you get the solution, you can write it down in comments. If you don’t – I’ll put the answer 7 days after the article is made live. Go – scratch your head!

Puzzle 6 – King and Wine

You are the ruler of an empire and you are about to have a celebration tomorrow. The celebration is the most important party you have ever hosted. You’ve got 1000 bottles of wine you were planning to open for the celebration, but you find out that one of them has been poisoned by your enemy. The poison exhibits no symptoms until death and the death occurs within fifteen hours of consuming even a diluted sample.

You have over a thousand slaves at your disposal and just under 24 hours to determine which single bottle is poisoned. You also have 30 prisoners about to be executed, and it would mar your celebration to have anyone else killed. What is the minimum number of prisoners, you must have to drink from the bottles to be absolutely sure to find the poisoned bottle within 24 hours?

 

These were some commonly asked interview puzzles. If you know of any other puzzle which employers ask in an analytics interview – please feel free to share.

If you like what you just read & want to continue your analytics learningsubscribe to our emailsfollow us on twitter or like our facebook page.

Kunal Jain 25 Jun, 2019

Frequently Asked Questions

Lorem ipsum dolor sit amet, consectetur adipiscing elit,