Friday, August 30, 2013

Box Having Defective Balls. 10 Box 1 Chance.

You have been provided with 10 boxes. Each are full of balls and each ball weighs 10 gm.

One of these box has all defective balls. That is each ball in that box is of 9 gm.

You are also given a weighing machine. It is a digital electronic machine that shows weight of howsoever numebr of balls kept on it. That is if you put 'n' balls on it, it will tell you the total weight of n balls. And machine is big enough to accomodate any number of balls.

You have only one chance to weigh.

How will you find the box that is defective balls container.

Moving Ants in Triangluar spiral - Classic Puzzle

There are three ants.

They are sitting on the three corners of an equilateral triangle.

If each ant randomly picks a direction. And start moving along the edge.

What is the probability that no two ants collide?

100 Prisoners - Set Free or Hanged Challenge

Suppose there are 100 prisoners. They all are in the prison in solitary cells. The jailor/admin of the prison offered them a challenge. He says that he will put one prisoner per day, selected randomly into a special room with a light bulb and a switch which controls the bulb.

A prisoner can be selected more than once.
No other prisoners can see or control the light bulb.
The prisoner in the special room can either turn on the bulb, turn off the bulb or do nothing.

On any good day the prisoners can feel winning and stop this process and say that every prisoner has been in that special electrical room at least once.

If that happens to be true, all the prisoners will be set free. But if it is false, then all the prisoners will be executed.

What should the prisoners do to win the challenge and come out!!
(PS: Police should take ownership that they wont do the crime again. Hehehe)

Generate random 7 from random 5

Write a function to generate a random number between 1 and 7. You have been given a function that generates a random number between 1 and 5. The distribution between each of the numbers must be uniform.

Bird Running Between Trains - Classic Puzzle

It is a classic Puzzle. And it can be seen all over the internet.

A train leaves City X for City Y at 15 mph. Same instant, another train leaves City Y for City X at 20 mph on the same track. (There will be an accident. Huh...)

At the same moment, there is a bird that was sitting on the engine of train at city X. It leaves the train and flies towards the City Y train  at 25 mph. When the bird reaches the train from City Y, it immediately reverses its 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 entire to and fro journey.

Bridge Crossing - Different Speed - 1/2/7

There are Four persons. They need to cross a rickety bridge at night.

They have only one torch and the bridge is too dangerous to cross without one. The bridge is only strong enough to support two people at a time. Not all people take the same time to cross the bridge.

Each person takes different time to cross bridge. Times for each person are  1 min, 2 mins, 7 mins and 10 mins.

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

Atleast One Husband is Cheating!!

A certain community comprises of 100 married couples only. Everyone lives with the following rule:

1. If a husband cheats on his wife, the husband is executed as soon as his wife finds out about him.
2. All the women only gossip about the husbands of other women.
3. No woman ever tells another woman if her husband is cheating on her.
So every woman knows about all the cheating husbands in the town except her own.

(It can also be assumed that a husband remains silent about his infidelity. )

One day, the leader of that small society/community announces that there is at least one cheating husband in the town.

What do you think happens?