# Nagarro Interview Puzzle

Posted on :05-04-2016

Q1. Four people need to cross a dark river at night.

* They have only one torch and the river is too risky to cross without the torch.
* If all people cross simultaneously then torch light wont be sufficient.
* Speed of each person of crossing the river is different. cross time for each person is 1 min, 2 minutes, 7 minutes and 10 minutes.

What is the shortest time needed for all four of them to cross the river?

ANS: 17 min

Solution:

The initial solution most people will think of is to use the fastest person as an usher to guide everyone across. How long would that take? 10 + 1 + 7 + 1 + 2 = 21 minutes. Is that it? No. That would make this question too simple even as a warm up question.

Lets brainstorm a little further. To reduce the amount of time, we should find a way for 10 and 7 to go together. If they cross together, then we need one of them to come back to get the others. That would not be ideal. How do we get around that? Maybe we can have 1 waiting on the other side to bring the torch back. Ahaa, we are getting closer. The fastest way to get 1 across and be back is to use 2 to usher 1 across. So lets put all this together.

1 and 2 go cross
2 comes back
7 and 10 go across
1 comes back
1 and 2 go across (done)

Total time = 2 + 2 + 10 + 1 + 2 = 17 minutes

Q2. In a recreational activity, you are given four different jars of 2 liters, 4 liters, 6 liters and 8 liters respectively with an unlimited water supply. Then you are asked to measure exactly 5 liters of water using them.

How will you do it?

Solution:

If we have to measure precisely, it is impossible. Because we are asked to measure odd number of liters whereas all the jars we have can contain only even liters of water.

Q3. You need to divide 50 marbles (25-red and 25-blue) into two boxes such that the probability of picking red marble is maximized.

Following conditions need to hold true:
1. None of box is empty
2. All the marbles must be in one of two boxes.

Solution:

Put one red marble in one box and all other marbles in the 2nd box.

Probability :
50 + 24/49

Q4. I have two hour glasses

A) Measures an exact 7 hours
B) Measures an exact 4 hours.

Using these two hour glasses, you need to measure an exact nine hours?

Solution:

Step1 -> Start running both the hourglasses.
Step2 -> When 4 hours hourglass runs out, turn it over.
Step3 -> When 7 hours hourglass runs out, turn it over.
Step4 -> Again when 4 hours hourglass runs out, turn 7 minute hourglass over (it was running for exactly one minute.)
final step -> 8 minute already passed and allow one minute of 7 hour glass to get over. ==>9 minute

Q5. I have two rectangular bars.
They have property such that when you light the fire from one end, it will take exactly 60 seconds to get completely burn.
However they do not burn at consistent speed (i.e it might be possible that 40 percent burn in 55 seconds and next 60 percent can burn in 10 seconds).

Problem is: How do you measure 45 seconds?

Solution:

Steps:
1) Light fire on first bar from both the ends and second bar from one end.

2) After 30 seconds (when first bar gets completely burned out), burn the second bar from second end as well.

3) When second run completely gets burned, you know its 45 seconds.

Q6. You have a pair of unbiased dices. You throw them together till you get a sum of 4 or 7.
What is the probability that you get a sum of 4 before the sum of 7?

ANS: 2/5

Explanation:

This problem can be solved with different approaches. Let us not go into the complicated generic stuff to avoid confusion and try to solve it with simpler means.

Let us find the results separately. There can be 4 different results that give the sum of 5 and there can be 6 different results that give the sum of 7.

Thus, the probability that we get the sum of 4 before the sum of 7 will be:
4/(4+6) = 4/10 = 2/5.

Q7. You are given a set of scales and 12 marbles. The scales are of the old balance variety. That is, a small dish hangs from each end of a rod that is balanced in the middle. The device enables you to conclude either that the contents of the dishes weigh the same or that the dish that falls lower has heavier contents than the other.
The 12 marbles appear to be identical. In fact, 11 of them are identical, and one is of a different weight. Your task is to identify the unusual marble and discard it. You are allowed to use the scales three times if you wish, but no more.

Note that the unusual marble may be heavier or lighter than the others. You are asked to both identify it and determine whether it is heavy or light.

Solution:

So that the following plan can be followed, let us number the coins from 1 to 12. For the first weighing let us put on the left pan coins 1,2,3,4 and on the right pan coins 5,6,7,8.

There are two possibilities. Either they balance, or they dont. If they balance, then the different coin is in the group 9,10,11,12. So for our second one possibility is to weigh 9,10,11 against 1,2,3

(1) They balance, in which case you know 12 is the different coin, and you just weigh it against any other to determine whether it is heavy or light.
(2) 9, 10, 11 is heavy. In this case, you know that the different coin is 9, 10, or 11, and that that coin is heavy. Simply weigh 9 against 10; if they balance, 11 is the heavy coin. If not, the heavier one is the heavy coin.
(3) 9, 10, 11 is light. Proceed as in the step above, but the coin you are looking for is the light one.

That was the easy part.

What if the first weighing 1,2,3,4 vs 5,6,7,8 does not balance? Then any one of these coins could be the different coin. Now, in order to proceed, we must keep track of which side is heavy for each of the following weighings.

Suppose that 5,6,7,8 is the heavy side. We now weigh 1, 5, 6 against 2,7,8. If they balance, then the different coin is either 3 or 4. Weigh 4 against 9, a known good coin. If they balance then the different coin is 3, otherwise it is 4. The direction of the tilts can tell us whether the offending coin is heavier or lighter.

Now, if 1,5,6 vs 2,7,8 does not balance, and 2,7,8 is the heavy side, then either 7 or 8 is a different, heavy coin, or 1 is a different, light coin.

For the third weighing, weigh 7 against 8. Whichever side is heavy is the different coin. If they balance, then 1 is the different coin. Should the weighing of 1,5, 6 vs 2,7,8 show 1,5,6 to be the heavy side, then either 5 or 6 is a different heavy coin or 2 is a light different coin. Weigh 5 against 6. The heavier one is the different coin. If they balance, then 2 is a different light coin.

FreshersLive - No.1 Job site in India. Here you can find latest 2018 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.

 ✖