Thursday, July 26, 2007

Saving The Prisoners

There are some prisoners(say 500) to whom the death sentence is annouced. But being liberal the jailar gave a chance and annouced a day before to the prisoners that
"I will keep a colored hat on your head, it will be either Red or Blue,
I will make you stand each one on the stairs (rule or clue - the top most stair guy can see all the prisoners hats and thier colors down to him, means standing one person per stair)
**Rule - No one is allowed to see their hat color but can see all others who are down to them.
I will come to each person from top stair to down and ask their hat color, if you say correct color.. .you are escaped.. else shot"

Then the prisoners gathered and decided on one strategy so that maximum people can be saved.

what is that strategy and how many prisoners can be escaped?

Find The Truth Teller...

There are three persons in a room
One of them always tells the truth, but the others are "alternate liars": they tell the truth then lie, then truth, etc, but you do not know if they will start by telling the truth or a lie...
You can ask three questions that MUST be answered by Yes or No.
Find the truth teller.

Anyone with previous knowledge on information theory and coding would find it more easy...

Saturday, July 21, 2007

Solution to the Handshakes problem

Your spouse shook hands with Pat, but not Chris.

We begin with what we know: since nobody shook hands with more than six persons, and the seven people other than
yourself all shook hands with a different number of people, the numbers must have been:
0,1,2,3,4,5,6, respectively.

Let us begin with "0"--whom we shall call the introvert, because this person shook nobody's hand. At the other extreme
was "6"--whom we shall call the extrovert for obvious reasons. The extrovert shook everybody's hand, except his/her
own spouse. Since the extrovert and the introvert did not shake hands, the introvert must be the extrovert's spouse.

0&6 are a couple, leaving 1,2,3,4,5 and yourself

Consider the remaining five people other than yourself. Each of these shook hands with the extrovert, and none with the introvert.

One of these five people-- "1", the quasi-introvert--only shook hands with one other person, the extrovert. Another--
"5", the quasi-extrovert--shook hands with five people, everyone except his/her own spouse and the introvert ("0").
Therefore, the quasi-introvert and the quasi-extrovert form a couple.

0&6, 1&5 are couples, leaving 2,3,4 and yourself.

In the same way, "2" and "4" form a couple--we'll call them the pseudo-introvert and pseudo-extrovert, respectively.

0&6, 1&5, 2&4 are couples, leaving 3 and yourself.

Therefore, your spouse is the one who shook hands with three other persons. Furthermore, you and your spouse shook hands with the same people: the extrovert ("6"), the quasi-extrovert ("5"), and the pseudo-extrovert ("4"). This group includes Pat (one of our givens: you shook hands with Pat), and therefore must exclude Chris.

Solution to Gold Chain Problem

This can be done wit 2 cuts.
Cut the gold chain into 3 pieces of length 1, 2 and 4. That will take just 2 cuts. On the first day, 1 can be given as wage. On 2nd day link 1 can be taken back, and link 2 can be given. On 3rd day link 1 can be given along with link 2. And so on..

Sunday, July 15, 2007

Locking up gifts?

You want to send a valuable object to a friend securely. You have a box which can be fitted with multiple locks, and you have several locks and their corresponding keys. However, your friend does not have any keys to your locks, and if you send a key in an unlocked box, the key could be copied en route. How can you send the object securely?

Knight vs Dragon

A dragon and knight live on an island. This island has seven poisoned wells, numbered 1 to 7. If you drink from a well, you can only save yourself by drinking from a higher numbered well. Well 7 is located at the top of a high mountain, so only the dragon can reach it.

One day they decide that the island isn't big enough for the two of them, and they have a duel. Each of them brings a glass of water to the duel, they exchange glasses, and drink. After the duel, the knight lives and the dragon dies.

Why did the knight live? Why did the dragon die?

Glass half full???

You are in an empty room and you have a transparent glass of water. The glass is a right cylinder, and it looks like it's half full, but you're not sure. How can you accurately figure out whether the glass is half full, more than half full, or less than half full? You have no rulers or writing utensils.

Saturday, July 14, 2007

Handshakes Problem..

Four couples attended a party. One couple was you and your spouse; another was Pat and Chris. Some people shook hands with one another, but nobody shook hands with oneself or with one's own spouse.

