Sunday, July 30, 2017

Puzzles

Question:- Three ants are sitting at the three corners of an equilateral triangle. Each ant starts randomly picks a direction and starts to move along the edge of the triangle. What is the probability that none of the ants collide?

Answer:- So let’s think this through. The ants can only avoid a collision if they all decide to move in the same direction (either clockwise or anti-clockwise). If the ants do not pick the same direction, there will definitely be a collision.

Well, each ant can move in 2 different directions. Because there are 3 ants, this means that there are 2*2*2 (which equals eight) possible ways that the ants can move.

And since we already know that there are only 2 ways in which the ants can avoid collision entirely :- 2/8 = 0.25

this means that there are 8-2 = 6 scenarios where the ants will collide. And 6 out of 8 possible scenarios, means that the probability of collision is 6/8 = .75. Thus, the probability of the ants colliding is .75.

Question:- A bird fly 200km/hr.Two trains coming oppositely one 100km/hr, other 50km/hr. Total distance between the trains starting point is 450km.So the bird is flying to and fro in the train line. How long distance the bird travel when the trains meet each other.

Answer:-

<---------------------------------- 450 km ---------------------------------------------------------------------------->
|-----------------------------------------------------------------------------|-------------------------------------------------|
X(100km/h) <----- (450-x) -------------------------------> meet  <---------- x --------->(50km/h) Y

 speed = distance /time

100 = 450-x / t1
50 = x / t2

as they meet at same time so

t1 = t2 => 450-x/100 = x/50 = x => 150 km

time = 150 / 50 = 3 hrs
Distance bird traveled is = 200 * 3 = 600 km


Question:- A train leaves City X for City Y at 15 mph. At the very same time, a train leaves City Y for City X at 20 mph on the same track. At the same moment, a bird leaves the City X train station and flies towards the City Y train station at 25 mph. When the bird reaches the train from City Y, it immediately reverses direction. It then continues to fly at the same speed towards the train from City X, when it reverses its direction again, and so forth. The bird continues to do this until the trains collide. How far would the bird have traveled in the meantime?

Answer:-
The concept of relative speed can work handy here. Let’s assume that the distance between City X and City Y is d miles. The trains are approaching each other at a relative speed of (20 + 15) = 35 mph. The sum of the distances covered by the trains when they collide is d (i.e. the distance between the cities). Since distance/speed gives us time, we know that the trains collide d/35 hours after they start.

Since the speed of the bird is constant at 25 mph, we know that the bird would have covered

25 * (d/35) miles = 5d/7 miles before the trains collide.

Question:- You have 10 boxes of balls (each ball weighing exactly10 gm) with one box with defective balls (each one of the defective balls weigh 9 gm). You are given an electronic weighing machine and only one chance at it. How will find out which box has the defective balls?

Answer:- For convenience sake, let’s name the boxes from 1 to 10. In order to solve this problem, you have to leverage the fact that you know exactly what each good ball is supposed to weigh and what each defective ball is supposed to weigh. Many of us instinctively will take one ball out of each box and try to find a way to make it work but the trick to take different number of balls from each box.

The number of balls you pick from each bag is equal to the box number. For example, pick 1 ball from box 1, 2 balls from box 2 and so on. In total you will have 55 balls. If all of the boxes have good balls, then the total weight of these balls would be 550gm.

If box 1 has defective balls, then the total weight should be 1gm less than expected (only one ball weighing 9 gm). If box 2 has defective balls, then the total weight should be 2gm less than expected (two balls weighing 9 gm). So once you weigh the set of chosen balls, find out the difference between the total weight and the expected weight. That number represents the box number which contains the defective balls.

Question:-  You have 9 balls, equally big, equally heavy - except for one, which is a little heavier. How would you identify the heavier ball if you could use a pair of balance scales only twice?

