Archive for the ‘Puzzle’ Category

h1

Pirates !

June 23, 2007

Five pirates have 100 gold coins.They have to divide up the
loot.In order of seniority,each pirate proposes a distribution
of the loot.All the pirates vote,and if at least half accept the
proposal,the loot is divided as proposed.If not,the most senior
pirate is eliminated,and they start over again with the next
senior pirate.What solution does the most senior pirate
propose? Assume they are very intelligent,extremely greedy,
and interested in surviving.

09.png

Solution:

The most senior pirate knows that he needs to get two other pirates
to vote for his solution in order for him not to be eliminated. So why
would any pirate vote for him? The next most senior pirate would
surely see it in his self-interest for the senior pirate to be eliminated.
Letís start simplifying. If there were only one pirate, there would
be no puzzle. The pirate would take all the loot, and no one
would complain.
Now consider the situation with two pirates. Same outcome. The
senior pirate takes all the loot, and the other pirate can’t do a thing
about it as the senior pirate’s vote represents half of the voters.
It gets more complicated for the senior pirate when there are
three pirates. Let’s number the pirates from least to most senior:
1, 2, and 3. With three pirates, pirate 3 has to convince at least one
other pirate to join his collation. Pirate 3 realizes that if his plan
is not adopted, he will be eliminated, and they will be left with two
pirates. All of them know what happens when there are two pirates:
pirate 2 takes all the loot himself and pirate 1 gets nothing. So pirate
3 proposes that he will take 99 gold coins and give 1 coin to pirate
1. If pirate 1 has any self-interest at all, he really has no choice. If
pirate 1 rejects the offer, he gets nothing. So pirate 3ís plan will
pass two to one over pirate 2ís objection.
With four pirates, an even number, the senior pirate needs just one
vote other than his own to impose his will. His question now is which
one of the other pirate’s votes can be exchanged for the fewest number
of coins. Pirate 2 recognizes that he is most vulnerable. Therefore, pirate
4 knows that if he gives pirate 2 anything at all, he will vote for it.
A rule is emerging here. In each case, the senor pirate should buy
only the votes he needs, and buy them as cheaply as possible. Apply
the rule to the five-pirate case. Pirate 5 needs two votes plus his own.
The goal is to toss a coin or two to pirate 1 and pirate 3, the two
pirates in the most vulnerable positions. Both will be empty-handed .

if the senior pirate is eliminated and four pirates remain. So pirate
5 offers one coin to pirate 3 and one coin to pirate 1. Pirates 2 and
4 get nothing.

Click here for detailed solution.

h1

Why nine minutes?

June 23, 2007

Many consumer alarm clocks have a snooze button that is
calibrated for 9 minutes.Does that sound like an odd
decision? Many people would think a 10-minute snooze
interval would make more sense.So were the designers asleep?
Why 9 minutes?

991126.gif

By setting the snooze time to 9 minutes, the alarm clock only needs to
watch the last digit of the time. Whether implemented by physical circuitry
or software, it is easier to manipulate just the terminal digit.

h1

Programmers and HR !

June 15, 2007

One hundred programmers are lined up one in front of the
other by an evil human resources person such that
programmers can see only the programmers in front of
them.The HR person puts a red hat or a blue hat on every
programmer.The programmers cannot see their own hats,
nor can they see the hats of those behind them,but they can
see the hats of the people in front of them.The HR person
starts with the last programmer in the back and says,
“What color is your hat?”

Programmers can answer with only one of two words,red
or blue.If the answer does not match the color of the hat on
the person’s head,the candidate is dismissed.Then the evil
HR person moves on to the next programmer,going from the
rear to the front of the row.Programmers in front get to hear
the answers of the programmers behind them,but not whether
they are dismissed or not.They can consult and agree on a
strategy before being lined up,but after being lined up and
having the hats put on,they can’t communicate in any way
other than by what has been specified.
What strategy should the programmers select to guarantee
the maximum number of surviving programmers?

Solution:

Is the best strategy for every programmer to say the same color, let’s
say “red” ? Assuming the hats were randomly distributed, half of them
would survive. Another strategy calls for every programmer to identify
the color of the hat on the head of the programmer immediately in front
of him or her. This guarantees the survival of that programmer, but does
nothing to promote the programmer’s own chances for survival. This
strategy also guarantees that at least half survive, plus a little more since
chance predicts that some of the programmers would have hats of the
same color as the person in front of them, thus sparing them both. In
fact, assuming random distribution of hats, this strategy yields a survival
rate of 75 percent. Getting better.
Some candidates might try to game the puzzle by suggesting that the people
in the puzzle could agree to give clues to each other by using a certain tone
of voice or drawing out the words. One candidate suggested that they could
agree that if they said their hat color in a soft voice, it means the hat in front
of them is the same color, and if they say it in a loud voice, it means the
hat in front is a different color. Recruiters think this is definitely good and
on the correct track. Another option is they could say “reeeeeeeeeeed” for
x number of seconds, where x represented the distribution of hats where a
hat was a bit in a binary number (red = 1, blue = 0).