After the party, you asked each person (except yourself) how many different people the person had shaken hands with. Each person replied with a different number--and each person's reply was truthful.

You shook hands with Pat. Did your spouse shake hands with Pat? With Chris?

Gold Chain Problem

A man has a gold chain with 7 links. He needs the service of a laborer for 7 days at a fee of one gold link per day. However, each day of work needs to be paid for separately. In other words, the worker must be paid each day after working and if the laborer is ever overpaid he will quit with the extra money. Also he will never allow himself to be owed a link.

What is the fewest number of cuts to the chain to facilitate this arrangement and how does that guarantee payment?

Solution to the 5 Pirates and the Gold Problem

All pirates assume tat the other players will play optimally.
Consider the case where there r just two pirates B and A in the order of seniority.. So B will decide how to split the gold. All the pirates are very greedy and only 50% votes are required for approval. So B will choose to keep all the gold and vote for himself.. Thus A will get zero..

If there are three pirates C,B and A then C must get 2 votes 2 win. A knows tat he will get nothing if C is killed. So if C agrees to give him atleast 1 gold coin, voting for C is a better option for A. So C will keep 99 coins and give 1 coin to A. So the coin distribution is 99, 0, 1

If there r 4 pirates, D,C,B and A then the same reasoning can be applied and D will provide the loser in the 3 people scenario above with a gold coin. Since B is the loser. He will get a gold coin. B knows tat if he does not vote for D, C will take over and he wont get any gold as shown above.
So the distribution becomes 99,0,1,0

If there r 5 pirates, E,D,C,B and A we need 3 votes for E to win.. So E will give 1 coin each to losers in the 4 person scenario. So C and A will get a coin each

So the distribution decided by the most senior pirate to ensure his survival and maximize his gold is 98,0,1,0,1.

Friday, July 13, 2007

Solution to which 1 is heavier..

The gold will be heavier if we try to lift it..
Weight is the force acting on a body due to gravity..
In vacuum the weight of 1kg of cotton and 1kg of gold will be the same..
We know tat cotton is very much less denser than gold.. So 1kg cotton will take up much more volume than 1 kg of gold.
Buoyancy of air causes an upthrust on both gold and cotton.. This upthrust is directly proportional to the volume of air displaced.. So a higher upthrust will act on Cotton..
So the net force acting downwards on Cotton will be smaller..
So cotton will be easier to lift up..

Solution to Cows and the Meadow Problem

The number of cows required is 20..
For this we have to consider the fact tat the grass is growing continously.. Let y be the rate of growth of grass.. So in 24 days the grass will grow 24y..
Now let the total amount be 1..
So (1+24y) is the amt of grass in 24 days..
In 1 day,70 cows will eat = (1+24y)/24
and 1 cow will eat = (1+24y)/(24*70)

and similarly we get 1 cow will eat (1+60y)/(60*30)
Equating the 2 equations and solving we get y= 1/480.. This is the rate of growth of grass. Substituting this in 1 of the above equations we get 1/1600

So for 96 days Let there be x cows---> (1+96*(1/480))/(96*x) = 1/1600

solving x we get x= 20 cows..

Solution to red and blue marbles problem

Place one red marble in one jar and all the remaining balls ( 49 red and 50 blue) in the next jar.
so probability would be 0.5* 1+ 0.5* 49/99 ..so u get a probability around 0.75.

Tuesday, July 10, 2007

5 Pirates and the gold problem

Five pirates have 100 gold coins. they have to divide up the loot. In order of seniority (suppose pirate 5 is most senior, pirate 1 is least senior), the most senior pirate proposes a distribution of the loot. they vote and if at least 50% accept the proposal, the loot is divided as proposed. Otherwise the most senior pirate is executed, and they start over again with the next senior pirate. What solution does the most senior pirate propose? Assume they are very intelligent and extremely greedy (and that they would prefer not to die).

Monday, July 9, 2007

Which one is heavier??

Which one will be heavier if u try to lift it : 1 kg of cotton or 1 kg of gold ??

Cows and the grass meadow problem

A grass meadow grew equally thick and fast. It was known tat 70 cows could eat it up in 24 days and 30 cows could eat it up in 60 days. How many cows would crop the grass in 96 days??

Red and blue marbles problem