Answer:-
Divide the 9 balls into 3 groups of 3. Compare the weight of two of those groups. The heavier group should then be obvious, it will either tip the scales, or, if the scales stay balanced, then it is the group you didn't include. Now, choose 2 balls from this group and compare their weights, and using the same logic as before, the heavier ball will be obvious.

Question:-  You have 100 doors to be painted and 2 painters. 1 starts at one end and paints every other door. The other painter starts at the other end and paints every 3rd door. What door number will they meet at?

Answer:-

1st painter: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
2nd painter: 97 94 91 88 85 82 79 76 73 70 67 64 61 58 55 52 49 46 43 40 37 34 31 28 25

the meeting point is 25th door

Plus, find out relative steps that would be 1st door = x, every 3rd door = 3x
relative doors = x+3x = 4x
total doors = 100
4x = 100
x = 100/4 = 25th door

Question:- The owner of a banana plantation has a camel. He wants to transport his 3000 bananas to the market, which is located after the desert. The distance between his banana plantation and the market is about 1000 kilometer. So he decided to take his camel to carry the bananas. The camel can carry at the maximum of 1000 bananas at a time, and it eats one banana for every kilometer it travels.

What is the largest number of bananas that can be delivered to the market?

Answer:-
First of all, the brute-force approach does not work. If the Camel starts by picking up the 1000 bananas and try to reach point B, then he will eat up all the 1000 bananas on the way and there will be no bananas left for him to return to point A.

So we have to take an approach that the Camel drops the bananas in between and then returns to point A to pick up bananas again.

Since there are 3000 bananas and the Camel can only carry 1000 bananas, he will have to make 3 trips to carry them all to any point in between.




<---p1---><--------p2-----><-----p3---->
A---------------------------------------->B
 

When bananas are reduced to 2000 then the Camel can shift them to another point in 2 trips and when the number of bananas left are <= 1000, then he should not return and only move forward.

In the first part, P1, to shift the bananas by 1Km, the Camel will have to

    1. Move forward with 1000 bananas – Will eat up 1 banana in the way forward
    2. Leave 998 banana after 1 km and return with 1 banana – will eat up 1 banana in the way back
    3. Pick up the next 1000 bananas and move forward – Will eat up 1 banana in the way forward
    4. Leave 998 banana after 1 km and return with 1 banana – will eat up 1 banana in the way back
    5. Will carry the last 1000 bananas from point a and move forward – will eat up 1 banana

Note: After point 5 the Camel does not need to return to point A again.

So to shift 3000 bananas by 1km, the Camel will eat up 5 bananas.

After moving to 200 km(P1) the Camel would have eaten up 1000 bananas and is now left with 2000 bananas.

Now in the Part P2, the Camel needs to do the following to shift the Bananas by 1km.

    1. Move forward with 1000 bananas – Will eat up 1 banana in the way forward
    2. Leave 998 banana after 1 km and return with 1 banana – will eat up this 1 banana in the way back
    3. Pick up the next 1000 bananas and move forward – Will eat up 1 banana in the way forward

Note: After point 3 the Camel does not need to return to the starting point of P2.

So to shift 2000 bananas by 1km, the Camel will eat up 3 bananas.

After moving to 333 km(P2) the camel would have eaten up 1000 bananas and is now left with the last 1000 bananas.

The Camel will actually be able to cover 333.33 km, I have ignored the decimal part because it will not make a difference in this example.

Hence the length of part P2 is 333 Km.

Now, for the last part, P3, the Camel only has to move forward. He has already covered 533 (200+333) out of 1000 km in Parts P1 & P2. Now he has to cover only 467 km and he has 1000 bananas.

He will eat up 467 bananas on the way forward, and at point B the Camel will be left with only 533 Bananas.

Question:- There are 4 persons (A, B, C and D) who want to cross a bridge in night.

A takes 1 minute to cross the bridge.
B takes 2 minutes to cross the bridge.
C takes 5 minutes to cross the bridge.
D takes 8 minutes to cross the bridge.

