# Nvidia Interview Puzzle

Posted on :18-02-2016
Nvidia Interview Puzzle:-

Q1. Two trains under a controlled experiment begin at a speed of 100 mph in the opposite direction in a tunnel. A supersonic bee is left in the tunnel which can fly at a speed of 1000 mph. The tunnel is 200 Nvidia Interview Puzzlemiles long. When the trains start running on a constant speed of 100 mph, the supersonic bee starts flying from one train towards the other. As soon as the bee reaches the second train, it starts flying back towards the first train.

If the bee keeps flying to and fro in the tunnel till the trains collide, how much distance will it have covered in total?

ANS:
The tunnel is 200 miles long and the trains are running at a speed of 100 mph which means that they will collide exactly at the center of the tunnel and seeking their speed, they will collide after an hour.

Now consider the bee which is flying at a speed of 1000 mph and will keep flying till the train collides. As calculated, it will keep flying for an hour which means the distance that it will cover is 1000 miles.

Q2. I got two jugs of
A) 11 liter
B) 6 liter

How can I measure exactly 9 liters?

ANS:

12 steps:
Steps- 11 Liter jug 6 Liter Jug
1. 11 -
2. 5 6
3. 5 0
4. 0 5
5. 11 5
6. 10 6
7. 10 0
8. 4 6
9. 4 0
10. 0 4
11. 11 4
12. 9 6 ==>  9 liter in 11liter jug(as required)

Q3. In a contest, four fruits (an apple, a banana, an orange, and a pear) have been placed in four closed boxes (one fruit per box). People may guess which fruit is in which box. 123 people participate in the contest. When the boxes are opened, it turns out that 43 people have guessed none of the fruits correctly, 39 people have guessed one fruit correctly, and 31 people have guessed two fruits correctly.
How many people have guessed three fruits correctly, and how many people have guessed four fruits correctly?

ANS:

It is not possible to guess only three fruits correctly: the fourth fruit is then correct too! So nobody has guessed three fruits correctly and 123-43-39-31 = 10 people have guessed four fruits correctly.

Q4. What is the probability of getting 5 Sunday in a 31 day month?

ANS:

3/7

Explanation:

If a 31day month starts on a Friday, Saturday or Sunday it will have five Sunday, if not it will have 4 Sunday.

Q5. You are the ruler of a medieval empire and you are about to have a celebration tomorrow. The celebration is the most important party you have ever hosted. You have got 1000 bottles of wine you were planning to open for the celebration, but you find out that one of them is poisoned.

The poison exhibits no symptoms until death. Death occurs within ten to twenty hours after consuming even the minutest amount of poison.

You have over a thousand slaves at your disposal and just under 24 hours to determine which single bottle is poisoned.

You have a handful of prisoners about to be executed, and it would mar your celebration to have anyone else killed.

What is the smallest number of prisoners you must have to drink from the bottles to be absolutely sure to find the poisoned bottle within 24 hours?

ANS:
10 prisoners must sample the wine. Bonus points if you worked out a way to ensure than no more than 8 prisoners die.

Number all bottles using binary digits. Assign each prisoner to one of the binary flags. Prisoners must take a sip from each bottle where their binary flag is set.

Here is how you would find one poisoned bottle out of eight total bottles of wine.

Bottle 1 Bottle 2 Bottle 3 Bottle 4 Bottle 5 Bottle 6 Bottle 7 Bottle 8
Prisoner A X X X X
Prisoner B X X X X
Prisoner C X X X X
In the above example, if all prisoners die, bottle 8 is bad. If none die, bottle 1 is bad. If A & B dies, bottle 4 is bad.

With ten people there are 1024 unique combination so you could test up to 1024 bottles of wine.

Each of the ten prisoners will take a small sip from about 500 bottles. Each sip should take no longer than 30 seconds and should be a very small amount. Small sips not only leave more wine for guests. Small sips also avoid death by alcohol poisoning. As long as each prisoner is administered about a milliliter from each bottle, they will only consume the equivalent of about one bottle of wine each.

Each prisoner will have at least a fifty percent chance of living. There is only one binary combination where all prisoners must sip from the wine. If there are ten prisoners then there are ten more combination where all but one prisoner must sip from the wine. By avoiding these two types of combination you can ensure no more than 8 prisoners die.

Q6. Give output for the following code:

#include
#include
int main(int argc, char *argv[])
{
int i=5;
printf(%d , i++ + ++i);
printf(%d , i++ + ++i + i++ + ++i);
printf(%d , ++i + i++ + ++i + i++);
system(PAUSE);
return 0;
}

ANS:

#include
#include
int main(int argc, char *argv[])
{
int i=5;
printf(%d , i++ + ++i); // 5 + 1 + 5 + 1 = 12 (i=7)
printf(%d , i++ + ++i + i++ + ++i); // 7 + 1 + 7 + 8 + 1 + 9 + 1 + 1 = 33 (i=11)
printf(%d , ++i + i++ + ++i + i++); // 1 + 11 + 12 + 1 + 12 + 12 + 1 = 50 (i=15)
system(PAUSE);
return 0;
}

## Related Companies

Accenture
HCL
TCS
Emphasis
SAP labs India

FreshersLive - No.1 Job site in India. Here you can find latest 2019 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.

 ✖