Data science interviews usually consist of questions around the core subject, business case studies, guess estimates and puzzles. Puzzles are a favourite kind of questions among the interviewers especially if the candidate is a fresher and the hiring is being done at a beginner or entry-level. It is to test the problem-solving and out of the box thinking that is a must-have for analytics and data science jobs.

Puzzles are a way to test logical reasoning and lateral thinking of a candidate. In this article, we bring 10 frequently asked puzzles in a data science interview ranging across technical, straight-forward and some brainstorming questions. While the interviewers expect the right answer from you, more often than not they are testing your approach to solving problems and probably your patience. These questions have been compiled from the various discussion portals and from interviewees who had appeared for analytics and data science interviews.

REGISTER>>

#### 1. Four people A, B, C, D need to cross a bridge at night, and they have only one torch. The bridge is too dangerous to cross without a torch and is strong enough to support a maximum of two people at a time. They take 1, 2, 5 and 8 minutes respectively. What is the shortest time needed for all four of them to cross the bridge?

This is one of the most commonly asked questions with an easy answer. A & B, the two fastest persons can cross the bridge first. In 2 minutes they can cross the bridge. B stays on the other end and A gets the torch back in 1 minute. This makes the total time of 3 minutes. Now, C & D can cross the bridge who take 5 & 8 minutes respectively. Total time taken by them to cross the bridge is 8 minutes. Now, the total time taken is 3 + 8 minutes, which is 11 minutes. Now C & D stay on the other side, and B comes back in 2 minutes. This makes the total time spent as 11 + 2 which is 13 minutes. Finally, A & B will cross the bridge in 2 minutes, making the total time 13 + 2, which is 15 minutes. So the minimum time taken by them to cross the bridge is 15 minutes.

#### 2. There are 100 black socks and 100 white socks mixed up in a drawer. If you have to pick socks blindly from the drawer, how many socks do you need to take out to be sure that you have a matching pair of socks?

It is important to note that it is asking for a matching pair of socks and not a specific colour. If you think thoroughly, 3 socks are the minimum number of socks that need to be pulled out for it to be a matching pair. If we take out 3 socks from the drawer blindly, the combinations that come out can be WBB, WWB, WWW, BWW, BBW, BBB, where B and W are black and white colours respectively. Therefore picking 3 socks from the drawer must get us either black or white socks.

#### 3. There are 9 balls which weigh the same except for one, which is heavier than the others. What is the minimum number of weighings should you perform to find the ball with higher weight?

While this may be the simple and most overused questions of all times, it might still get candidates stuck for a while. If we carefully analyse, the answer is two weighings. Let us name the balls: 1, 2, 3, 4, 5, 6, 7, 8 and 9. Now, weigh 123 vs. 456.

Scenario 1: If these balance out, the heavier balls is one of 789. In this case, weigh 7 vs. 8. If these balance out, the heavier ball is 9. If not, either 7 or 8 is the heavier ball.

Scenario 2: If they do not balance out, the heavier side has the oddball. Assuming the 123 weighs heavier than 456, then weigh 1 vs. 2. If they balance out 3 is the heavier ball, if not either 1 or 2 is.

Therefore, we would need to take minimum 2 weighings to get the right answer.

#### 4. There are 100 doors and they are all closed. A person walks through these 100 doors 100 times. Each time he toggles some of the doors, i.e closes if open and opens if it is closed. In the first walk, he will toggle all the doors. In the second walk, he will toggle every second door, i.e., 2nd, 4th, 6th, 8th and so on. In the third walk, he will toggle every third door, i.e. 3rd, 6th, 9th and so on. So after the 100th walk, which doors will be open and which will be closed?

The question may sound confusing in the first go, but if thought thoroughly, the answer to this one isn’t far away. First, the person visits the door and opens all of them as they are initially closed. Now, the second time the person visits 2nd, 4th, 6th, doors…and so on, and will close them, since they are open. The third time, the person visits door numbers 3, 6, 9, 12 and so on. He/she will close the doors 3rd, 9th since they are open and will open the doors 6th, 12th, as they are closed. The fourth time, the person will visit doors 4th, 8th, 12th, 16th and so on, and will close 12th.., since they are open and will open 4th, 8th, since they are closed. This implies that the door number which has an odd number of factors will remain open. The trick to remember is that only perfect square numbers can have an odd number of factors.

Therefore, after the 100th walk, doors number 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100 will be open and rest will be closed.

#### 5. There are two sand timers which show 4 minutes and 7 minutes respectively. What would be the best approach to get a time of 9 minutes using both the sand timers, at one time or one after another or in any other combination?

Initially both the hour glasses are ideal. Turn both of them simultaneously. At the completion of 4 minutes, the smaller hourglass is finished, and the bigger one has 3 minutes left. At this point, restart the smaller timer by turning upside down and continue the process. At the completion of 7 minutes, the bigger hour glass is completely finished and the smaller one has 1 minute remaining. Now turn the bigger hourglass upside down. At the completion of 8 minutes, the smaller one is finished and the bigger one has run only for 1 minute. At this point when you turn it upside down, the total timing would be 9 minutes.