There is only one torch with them and the bridge cannot be crossed without the torch. There cannot be more than two persons on the bridge at any time, and when two people cross the bridge together, they must move at the slower person’s pace. Can they all cross the bridge in 15 minutes?

Answer:-
A and B cross the bridge. A comes back. Time taken 3 minutes. Now B is on the other side.
C and D cross the bridge. B comes back. Time taken 8 + 2 minutes. Now C and D are on the other side.
A and B cross the bridge. Time taken is 2 minutes. All are on the other side.

Total time spent is 3 + 10 + 2 = 15 minutes.

Question:- You have 1000 wine bottles, one of which is poisoned. You want to determine which bottle is poisoned by feeding the wines to the rats. The poisoned wine takes one hour to work. How many rats are necessary to find the poisoned bottle in one hour?

Answer:-
Let's  take something simpler to explain: Suppose you have 8 bottles to test.   You can test this with 3 rats.  Each rat gets fed some of 4 bottles:

Rat A: #2, #5, #6, #8
Rat B: #3, #5, #7, #8
Rat C: #4, #6, #7, #8

If no rats die, then you know that #1 is poisoned.
If A dies, then you know #2 is poisoned.
If B dies, then you know #3 is poisoned.
If C dies, then you know #4 is poisoned.
If both A and B die, then you know #5 is poisoned.
If both A and C die, then you know #6 is poisoned.
If both B and C die, then you know #7 is poisoned.
If all the rats die, then you know #8 is poisoned.

So, for 8 bottles, you need 3 rats.

Turns out, with 1 rat, you can test 2 bottles.  With 2 rats, you can test up to 4 bottles.  With 3 rats, you can test up to 8 bottles.  With N rats you can test 2N bottles.  So for 1000 bottles, you need log21000, round up, which is ~9.965784 rats, rounded up to 10 rats.
N= rats
2N= 1000 =>
N = log2(1000) => ~ 9.9 = 10

Another Answer:-
The idea is to number bottles from 1 to 1000 and write their corresponding binary numbers on the bottle. Each rat is assigned a position in the binary numbers written on bottles. Let us take an example. Rat 1 represents first bit in every bottle, rat 2 represents second bit and so on. If rat numbers 5, 7 and 9 die, then bottle number 42 (Binary 0000101010) is poisoned.


We number the bottles from 1 to 1000 and write their corresponding binary numbers on the bottle.
Each bottle will have a binary number with 10 place digits since 2 to the power 10 = 1024.

Now, each rat is assigned a placeholder in the binary numbers so formed.
Rat 1 is assigned binary place 1.
Rat 2 is assigned binary place 2.
Rat 3 is assigned binary place 3.
and so forth and so on...

Each rat is given a sip from the bottle if the number on the bottle at the binary place assigned to him is 1 otherwise if it is 0, it doesn't take a sip.

Now for a bottle numbber 28 i.e 0000011100, Rat 3, Rat 4 and Rat 5 take a sip from that bottle. This way each rat takes(or not takes) a sip from many bottles depending upon binary number (0 or 1) appearing against his assigned binary place on that bottle.

Then we wait for an hour and to let rats die.

Imagine Rat 3,5,6 & 8 died. It means poisoned bottle would be:

(10) (9) (8) (7) (6) (5) (4) (3) (2) (1)
 0 0 1 0 1 1 0 1 0 0 = 0010110100 = 180

Hence bottle no. 180 was poisoned.

Question:- A man has a medical condition that requires him to take two kinds of pills, call them A and B. The man must take exactly one A pill and exactly one B pill each day, or he will die. The pills are taken by first dissolving them in water.

The man has a jar of A pills and a jar of B pills. One day, as he is about to take his pills, he takes out one A pill from the A jar and puts it in a glass of water. Then he accidentally takes out two B pills from the B jar and puts them in the water. Now, he is in the situation of having a glass of water with three dissolved pills, one A pill and two B pills. Unfortunately, the pills are very expensive, so the thought of throwing out the water with the 3 pills and starting over is out of the question. How should the man proceed in order to get the right quantity of A and B while not wasting any pills?