you have two jars, 50 red marbles, 50 blue marbles. you need to place all the marbles into the jars such that when you blindly pick one marble out of one jar, you maximize the chances that it will be red. (when picking, you'll 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.

Solution to jelly bean problem

The answer is one..
remember tat all the jars are mislabeled..
take a jellybean from the jar labeled as "mix of both".
if it is a grape jelly jelly bean then the jar should be labeled as "grape jelly" and the jar mislabeled as "peanut butter" should be corrected as "mix of both.." and the jar mislabeled as "grape jelly" should be corrected as "peanut butter"

Solution to Coins on the Table problem

Move the coins 1 by 1 to two sides of the table alternatively.. Then flip all coins in one of the sides..

Solution to the Numerical Puzzle

There r 2 ways to do this..

((5!)/(5+5))+(5*5) or

(((5+5)/5)^5)+5

Solution to contaminated pill problem

This is a simple 1..
Take one pill from jar 1.. two from jar 2 and so on till 5 from jar 5..
Now Weigh the pills together..
If the reading of the weighing machine ends in 9 then the contaminated pill is from jar 1..
If it ends in 8 then it is from jar 2.
If 7 then jar 3.
If 6 then jar 4.
and if 5 then jar 5.

Solution to top three

The minimum number of races required is 7. The solution goes like this.
first divide the 25 horses into 5 grps A,B,C,D,E each containing 5 horses.
Now conduct 5 races for the 5 groups and u will get 1st,2nd,3rd place winners for each group.

Lemme call the 1st place winner of grp A as A1, 2nd place winner as A2 and so on till A5.
Do the same to the other groups.

Now group A1,B1,C1,D1,E1 together and conduct a race. let A1 be 1st, B1 be 2nd and C1 be 3rd.
A1 will be the fastest 1st place horse. Now for 2nd and 3rd place horse.

We r sure tat other horses in group C,D and E wont be the 2nd and 3rd place horses. C1 turned out to be the fastest horse in group C and so the other horses in C will be slower than C1.

So for the next race group A2,A3,B1,B2,C1 together and conduct the race.
The 2nd place winner in this race will be the 2nd fastest horse.
The 3rd place winner in this race will be the 3rd fastest horse.

Solution to crossing the bridge

Its possible to cross the bridge in 17 minutes

C&D crosses D returns = 2+ 1 = 3mins
A&B crosses C returns =10 + 2=12min
C&B crosses =2min
So the total is 17 minutes.

Solution to the King and his poisoned wine problem

Number the bottles from 1 to 1000.. The trick to gettin the answer to tis problem is to know that every number frm 1-1000 has a unique binary representation.
The binary representation of 1 is 0000000001, 2 is 0000000010 and so on..
Now we hav 10 wine tasters. Number them from 1 to 10. Now feed the nth wine taster wit the wine from the bottles whenever nth bit in binary number is 1. for eg. for 0000000001 only the 10th taster is fed wit bottle 1. if 1000000011 the 1st,9th,10th tasters r fed.
So by identifyin the tasters who die on the 29th day we will be able to verify the correct bottle.

Sunday, July 8, 2007

Saturday, July 7, 2007

Jelly Bean problem..

U have three jars that are all mislabeled. one contains peanut butter jelly beans, another grape jelly jelly beans, and the third has a mix of both. how many jelly beans would you have to pull out, and out of which jars, to find out how to fix the labels on the jars?

Coins on the table problem

There is a table on which a number of coins are placed. You also know that there are as many coins with Head up as many coins with Tail up. Now you have to divide the coins (number of coins is even) into two equal piles such that number of coins with Heads up and Tails up in either piles be the same. The catch is you are blind folded and you cannot determine the sides (for sure) if you are blinded.. How will u do it?

Numerical Puzzle

Can u Make 37,using five 5's??

Contaminated Pill problem

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

Top Three

There are 25 horses and your objective is to find the fastest 3 among them. You can conduct races and the number of horses participating in a single race is 5. Calculate the minimum number of races by which you can find the top three?

Note : Races gives you positions and races are not timed.

Crossing the bridge !

A,B,C and D have got 17minutes to cross a bridge. A takes 10minutes,B takes 5 minutes, C takes 2 minutes and D takes 1 minute to cross the bridge. They only have one lantern and for each crossing of this bridge they require the lantern. The bridge can support only two persons at a time. Is it possible to cross the bridge in 17minutes. If possible,how?

Thursday, July 5, 2007

The King and his Poisoned Wine problem

A king is having a feast. His intelligence officer comes up to him 30 days before the feast and tells the king that 1 of his 1,000 bottles of wine had been poisoned by his enemies. The poison kills immediately after 29 days, but has no other effects beforehand. The king has only 10 wine tasters. How will he find out which bottle of wine was poisoned in time for the feast?

Infinite Monkey Theorem & Darwinism

I came across this concept while i was doing a course in probability and random process.It was something that really caught my fascination.So i did some kind of a research work,and i was fascinated by the way the theorem and the Theory of evolution are correlated....
For starters,what is Infinite Monkey Theorem??.The infinite monkey theorem states that "a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type or create a particular chosen text, such as the complete works of William shakephere". The term 'almost surely' is a mathematical term with a precise meaning, and the "monkey" is not an actual monkey; rather a random sequence generator.
The infinite monkey theorem can be proved in a very straight forward manner.If two events are statistically independent,then the probabilty of both happening equals the product of the probabilities of each one happening on its own.Let A&B be the two statistically independent events then,P(a,b)=P(a)*P(b).Suppose we have a typewriter with say '50'keys,then the probability for each letter to be typed would be 1/50.Suppose we are typing the word 'blog',then the chance that first letter typed is 'b' is 1/50,second letter typed is 'l' is 1/50,and so the total probability that the entire word is typed will be (1/50)*(1/50)*(1/50)*(1/50)=(1/50)^4

Since each block is typed independently, the chance Xn of not typing blog in any of the first n blocks of 4 letters is

Xn=(1-1/50^4)^n

As n grows, Xn gets smaller. For an n of a million, Xn is 99.99%, but for an n of 10 billion Xn is 53% and for an n of 100 billion it is 0.17%. As n approaches infinity, the probability Xn approaches zero; that is, by making n large enough, Xn can be made as small as one likes.

The Infinite Monkey Theorem is used as an argument against Darwinism.. According to Darwinism all complex organism (including humans) evolved as the product of random mutations..

Infinite theorem says tat this is impossible.. coz some random mutations cannot produce a complex organism like human beings.. Ill use an example Richard Dawkins used in his book Climbing Mount Improbable. Its like letting a tornado blow through a junkyard and producing a fully connected aeroplane from the debris. such an event is so improbable. which is stated by the Infinite Monkey Theorem..

But that is not how Darwinism works.. A tiny mutation is produced and it is propagated along the generations if this mutation proves advantageous to the species.. if its bad the mutation is rejected simply bcoz the organisms having tat mutation is not as successful as the ones tat don't have it. This is just like a tiny step at a time. and this way natural selection finds a way around the difficulty posed by creationist's argument. Tiny successful mutations get selected and this produces the development of a complex organism from simpler ones.

So i think i have been able to address the issue in a very precise manner,so that it can be understood by people who haven't had any exposure to Probability too...



Solution to the Cube Painting problem

There r " 30 " ways in which the cubes can be painted..

Before saying the solution, lemme say why the answer is not " 1 ".. The most common answer i got from my friends is "1". If there was just 1 way to paint the cube then if u have many cubes of this type they would be indistinguishable from each other.. but this is not the case here. A cube with red and blue painted on opposite sides can be distinguished from a cube with red and green painted on opposite sides..

This gives us a hint to the solution.. the cubes can distinguished by what colors lie opposite to each other. So we just have to consider the number of ways to make such pairs..

Now consider an unpainted cube.. Now paint a particular side with 1 color.. Now u have 5 colors left. The number of ways in which the side opposite to this can be colored is in 5 ways.. After coloring the opposite side u have 4 colors left.. Rotate the cube by 90.. and color the blank face wit one more color. Then the face opposite to it an be colored in 3 ways.. Now 2 faces are left.. Color the remaining 2 colors on the 2 sides.. But we will be able to make 1 more distinguishable cube if u jst reverse the way in which the last 2 colors are painted. So the number of cubes tat can be made is 5 * 3 *2 = 30 cubes..

Solution to the series

The next term in the series is 63.
Solution :-
The nth number of the series is the sum of the nth prime number and nth fibonacci number..

The fibonacci series goes lik this 0, 1, 1, 2, 3, 5, 8, 13..
The nth term is the sum of the (n-1)th and (n-2)th term..

The prime numbers go lik this 2, 3, 5, 7, 11, 13, 17...

http://www.research.att.com/~njas/sequences/
This is an online encyclopedia of integer sequences.. Go there and try searching our sequence.
This is a useful link i found while attempting programming competitions at http://www.topcoder.com

Solution to the Three Doors and 1 Prize Problem..

This is a famous problem in probability called the Monty Hall problem.. For more info goto
http://en.wikipedia.org/wiki/Monty_Hall_problem

The answer is it is always better to switch ur choice to the other door.. Chance of winning doubles if u switch ur door.. The solution goes like this..

Suppose doors are numbered 1,2 and 3. Its clear tat u hav an equal probability of choosing any of the doors. Now suppose tat the prize is behind door 1 and the other 2 doors hav goats behind.

Suppose tat u will always switch ur choice when the gameshow host asks u..

If ur choice was door 2, the gameshow host will open up door 3 for u and show u a goat. So since the prize is behind door 1 u will win if u switch to door 1.

If u picked door 3, the gameshow host will open up door 2 for and show u a goat.. So u will win again if u switch ur choice to door 1..

Now suppose ur choice was door 1, the gameshow host will open any of door 2 or 3 for u. This time u will lose if u switch ur door..
So u hav a 2/3 chance of winning if u switch ur door..

Now suppose ur choice was never to switch..

if door 2 was ur choice, u will lose..
if door 3 was ur choice, u will lose again..
if u had picked door 1, u will win.
So u hav a 1/3 chance of winning if u dont switch..

So ur chance of winning doubles if u switch ur doors..
Hope its clear.. The wikipedia article has links to java applets tat demonstrates tat the solution is correct..

Monday, July 2, 2007

Coloring the Cube

U are given a cube and 6 different colors.. In how many ways can u color the cube by coloring each side with a unique color ??

Guess the next term....

2, 4, 6, 9, 14, 18, 25, 32, 44...
guess the next term in the sequence??

Three Doors and 1 Prize

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick door No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to switch to door No. 2?" Wat will be your choice??

Solution to the 2 Mathematicians

The first clue was the product of their ages is 72.
So take all the possibilities.
72 ,1,1 = not possible coz mathematicians met after 27 years.
36, 2,1= not possible
18,2,2
9,4,2
4,6,3
6,6,2
12,3,2
12,6,1
24,3,1
3,3,8

Now the second clue is tat the sum of their ages is a number tat the other guy can clearly see.. But still the other guy cant guess the answer.
18,2,2 =22
9,4,2 =15
4,6,3 =13
6,6,2 = 14
12,3,2 =17
12,6,1 =19
24,3,1 = 28
3,3,8 = 14
So if the guy couldnt guess the answer tat means tat the total must hav been 14. thn u hav 2 possible ways u can factorise 72 wit the sum 14..
so the answer must be 6,6,2 or 8,3,3
The third clue says tat the youngest daughter just started walking.
So.. 8,3,3 s nt possible.. here u hav 2 younger daughters of the same age.

Therefore 6,6,2 is the answer :)

Solution to Cookie Seller

The solution goes lik this.. :)
We hav inifinte number of boxes of each type..
By taking all multiples of 6 we will get all the even multiples of 3 above 6.. and by taking all multiples of 9 we will be able to make all odd multiples of 3. Thus we can make all the multiples of 3 above the number 6..
So wat abt the the other numbers?? hmmm..
Now take the number 29.. it gives 2 as remainder when divided by 3.. if we add 400 to 29 ie 429 is a multiple of 3. So any number above 410 which gives a remainder of 2 when divided by 3 can be made by using a 400 box and the rest 6 and 9.
ie, 421= can be made as 400 + 21 ( 2 *6+1*9) and so on..
Now take the number 28. it gives a remainder 1 when divided by 3. If we add 800 to 28 ie 828 is divisble by 3..
So any number above 806 can be made by these 3 types of boxes..
So wat abt the maximum tat cannot be sold
805 - 400 is divisible by 3..
804 is divisible by 3
803 is nt divisble by 3, 803-400=403 is nt divisble by 3, a 803-800=3 cannot be made using our boxes..

So 803 is the max number of boxes tat cannot be sold..