#### 6. There are four men A, B, C and D buried up to their necks in the ground in a straight line. Between A & B there is an opaque wall. They cannot move and can only look forward such that A and B can only see their respective sides of the wall, C can see B, and D can see B and C. They are all aware that each of them is wearing a hat, and that two of them are wearing a black hats while the other two are wearing white hats. They don’t know what color they are wearing. In order to avoid being executed, one of them must call out to the executioner the color of their hat. If they get it wrong, everyone will be shot. After 60 seconds, one of them calls out. Which one of them calls out? How can he be certain he knows the color of his hat? There’s no outside influence and no other way of communicating.

In the given scenario, A or B cannot answer since they are facing the wall and cannot determine anyone’s hat colour. D can see C and B but cannot determine his own hat colour. This leaves only C with the chances of answering and he calls out that he is wearing a black hat. He is 100% certain as, if D would have seen both B & C wearing white or black hats, he would have answered. But since D is silent, C knows that he must be wearing a black hat as he can see that B is wearing a white hat.

#### 7. There are two ropes and a lighter. Each rope takes exactly 60 minutes to burn completely. But the ropes do not burn at a constant rate, so you do not know that half the rope burns in 30 minutes. For instance, if one end of the rope is lit, it may take 5 minutes to burn the first half of it, and 55 minutes to burn the second half. How can you measure exactly 45 minutes by burning the ropes?

Fairly tricky riddle, this one has a simple approach. Take one rope and burn it at both ends. At the same time, burn only one end of the other rope. The rope which has both ends burning will burn the 2 times the speed of the second one and hence will burn in 30 minutes. At this point, the second rope will have 30 minutes to burn. At this point, burning the other end of the rope will burn at double the speed. So that remaining rope will burn in 15 minutes. Adding up this 30 minutes and 15 minutes gives us 45 minutes.

#### 8. How many times a day do the minute and hour hands of a clock overlap?

This relatively straightforward question, tests your mathematical skills and might require you to go back to time and distance lessons to get the right answer.

We know time = distance/speed. Also 1 day is 24 hours or 24 * 60 minutes which is 1440 minutes. Now determining the angular speed of the minute hand. Minute hand of the clock moves 360 degrees in 1 hour or 60 minutes. So the speed of a minute hand in 1 minute is 360 / 60 = 6 degrees per minute.

Now, determining the angular speed of the hour hand. Hour and of clock moves 360 degrees in 12 hours of 12 * 60= 720 minutes. So the speed of the hour hand is 360/720 = ½ degrees per minute.

Now, according to the concept of relative speed, when two objects say, A & B move in the same direction, then their relative speed is A -B. Therefore angular relative speed between minute and hour hand is 6 – ½ = 11/2 degrees per minute.

If we consider 12 PM as the reference point where minutes and hours coincide, the angular distance covered between them is 360 degrees.

Now time = angular distance/angular relative speed, which is 360 / (11/2) = 720/11 minutes or 65.45 minutes.

This means that every 720/11 minutes the minute hand and clock hand coincide.

So, in a day which is 1440 minutes it meets, 1440/ (720/11), which is 22 times.

#### 9. There are 2 jars with 50 red marbles and 50 blue marbles. You need to place all the marbles into the jars in such a way that if you blindly pick one marble out of the jar, there are maximum chances of it being red. While picking, you will first randomly pick a jar and then randomly pick a marble out of that jar. You can arrange the marbles however you like, but each marble must be in a jar.

If we put a single red marble in one jar and the rest of the marbles in the other jar, there is at least a 50% chance of getting a red marble (since one marble picked at random, doesn’t leave any room for choice). Now there are 49 red marbles left in the other jar and there is nearly even chance of picking a red marble (49 out of 99). Calculating the total probability will give us:

P (red marble ) = P(Jar 1) * P (red marble in Jar 1) + P (Jar 2) * P (red marble in Jar 2)

P (red marble) = 0.5 * 1 + 0.5 * 49/99

P (red marble ) = 0.7474

Thus, we end up with ~75% chance of picking a red marble.

#### 10. At a party, everyone shook hands with everybody else. There were 66 handshakes. How many people were at the party?

If there are n+1 people.

no. of handshakes = n

n * (n+1)/2 = 66

n = 12

So there were 12 people at the party.

You can check more puzzles here.

##### Join Our Telegram Group. Be part of an engaging online community. Join Here.

## Subscribe to our Newsletter

Get the latest updates and relevant offers by sharing your email.Srishti currently works as Associate Editor at Analytics India Magazine. When not covering the analytics news, editing and writing articles, she could be found reading or capturing thoughts into pictures.