Soliloquy

interview questions – part 2

Posted by: eskay on: November 1, 2008

Both the problems here are based on prisoners and hats….

Question 1:

There are n prisoners in a prison. The prison warden gives them an offer:

Activity:

              He will be asking the prisoners to stand in a queue, ordered based on their heights, tallest in the front of the queue and the shortest at the end such that every prisoner can see the heads of all prisoners in front of him. Now everyone will be blindfolded and a black or a white hat will be placed on every head. Distribution will be random. The warden would then remove the blindfolds and would start asking every prisoner the colour of their hat, in order, starting from the shortest. The prisoner can answer either “black” or “white”. If a prisoner tells the answer correctly, he will be freed, otherwise killed instantly. 

The warden gives twenty minutes for the prisoners to discuss the algorithm among themselves. Then the above activity starts. 

Out of n prisoners, how many can be saved for sure ? What is the method ? 

Question 2:

Here there are only three prisoners. The warden has three white and two black hats, and the prisoners know this fact. The warden announces that he would be placing one cap on each of their heads after blindfolding them. After removing the blindfold, every prisoner will be able to see both the other prisoners.

The warden blindfolds them and places the three white hats on their heads. 

Everyone thinks for some time, after which one prisoner answers “white”.

How did the prisoner come to the conclusion that his head had a white hat ?

Solutions

Leave a Reply

What I blog about

When did I blog

November 2008
M T W T F S S
« Oct   Dec »
 12
3456789
10111213141516
17181920212223
24252627282930

Visitor Count

  • 8,422 readers

Quotable Quote


They build too low who build beneath the skies

Visitor Map

Academics Blogs - BlogCatalog Blog Directory