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.
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.
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
// again 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.
More puzzles to try-
- 3 + 3 = 3 5 + 4 = 4 1 + 0 = 3 2 + 3 = 4 ...Read More »
- There are 10 stacks of 10 coins each. Each coin weights 10 gms. However, one stack of coins is defective ...Read More »
- Which clock works best? The one that loses a minute a day or the one that doesn’t work at all?Read More »
- Paul, Sam and Dean are assigned the task of figuring out two numbers. They get the following information: Both numbers ...Read More »
- Five puzzleFry ship’s pirates have obtained 100 gold coins and have to divide up the loot. The pirates are all ...Read More »
- Four days are there which start with the letter ‘T‘. I can remember only two of them as “Tuesday , Thursday”. ...Read More »
- Two fathers took their sons to a fruit stall. Each man and son bought an apple, But when they returned ...Read More »
- A farmer is taking her eggs to the market in a cart, but she hits a pothole, which knocks over ...Read More »
- Let it be simple and as direct as possible. Interviewer : Tell me how much time (in days) and money would ...Read More »
- Solve this logic sequence puzzle by the correct digit- 8080 = 6 1357 = 0 2022 = 1 1999 = ...Read More »
- A man leaves his house in the morning to go to office and kisses his wife. In the evening on ...Read More »
- Jasmine, Thibault, and Noah were having a night out and decided to order a pizza for $10. It turned out ...Read More »
- Which letter replaces the question markRead More »
- A murderer is condemned to death. He has to choose between three rooms. The first is full of raging fires, ...Read More »
- Richie established a very strange number system. According to her claim for different combination of 0 and 2 you will ...Read More »
- The result of math class test came out. Fariha’s mark was an even number. Srabon got a prime!! Nabila got ...Read More »
- Robi is a very serious student. On the first day of this year his seriousness for study was 1 hour. ...Read More »
- Ragib: I got digits of a 2 digit number Sakib: Is it an odd? Ragib: Yes. Moreover, the sum of ...Read More »
- If u r genius solve it:- 40 * 14 = 11 30 * 13 = 12 20 * 12 = ...Read More »
- When do we call “10” while looking at number “2”?Read More »