But the ideal solution, that the programmers can say only red or blue and cannot alter their
voice in such a convincing way as to signal any information other than
the word they said. A good way to get this point across is simply to
change the problem slightly by saying ìthe evil HR person gets to hear
their plan beforehand and will thwart it if it is not to the rules.î
But even with the HR person hearing their plan in advance, there is
still a way to save almost everyone. We know that the first programmer
is never going to have any information about the color of his or her hat,
so this person cannot be guaranteed to survive. But every other person can
be saved with certainty. The programmers simply agree that if the number
of red hats that the rear-most person can see is even, then the programmer
will say “red” If the number of red hats that the rear-most person can see
is odd, the programmer will say “blue” This way, programmer number
99 can look ahead and count the red hats. If the sum of red hats is an
even number and number 100 said “red” then 99 must be wearing a blue
hat. If they add up to an even number and number 100 said “blue” signal-
ing an odd number of red hats, number 99 must also be wearing a red hat.
Number 98 knows that 99 said the correct hat, and so uses that information along with the 97 hats in front to figure out what color hat is on
the head of programmer 98.
Even if the evil HR person knows the plan, the person can’t thwart
it. The plan doesn’t rely on any specific ordering of the hats. The worst
outcome is that the evil HR person will ensure that programmer number
100 is dismissed.

h1

Bucket and water!

June 15, 2007

You have a 3-quart bucket,a 5-quart bucket,and an infinite
supply of water.How can you measure out exactly 4 quarts?

Solution:

Step 1- Fill 3-quart bucket and pour it into 5-quart bucket.

Step 2- Fill the 3-quart bucket again and pour it into 5-quart bucket , this leaves you with 1-quart water in the 3-quart bucket.

Step 3- Empty the 5-quart bucket and pour the 1 quart water from the 3-quart bucket.

Step 4- Fill the 3-quart bucket once again and pour it into the 5-quart bucket and you have 4 quart water in the bucket.

h1

Contaminated pill!

June 15, 2007

You have ten jars of pills.One jar of pills is contaminated.The
only way to tell which pills are contaminated is by weight.A
regular pill weighs 10 grams; a contaminated pill weighs 1.1 grams.
You are given a scale and allowed to make just one measurement
with it.How do you tell which jar is contaminated?

Solution: 

1- Take 1 pill from 1st jar,2 pills from 2nd jar and so on. .. …

n pills from nth jar.

2-Weight them

3- If the total weight is :

10.1  –> 1st jar had contaminated pill.

10.2 –>2nd jar had contaminated pill.

10.n –> nth jar had contaminated pill.

h1

Easy one!

June 12, 2007

Consider an analog clock.What is the angle between the
minute hand and the hour hand at 3:15?

Solution: 

7.5 degree(simple and needs no explaination, I guess !)

h1

Secure Send!

June 12, 2007

You want to send a valuable object to a friend securely.You
have a box that is more than large enough to contain the object.
You have several locks with keys.The box has a locking ring
that is more than large enough to have a lock attached.But
your friend does not have the key to any lock that you have.
How do you send the object securely?

Solution:

This puzzle deserves to be stated in the introduction class of cryptography. Let’s say you
want to send a secret message to your friend. Because you don’t trust
commercial and freeware encryption methods, you use a secret cipher of
your own. Only you know the key to the cipher. Not even your friend
knows it. So you send the encrypted message; your friend encrypts it
further with his or her favorite secret cipher and sends it back to you.
You remove your cipher and send it back to your friend; and he or she
removes the second secret cipher and reads the clear text. This process
has the benefit of being very quick and easy by e-mail.
The ideas are perhaps related in some ways. But
the story may just be told to show that really secure ciphers (ones where
he decryption keys are not spread around to many people) are possible.

Put the valuable object into the box, secure it with one of
your locks, and send the box to your friend. Your friend should then
attach one of his own locks and return it. When you receive it again,remove your lock and send it back. Now your friend can unlock his own
lock and retrieve the object.

h1

Marbles

June 12, 2007

In a box you have 13 white marbles and 15 black marbles.You
also have 28 black marbles outside the box.Remove 2 marbles,
randomly,from the box.If the marbles are of different colors,
put the white one back in the box.If they are of the same color,
remove both of them and replace them with a black marble
from outside the box.Continue this process until only 1 marble
remains in the box.What color is the last marble?

Solution: 

Most of the people will find the concepts of probability around them as they progress with the question. It won’t take much time to realize that the puzzle has nothing much to do with probability.Since marbles can only be taken out in pairs and we started off with
an odd number of white marbles, there is always going to be 1 white
marble left over that you’ll keep putting back in the box until it’s left
on its own.

 

h1

Socks!

June 12, 2007

There are three sock drawers in a bureau.The drawers are
labeled White,Black,and Mixed,but every drawer is labeled
incorrectly.One drawer has all white socks,one all black socks,
and one mixed white and black socks.You are permitted to
close your eyes and pick one sock from one drawer.How can
you correctly label each drawer?

Solution:

It is very important to notice that all the drawer are labeled incorrectly.Just take out a sock from one labeled with “mixed”. If the sock drawn is :

White : Then the drawer has all white socks, the drawer labeled with Black must be mixed one and the remaining one has all Black socks.

Black: Then the drawer has all black socks, the drawer labeled with White must be mixed one and the remaining one has all White socks.

h1

Water and Ice

June 12, 2007

Consider a glass of water with an ice cube in it and with the
water level at the very brim of the glass.What happens to
the water level as the ice melts? Will the water level go up
and overflow the glass,go down,or remain unchanged.Why?
Ignore evaporation and the effects of surface tension.

 

 

 

Solution:

Ice is less dense than water. That’s
why it floats. We also know that ice occupies more volume than
water. We know this because a full bottle of water will shatter as
it freezes and the ice expands. So the first thought is that the water
level will drop. But I know from experience that a glass full of ice
doesn’t overflow when the ice melts. Why is that? I think that’s
because the ice is floating with a section of the ice sticking up
above the water level. Thus, when the ice melts, it shrinks, but this
is counterbalanced by the volume of ice that is sticking up out of
the water. Thus, there will be no change in the level of the water
from the melting ice. I wish I could draw a couple of free body diagrams showing the the equilibrium of forces.