Answer:-
Add one more A pill to the glass and let it dissolve. Take half of the water today and half tomorrow. It works under following assumptions.

The dissolved Pills can be used next day.

The man has to take pills at least for one more day.

Question:-
You have 5 jars of pills. Each pill weighs 10 grams, except for contaminated pills contained in one jar, where each pill weighs 9 grams. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

Answer:-
Take out 1 pill from jar 1, 2 pills from jar 2, 3 pills from jar 3, 4 pills from jar 4 and 5 pills from jar 5. Put all these 15 pills on scale. The correct wight is 150 (15*10). But one of the jars has contaminated pills. So the wight will definitely less than 150. If the wight is 149 then jar 1 has contaminated pills because the there is only one contaminated pill. If the wight is 148 then jar 2, if the wight is 147 then jar 3, if 146 then jar 4, if 145 then jar 5.

Question:-
There is a room with a door (closed) and three light bulbs. Outside the room there are three switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door you can’t change them. Identify each switch with its bulb.

Answer:-
Let the bulbs be X, Y and Z

Turn on switch X for 5 to 10 minutes. Turn it off and turn on switch Y. Open the door and touch the light bulb.

1. if the light is on, it is Y
2. if the light is off and hot, it is X
3. if the light is off and cold, it is Z

Question:-
There are 3 person in a forest, when they slept at night someone from outside colored their faces black(all three). Now when they wake up in the morning all three started laughing at each other thinking that the other two persons have black faces.
But after some time they realized that their own faces are also black and then they stop laughing at each other.
Here, you have to give a valid LOGICAL REASON that how they realized that their own faces are also black, i.e. all three faces are black.

Answer:-
Case 1: Only one guy is painted Assume C, Obviously C won't laugh. A and B will laugh.
Case 2 : Two guys were painted assume B and C, Then A will laugh for sure as B and C are painted.
if B is laughing it means C has painted pace as A doesn't have painted face.
if C is laughing it means, B has painted pace then he immediately stops laughing.
if both B and C are laughing, it means both B and C have painted face as they are aware that A doesn't have painted face. Immediately both B and C will stop laughing and A will continue to laugh.
Case 3 : All three are painted
A thinks that B and C are laughing by seeing each other. Similarly for B and C. So when All three are painted only All three will laugh.

Question:-
Two dice are thrown simultaneously. What is the probability of getting two numbers whose product is even?

Answer:-
In a simultaneous throw of two dice, we have n(S) = (6 x 6) = 36.

Then, E     = {(1, 2), (1, 4), (1, 6), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 2), (3, 4), (3, 6), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 2), (5, 4), (5, 6), (6, 1),
(6, 2), (6, 3), (6, 4), (6, 5), (6, 6)}

n(E) = 27.

P(E) =     n(E) / n(S)   =     27 / 36    =     3 / 4

Question:-
In a lottery, there are 10 prizes and 25 blanks. A lottery is drawn at random. What is the probability of getting a prize?

Answer:-
P (getting a prize) =     10 / (10 + 25)    =     10/35     =     2 / 7


Question:-
In a throw of dice what is the probability of getting number greater than 5.

Answer:-
Number greater than 5 is 6, so only 1 number
Total cases of dice = [1,2,3,4,5,6]

So probability = 1/6

Question:-
Three unbiased coins are tossed, what is the probability of getting at least 2 tails ?


Answer:-
Total cases are = 2*2*2 = 8, which are as follows
[TTT, HHH, TTH, THT, HTT, THH, HTH, HHT]

Favoured cases are = [TTH, THT, HTT, TTT] = 4

So required probability = 4/8 = 1/2

No comments:

Post a Comment

Web Development

Design Phase:- Below all these represent different stages of the UX/UI design flow:- Wireframes represent a very basic & visual repr...