Archive for category Puzzle

Pirates !

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.



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.


Leave a comment

Why nine minutes?

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?


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.

Leave a comment

Programmers and HR !

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?


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.

Leave a comment

Bucket and water!

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


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.

Leave a comment

Contaminated pill!

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?


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.

Leave a comment