Prisoner's Hat Puzzle || 100 Prisoners with Red/Blue Hats || Google Interview Puzzle

preview_player
Показать описание
#SimplyLogical #LogicalInterviewPuzzles

Prisoner's Hat Puzzle

Puzzle Details :
Variation 1 : 100 prisoners in jail are standing in a queue facing in one direction. Each prisoner is wearing a hat of color either black or red. A prisoner can see hats of all prisoners in front of him in the queue, but cannot see his hat and hats of prisoners standing behind him.
The jailer is going to ask color of each prisoner’s hat starting from the last prisoner in queue. If a prisoner tells the correct color, then is saved, otherwise executed. How many prisoners can be saved at most if they are allowed to discuss a strategy before the jailer starts asking colors of their hats.

Variation 2 : An executioner lines up 100 prisoners single file and puts a red or a blue hat on each prisoner's head. Every prisoner can see the hats of the people in front of him in the line - but not his own hat, nor those of anyone behind him. The executioner starts at the end (back) and asks the last prisoner the colour of his hat. He must answer "red" or "blue." If he answers correctly, he is allowed to live. If he gives the wrong answer, he is killed instantly and silently. (While everyone hears the answer, no one knows whether an answer was right.) On the night before the line-up, the prisoners confer on strategy to help them. What should they do?

feel free to pause the video and try yourself before checking the solution.
lets everyone know your answer in the comment section.

Watch our other Videos.

Рекомендации по теме
Комментарии
Автор

Can you solve this "Google Interview Puzzle" ?

SimplyLogical
Автор

This is complex puzzle, believed to be asked in google and microsoft.
Thanks for the clear solution.

deepthihs
Автор

So of I was a jailor, I will provide them 1 red hat and 99 blue hats!

mukeshchandthakur
Автор

Being a criminal on death row, the last person purposefully gives incorrect answer killing everybody.😅(possibly saving himself)

cipherxen
Автор

U didn’t mention same number of red and blue hats are available
As u said he counts hats infront of him
How can he conclude his hat it may be blue r red

Y
Автор

Are their equal no of red and blue hats?

jeetmishra
Автор

Anyways they got chance to discuss their strategy so they can line up sorted by the colours after that if last person able to see blue cap of the person infront of him then he will consider himself cap colour as blue like wise everyone will do the same aand gets colour of their own cap .in this case only one person will get executed , line is sorted will cap colours then there will be one person in front of whom all the person have diff colour cap that person will get executed

lets___explore
Автор

What happens if at most one prisoner was allowed to change his position once during the lineup? Will that change the answer?

annieli
Автор

But if the last one has 50-50 chances of survival, so won't there be a fight while discussing the strategy as none would want to stand last ?

rakeshjoshi
Автор

If it’s red, put arms on right shoulder. If it’s blue, put arms of left shoulder.

When the jailer ask the last prisoner who have nobody behind him, double tap the guy in front of him and everyone in the queue follows through and they switch direction. The rule is all have to face one direction but did not say how many times it can swop direction.Then the last guy will become the first guy in the queue with either a left or right tap on the shoulder.

francscasoh
Автор

This is such a squid game like game...

cutepurplestar
Автор

It seems the exact same strategy would work in both variations. Am I missing something?

mikedaly
Автор

if they are this cooperative that someone is happy to stand at the last and get 50-50 chances of survival and they are allowed to discuss why can't he directly tell the next person the color of his/her hat?? that way the last one would still have 50-50 chances....

piyushkumar
Автор

For the 3 colours also we use the same odd even approch for that i think.

krishnabhagat
Автор

where is the odd and even concept kicking in? why can't it be 99 red and 1 blue hat?

visswanathvenkataraman
Автор

This is not the best video on this topic, in fact it contains at least one error. You ask "How many prisoners can be saved at most?". In fact the correct question is how many prisoners can be saved at least?. The minimum number or prisoners that ca be saved is N-1 (99 in this case). This is guaranteed if everyone follows the rules. If the person at the back of the queue (the first one to guess the color of his hat) is the only one who has to guess and thus has a 50% change of survival.
Also other videos show the prisoners in a line and it makes it obvious that they can see the people in front of them. You video has them all in a 5x6 matrix on the left side.

viorelnegoita