Free the prisoners puzzle
The warden meets with 23 new prisoners when they arrive. He tells them, “You may meet today and plan a strategy. But after today, you will be in isolated cells and will have no communication with one another.
“In the prison is a switch room, which contains two light switches labeled 1 and 2, each of which can be in either up or the down position. I am not telling you their present positions. The switches are not connected to anything.
“After today, from time to time whenever I feel so inclined, I will select one prisoner at random and escort him to the switch room. This prisoner will select one of the two switches and reverse its position. He must flip one switch when he visits the switch room, and may only flip one of the switches. Then he’ll be led back to his cell.
“No one else will be allowed to alter the switches until I lead the next prisoner into the switch room. I’m going to choose prisoners at random. I may choose the same guy three times in a row, or I may jump around and come back. I will not touch the switches, if I wanted you dead you would already be dead.
“Given enough time, everyone will eventually visit the switch room the same number of times as everyone else. At any time, anyone may declare to me, ‘We have all visited the switch room.’
“If it is true, then you will all be set free. If it is false, and somebody has not yet visited the switch room, you will all die horribly. You will be carefully monitored, and any attempt to break any of these rules will result in instant death to all of you”
What is the strategy they come up with so that they can be free?
Team needs a COUNTER(so selects a leader as counter)
The team nominates a leader. The group agrees upon the following rules so that counting can be done by counter:
The leader is the only person who will announce that everyone has visited the switch room. All the prisoners (except for the leader) will flip the first switch up at their very first opportunity, and again on the second opportunity. If the first switch is already up, or they have already flipped the first switch up two times, they will then flip the second switch. Only the leader may flip the first switch down, if the first switch is already down, then the leader will flip the second switch. The leader remembers how many times he has flipped the first switch down. Once the leader has flipped the first switch down 44 times, he announces that all have visited the room.
It does not matter how many times a prisoner has visited the room, in which order the prisoners were sent or even if the first switch was initially up. Once the leader has flipped the switch down 44 times then the leader knows everyone has visited the room. If the switch was initially down, then all 22 prisoners will flip the switch up twice. If the switch was initially up, then there will be one prisoner who only flips the switch up once and the rest will flip it up twice.
The prisoners can not be certain that all have visited the room after the leader flips the switch down 23 times, as the first 12 prisoners plus the leader might be taken to the room 24 times before anyone else is allowed into the room. Because the initial state of the switch might be up, the prisoners must flip the first switch up twice. If they decide to flip it up only once, the leader will not know if he should count to 22 or 23.
In the example of three prisoners, the leader must flip the first switch down three times to be sure all prisoners have visited the room, twice for the two other prisoners and once more in case the switch was initially up.
what if prisoner happens to call leader all the time lets say 10 times before calling anybody else ,,,,,,
If leader is called 10 times continuously he will still be counting 1 as himself.
Only when The leader will get the Switch up he’ll flip the switch and count 2.
I agree this might be a never ending process but It is the Only solution.
They can just decide to switch up the first switch once, and the leader counts to 23, cause at 23 he can be certain everyone has been to the room.22 wld B a gamble, and with 23 he cold stay at the safe side
No he can’t. Suppose the switch 1 is initially down. They decide to flip switch 1 only once. 1st prisoner goes and switches on switch 1. Then leader goes and switches off switch 1 and counts 1 then 2nd prisoner goes then the leader and this goes on till the 22nd prisoner and counter reads 22 .
Now the counter will never go up to 23 as everyone has flipped the switch 1 once and thus the leader would never declare that they all have visited the room.
safest way i could think of if they assign ID’s 1 to 23 to each of the prisoners (they have to remember their ID’s of-course) and based on their ID
if (even ) flip switch at ur right and if odd flip switch at ur left.
Initially switches can be 00 (off off) or 11 (on on)
Let make a table how switch order changes with every press by each ID’s (they are drawing in group meeting before it starts)
Person ID Switch Left – Switch Right
00
01. 01
02. 11
03. 10
04. 00
05. 01
06. 11
07. 10
08. 00
09. 01
10. 11
11. 10
12. 00
13. 01
14. 11
15. 10
16. 00
17. 01
18. 11
19. 10
10. 00
11. 01
12. 11
13. 10
14. 00
15. 01
16. 11
17. 10
18. 00
19. 01
20. 11
21. 10
22. 00
23. 01
// again 01
01. 00
02. 10
03. 11
04. 10
05. 11
06. 10
07. 11
08. 01
and so on ….
Now you see a pattern doesn’t matter what the initial state of switch is all even ID’s should expect to see the same (00 or 11) in first round and once all 23 visited in second round all odd ID’s will see the switch state same (00 or 11) i.e, once the same person sees the same state (00 or 11) thrice either in order 00 –> 11 –> 00 or 11–> 00 –> 11 i.e, he knows three rounds are done and everyone should have visited it once. So, he can announce the freedom call 😉
The fact that prisoner can pick ” the same guy three times in a row” – doesn’t matter it will flip back to original state. (00 -> odd person came in thrice 01-> 00 -> 01.) and NOTE : he will see the order 00 -> 00 –>not 00 –> 01 –> so no chance of miss calculations.
Only thing they have to remember is their ID’s and once you see 00 –> 11 –> 00 or 11–> 00 –> 11 pattern after u n visits you are good to make a call .
To me on absolutely safe side if in case u don’t want to miss any corner case you can extend the freedom pattern like –> 00 –> 11 –> 00 –> 11 or 11–> 00 –> 11 –> 00 . Or even bigger if you want to enjoy few more nights in prison.
Thanks,
Dhruva
The switch #1 is used to COUNT. The #2 is used to PASS.
The prisoners elect a leader and stablish the following rules and behaviours:
– Only the leader can turn the switch #1 off.
– Only the leader can announce that they all visited the room.
– Leader’s behavior:
If the switch #1 is on, turn off the switch #1 and count 1 visit more ( # of visits starts from zero).
If the # of visits is equal to 23 (22 prisoners plus the case were the switch #1 was already on), warns: “We have all visited the switch room”
If not, flips the switch #2.
– Other’s behavior:
If the switch #1 is turned off and I never turned the switch #1 on, then turn the switch #1 on.
If not, flips the switch #2.
Your Answer
More puzzles to try-
Water Jug riddle
You have two jugs. One jug has a content of 3 litres and the other one has a content of ...Read More »Railway ticket selling puzzle
Every station on the railway system sells tickets to every other station. Some new stations were added. 46 sets of ...Read More »Massage Parlour
Outside a massage parlour, there is a board that reads “I only massage those who do not massage themselves.” Reading ...Read More »Can you see both the young woman and the old woman in this classic optical illusion?
Can you see both the young woman and the old woman in this classic optical illusion? If you need some ...Read More »Fun with fuse riddle
Assume that you have a number of long fuses, of which you only know that they burn for exactly one ...Read More »Holes top and bottom
It has holes on the top and bottom. It has holes on my left and on my right. And it ...Read More »Money and time relation puzzle
A Man gave one of his son 10 cents and another son was given 15 cents. What time is it? ...Read More »Dirty rug like bad boy
Why is a dirty rug like a bad boy ?Read More »A special squarish age
Let’s say that a number is squarish if it is the product of two consecutive numbers. For example, 6 is ...Read More »It is what you love
Ii is what you seek, It is only what is right. It is never wrong. It could be short, It ...Read More »Abnormal paragraph
This is an abnormal paragraph. It is not normal at all. All of its writing is grammatically right, but it ...Read More »Hide and cheat
Some try to hide, some try to cheat, but time will show, we always will meet. Try as you might, ...Read More »Tricky addition riddle
20+20+20=60. How can you make 60 again by using the same number 3 times, but it can’t be 20?Read More »Taller and Deeper it grow
Wherever the wind does go, towards there it dance; With the sun above it grow; Yet without water below, it ...Read More »Chocolates Bricks Riddle
How many steps are required to break an m × n sized bar of chocolate into 1 × 1 pieces? ...Read More »Serial Vowels riddle
The word FACETIOUSLY contains the six vowels, A-E-I-O-U and Y, in their alphabetical order. Find another English word that does ...Read More »cities without houses
Where can we find roads without cars, forests without trees and cities without houses ?Read More »Four-Word Form Energy
I am a five-letter word and people eat me. If you remove the first letter I become an energy form. ...Read More »Helper all the time
You use it everyday but let it rest at night. It has an identical twin beside it all the time. ...Read More »Gold Bar Puzzle
You’ve got someone working for you for seven days and a gold bar to pay him. The gold bar is ...Read More »