74. There are 100 prisoners in solitary cells. There's a central living room with one light bulb; this bulb is initially off. No prisoner can see the light bulb from his or her own cell. Everyday, the warden picks a prisoner equally at random, and that prisoner visits the living room. While there, the prisoner can toggle the bulb if he or she wishes. Also, the prisoner has the option of asserting that all 100 prisoners have been to the living room by now. If this assertion is false, all 100 prisoners are shot. However, if it is indeed true, all prisoners are set free and inducted into MENSA, since the world could always use more smart people. Thus, the assertion should only be made if the prisoner is 100% certain of its validity. The prisoners are allowed to get together one night in the courtyard, to discuss a plan. What plan should they agree on, so that eventually, someone will make a correct assertion?
This puzzle is hard, and what's worse it's difficult to give clues to. I'm afraid I'm just going to have to tell you the answer:
Before reading the answer can I interest you in a clue?
As usual there's no 'cheating' no passing notes. No writing on the wall. No shouting. The puzzle is pure logic. Let's hope they aren't the same 100 prisoners from the earlier puzzle with the hats.
So when the prisoners meet they agree the following.
One prisoner will be selected as the Captain, in charge of counting.
When a prisoner (other than the Captain,) enters the room he will turn the light on if and only if the light is off and he has never done so before.
When the Captain enters the room if the light is off he will leave it untouched. If the light is on he will turn it off and add one to his count.
When the Captain's count gets to 99 he will assert that all 100 prisoners have entered the room and they will all be released.
If you follow this procedure carefully it will work. But how long will it take?
Efficiency
The duration of the problem based on one prisoner a day being taken in to the room grows with the square of the number of prisoners. It's perfectly legitimate to ask if the solution is practical. You know like would they all be dead by the time it completed? Genuinely before I wrote the simulator I estimated around 30 years (swear to god.) I estimated 100x100 days, as in 100 days between people and 100 days to find them. The other number of interest is how many days it actually takes for all the prisoners to have entered the room if the counting method were perfect. Have a play, (in Firefox if you have the choice,) see what you think:
Note: no information is sent to me, the calculation is done entirely locally, on your computer.
Prisoners
Time to Run milliseconds
Continuous Output Max Prisoners
A conclusion one might draw is that whilst the proposed solution does guarantee complete success it takes on average 10,411 days. Where as if you were just to wait to for what maybe 2000 days and go then. The average is 519!
Both AI's got this puzzle wrong. They looked like they got it right but neither of them realized the point about only flicking the switch if you'd never done it before.
If you're curious what Bard made of this puzzle...
Here is a plan that the prisoners can agree on, so that eventually, someone will make a correct assertion:
Select a leader. The prisoners should select a leader who will be responsible for coordinating the plan.
Assign each prisoner a number. The prisoners should be assigned numbers from 1 to 100.
Develop a protocol. The prisoners should develop a protocol that specifies what each prisoner should do when they are selected to visit the living room. The protocol should include the following steps:
If the light bulb is off, turn it on.
Count the number of times the light bulb has been turned on.
If the count is equal to the prisoner's number, assert that all 100 prisoners have been to the living room.
Implement the plan. The prisoners should implement the plan by following the protocol each time they are selected to visit the living room.
This plan will eventually allow someone to make a correct assertion. The probability that a prisoner will make a correct assertion on their first visit to the living room is 1/100. However, the probability that a prisoner will make a correct assertion at some point is 100%. This is because the probability of a prisoner not making a correct assertion on their first visit is 99/100, and the probability of a prisoner not making a correct assertion on their second visit is (99/100)^2, and so on. The probability of a prisoner never making a correct assertion is equal to the product of the probabilities of them not making a correct assertion on each visit. This product converges to 0 as the number of visits increases. Therefore, the probability that a prisoner will make a correct assertion at some point is 100%.
If you're curious what ChatGPT made of this puzzle...
One possible plan that the prisoners could agree on is:
Designate one of the prisoners as the "counter".
Each time a prisoner is selected to visit the living room, he or she should toggle the light bulb if it is currently off, but do nothing if it is already on.
If a prisoner visits the living room and finds the light bulb on, he or she should not toggle it, but should make a mental note of the fact that the light is on.
Whenever a prisoner is in the courtyard, he or she should announce whether they have visited the living room and toggled the light bulb or not. If a prisoner announces that they have visited the living room and found the light bulb on, the "counter" should make a note of this.
If the "counter" observes that every prisoner except one has visited the living room and toggled the light bulb (or reported that they found the light bulb on), the "counter" should assert that all 100 prisoners have visited the living room.
The key to this plan is that the "counter" keeps track of the number of prisoners who have reported that they found the light bulb on. If the number of such prisoners is 99, then the last prisoner must not have visited the living room yet, since if he had, he would have found the light bulb on and reported it. Therefore, the "counter" can assert that not all prisoners have visited the living room, and no one will be shot.
On the other hand, if the "counter" observes that all 100 prisoners have visited the living room and toggled the light bulb (or reported that they found it on), then he can assert that all 100 prisoners have visited the living room with 100% certainty, and all the prisoners will be set free.
PayPal
I always think it's arrogant to add a donate button, but it has been requested. If I help you get a job though, you could buy me a pint! - nigel
This Website Uses Cookies
To increase the functionality of the site. The cookies I apply do not uniquely identify you, by continuing to use this site you agree to let me place a cookie. I also have advert and analytics providers, my advertising provider (Google,) does provide personalised adverts unless you specify otherwise, with them. For more information click here.x