CTK Exchange
CTK Wiki Math
Front Page
Movie shortcuts
Personal info
Awards
Terms of use
Privacy Policy

Interactive Activities

Cut The Knot!
MSET99 Talk
Games & Puzzles
Arithmetic/Algebra
Geometry
Probability
Eye Opener
Analog Gadgets
Inventor's Paradox
Did you know?...
Proofs
Math as Language
Things Impossible
My Logo
Math Poll
Other Math sit's
Guest book
News sit's

Recommend this site

Manifesto: what CTK is about Search CTK Buying a book is a commitment to learning Table of content Products to download and subscription Things you can find on CTK Chronology of updates Email to Cut The Knot Recommend this page

CTK Exchange

Subject: "100 prisoners and a light bulb"     Previous Topic | Next Topic
Printer-friendly copy     Email this topic to a friend    
Conferences The CTK Exchange This and that Topic #634
Reading Topic #634
iliaden
Member since Aug-14-05
Aug-14-05, 05:18 PM (EST)
Click to EMail iliaden Click to send private message to iliaden Click to view user profileClick to add this user to your buddy list  
"100 prisoners and a light bulb"
 
   A few years ago, I have encountered this problem, and ever since I haven't been able to find the most optimal solution.

This is the problem:

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?

I have seen this problem on othe forums, and here are some of the best solutions (to my opinion):

1) At the beginning, the prisoners select a leader. Whenever a person (with the exeption of the leader) comes into a room, he turns the lights on. If the lights are already on, he does nothing. When the leader goes into the room, he turns off the lights. When he will have turned off the lights 99 times, he is 100% sure that everyone has been in the room.

2)wait 3 years, and with a great probability say that everyone has been in the room.

Does anyone know The optimal solution???

I have taken this problem from the www.ocf.berkeley.edu site, but I believe that you can find it on many others.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top

  Subject     Author     Message Date     ID  
  RE: 100 prisoners and a light bulb alexbadmin Aug-14-05 1
     RE: 100 prisoners and a light bulb mr_homm Aug-17-05 2
         RE: 100 prisoners and a light bulb alexbadmin Aug-17-05 3
             RE: 100 prisoners and a light bulb Sheridan Aug-18-05 4
             RE: 100 prisoners and a light bulb mr_homm Aug-18-05 5
                 RE: 100 prisoners and a light bulb alexbadmin Aug-18-05 6
                     RE: 100 prisoners and a light bulb mr_homm Aug-19-05 7
                     RE: 100 prisoners and a light bulb sfwc Aug-21-05 8
                         RE: 100 prisoners and a light bulb mr_homm Aug-29-05 9
                             RE: 100 prisoners and a light bulb mr_homm Aug-29-05 10
                                 RE: 100 prisoners and a light bulb sfwc Sep-21-05 12
         RE: 100 prisoners and a light bulb alexbadmin Nov-03-05 24
             RE: 100 prisoners and a light bulb mr_homm Nov-04-05 25
                 RE: 100 prisoners and a light bulb alexbadmin Nov-04-05 26
                     RE: 100 prisoners and a light bulb mr_homm Nov-05-05 27
                         RE: 100 prisoners and a light bulb alexbadmin Nov-08-05 28
     RE: 100 prisoners and a light bulb alexbadmin Sep-08-05 11
         RE: 100 prisoners and a light bulb Rod H. Sep-28-05 13
             RE: 100 prisoners and a light bulb ramsey2879 Sep-29-05 14
                 RE: 100 prisoners and a light bulb Rod H. Oct-03-05 18
             RE: 100 prisoners and a light bulb iliaden Sep-29-05 15
                 RE: 100 prisoners and a light bulb Ramsey2879 Sep-30-05 16
                     RE: 100 prisoners and a light bulb iliaden Sep-30-05 17
                 RE: 100 prisoners and a light bulb Rod H. Oct-04-05 19
                     RE: 100 prisoners and a light bulb iliaden Oct-16-05 20
                         RE: 100 prisoners and a light bulb ramsey2879 Oct-27-05 21
                             RE: 100 prisoners and a light bulb iliaden Oct-30-05 23
  RE: 100 prisoners and a light bulb Mendozas Oct-30-05 22
     RE: 100 prisoners and a light bulb Ghigginson Feb-04-07 29
     RE: 100 prisoners and a light bulb Ghigginson Feb-04-07 30
         RE: 100 prisoners and a light bulb The Dog Feb-05-07 31
  RE: 100 prisoners and a light bulb ryani Apr-23-07 32
  RE: 100 prisoners and a light bulb mmc May-31-07 33
  RE: 100 prisoners and a light bulb maryam Jul-28-07 34
  RE: 100 prisoners and a light bulb mpdlc Jul-31-07 35
  100 prisoners and a light bulb: trivial solution al_q Aug-02-07 36
  RE: 100 prisoners and a light bulb Arup Roy Sep-25-07 37
  RE: 100 prisoners and a light bulb spags Mar-28-08 38
     RE: 100 prisoners and a light bulb Kerry Oct-12-09 39
         RE: 100 prisoners and a light bulb alexbadmin Oct-14-09 40

Conferences | Forums | Topics | Previous Topic | Next Topic
alexbadmin
Charter Member
2448 posts
Aug-14-05, 07:29 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
1. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   >A few years ago, I have encountered this problem, and ever
>since I haven't been able to find the most optimal solution.
>
>This is the problem:
>
>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?

The problem is indeed popular. It's even included in P. Winkler's Mathematical Puzzles, which is a recommended book in any event. Winkler also lists a slew of sources where the problem appeared, including ibm.com and a newsletter of the MSRI.

The solution is this:

The prisons select a fellow, say Alice, who will have a special responsibility. All other prisoners behave according to the same protocol: each turns the light off twice, i.e. they turn it off the first two times they find it on. They leave it untouched thereafter. Alice turns the light on if it was off and, additionally, counts the number of times she entered the room with the light off. When her count reaches 2n - 3 she may claim with certainty that all n prisoners have been to the room.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mr_homm
Member since May-22-05
Aug-17-05, 03:53 PM (EST)
Click to EMail mr_homm Click to send private message to mr_homm Click to view user profileClick to add this user to your buddy list  
2. "RE: 100 prisoners and a light bulb"
In response to message #1
 
   >
>The solution is this:
>
>The prisons select a fellow, say Alice, who will have a
>special responsibility. All other prisoners behave according
>to the same protocol: each turns the light off twice, i.e.
>they turn it off the first two times they find it on. They
>leave it untouched thereafter. Alice turns the light on if
>it was off and, additionally, counts the number of times she
>entered the room with the light off. When her count reaches
>2n - 3 she may claim with certainty that all n
>prisoners have been to the room.

This would work of course, but is it optimal? For instance, this would also work, I think:

Alice counts the times she finds the light on, and ensures that it is always off when she leaves the room. Everyone else turns on the light the first time they find it off, and then never touches it again. This way, between visits of Alice, at most one prisoner will turn on the light, and no prisoner turns it on more than once. Therefore the number of times Alice finds the light on is no more than the number of different prisoners that have entered the room. Each prisoner knows he has been counted once he has turned the light on, since he is the only one who touched the switch since Alice last visited. When Alice counts to n-1, she knows everyone has visited the room.

What does optimal mean here? It could only reasonably mean that the prisoners are freed in the shortest time. So what is the expected time they must wait until Alice has counted to n-1? This is a rather elaborate calculation in probability, so the prisoners turn to the actuary (who is in prison for embezzlement) for some answers.

He explains that using Bayes theorem, P(X|Y)*P(Y) = P(X&Y) = P(Y|X)*P(X) and the linearity of expected value, E(X|Y)*P(Y) + E(X|~Y)*P(~Y) = E(X) you can calculate the expected time in prison like this:

Suppose Alice has just visited the room, and let K be the number of days that pass before her next visit (so she visits again K+1 days from now), let n be the number of prisoners, let c be the number of times she has found the light on so far, and let P(ON) and P(OFF) be the probabilities that she finds the light on or off on her next visit. Then E(K)=1/n, P(K=k) = 1/n*((n-1)/n)^k, P(K=k|OFF) = 1/n*(c/n)^k, which are fairly obvious.

Bayes theorem then gives P(K=k|OFF) = (1-c/n)*(c/n)^k, and from this you can calculate E(K|OFF) = c/(n-c). and linearity gives E(K|ON) = ((n-1)(n-c)-c/(n-c))/(n-c-1). Now let m be the number of times Alice visits and L be the number of days that pass before she next finds it on. Each time she finds it is off, c does not change, so all the calculations regarding the time until her next visit also do not change.

Therefore, the expected number of days until she next finds the light on is found by summing over all possible m to get the expected total time wasted on visits where the light is off, plus the expected time for the one visit where it was on. This gives E(L) = (1+E(K|ON))P(ON) + sum(m(1+E(K|OFF))P(OFF)^m = n(1/(n-c-1) - 1/(n-c) + 1 - 1/(n-c)^2).

Now we know how long we expect to wait from count = c to count = c+1. Therefore, we must sum this up from c=0 to c=n-2 to find the total expected time E(T). The result is E(T) = n^2 - n/(n-1) - a, where a = sum(1/c^2) from 2 to n. Putting n=100 into this gives 9935.5 days, which is 26.2 years.

But (continues the actuary) this is absurdly long to wait. Simple probability shows that we can be almost certain much sooner than this. The probability that on day d the count is c is P(c,d), which is obviously equal to P(c-1,d-1)*(1-(c-1)/n) + P(c,d-1)*(c/n). Of course, P(0,0) = P(1,1) = 1 and P(1,0) = 0, so we can recursively calculate the probability P(n,d). It turns out that P(100,1146) = 0.999, and P(100,1375) = 0.9999, P(100,1604) = 0.99999, and P(1833) = 0.999999. That means that in 3.14 years, we have a less than 1/1000 chance of failing, and in exactly 5 years and a week, we have less than one in a million chances of failing. I say we should wait 5 years and then say "let us out, we've all seen the light."

As they are about to kill Alice (who was already a member of Mensa) for coming up with a crazy plan to keep them in prison for 26 years, the game theorist (who is in prison for insider trading on the stock market) steps in to point out that this is a losing move. If they kill her now she will never go into the room, and the warden will keep them here forever.

In the happy ending, they let Alice live, and they all get out of prison in 5 years. Strangely, they all decline to join Mensa, preferring to enter actuarial training.

--Stuart Anderson


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexbadmin
Charter Member
2448 posts
Aug-17-05, 09:22 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
3. "RE: 100 prisoners and a light bulb"
In response to message #2
 
   >This would work of course, but is it optimal? For instance,
>this would also work, I think:

It's a pleasure seeing you having fun.

>Alice counts the times she finds the light on, and ensures
>that it is always off when she leaves the room. Everyone
>else turns on the light the first time they find it off, and
>then never touches it again. This way, between visits of
>Alice, at most one prisoner will turn on the light, and no
>prisoner turns it on more than once. Therefore the number
>of times Alice finds the light on is no more than the number
>of different prisoners that have entered the room. Each
>prisoner knows he has been counted once he has turned the
>light on, since he is the only one who touched the switch
>since Alice last visited. When Alice counts to n-1, she
>knows everyone has visited the room.

The problem may be in that the original state of the light is not known. You must account for both possibilities.

Your approach will work if originally the light was off. If it was on and Alice counted it as 1, she is bound to cause an action no one of her fellow prisoners would appreciate. However, if she decides to skip the first count and originally the light was off, she will never reach the revelation point.

>
>What does optimal mean here? It could only reasonably mean
>that the prisoners are freed in the shortest time.

Or, perhaps, the least count that would assure the prisoner release.



  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Sheridan
guest
Aug-18-05, 07:58 AM (EST)
 
4. "RE: 100 prisoners and a light bulb"
In response to message #3
 
   A simple way around the problem of not knowing the original state of the light is to say that the person who enters the room on the first day turns the light off.
They then start the procedure from day two (with the person who first entered the room "resetting")


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mr_homm
Member since May-22-05
Aug-18-05, 01:29 PM (EST)
Click to EMail mr_homm Click to send private message to mr_homm Click to view user profileClick to add this user to your buddy list  
5. "RE: 100 prisoners and a light bulb"
In response to message #3
 
   >
>The problem may be in that the original state of the light
>is not known. You must account for both possibilities.
>
In the problem as stated here by Iliaden, the bulb was initially off. Perhaps there are other variants of this problem on the internet with different starting assumptions, such as an unknown initial bulb state, and the solution you presented is for one of those.

>Your approach will work if originally the light was off. If
>it was on and Alice counted it as 1, she is bound to cause
>an action no one of her fellow prisoners would appreciate.
>However, if she decides to skip the first count and
>originally the light was off, she will never reach the
>revelation point.
>
Actually, this is easy to fix. Just add a rule that whoever is picked to go to the room the first day must turn out the light, and then revert to the original rules starting from day 2. This adds one day to their 26.2 year wait.

By the way, I am thinking of this problem as a programming problem, in which there is a controlling process (Alice) that receives a series of 1-bit'semaphore flags from some other processes in a message register which is only checked occasionally. Since she can only receive 1 bit, and there is no possibility of somehow encoding extra information into only 1 bit, at most one other prisoner can send her a signal. She must reset the register to a known state so that she can detect the next flag sent, and the other prisoners must not overwrite each other's flags, so only one prisoner may touch the switch between visits from Alice. It was this line of thinking that led me to set up the prisoners' protocol the way I did. This is also where the idea came from in the paragraph just above this one: I am simply initializing the register. It's just "startup code."
>>
>>What does optimal mean here? It could only reasonably mean
>>that the prisoners are freed in the shortest time.
>
>Or, perhaps, the least count that would assure the prisoner
>release.

Well, yes, now that you mention it, although of course the shortest time to freedom would be more to the prisoners' taste. I suspect that the least count would also be the shortest time, but this is not completely clear. For example, Alice needs to count to n-1 in my solution, 2n-3 in yours, but since each prisoner turns the light switch twice, she is twice as likely to detect a signal in the solution you presented, and therefore will increment her count more often. Possibly both solutions lead to approximately the same total waiting time.

Another type of optimality occurs to me now: minimizing the amount of information the other prisoners have to remember. In one solution each prisoner has to remember which of 2 states he is in (I have turned on the light 0 or 1 times before), and in the other, which of 3 states he is in (I have turned on the light 0, 1, or 2 times before). In human terms, the prisoners might forget after a lapse of years, whether they turned the light on once or twice (disastrous!), but they are less likely to forget whether they turned it on at all. In programming terms, the other processes need an internal buffer to hold their current state, and this buffer is smaller (1 bit) with two states than with three states (2 bits). The Alice process needs n states instead of 2n-2 as well.

Come to think of it, this question would make a good problem assignment for an electrical engineering course: design a set of interacting finite state machines with a shared one bit register that solve this problem. In order to do this, they must be good at translating outcome requirements into protocols and protocols into hardware. Of course, most students don't like to be challenged this much, so they would probably complain that the assignment was "unfair."

--Stuart Anderson


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexbadmin
Charter Member
2448 posts
Aug-18-05, 03:31 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
6. "RE: 100 prisoners and a light bulb"
In response to message #5
 
   >>The problem may be in that the original state of the light
>>is not known. You must account for both possibilities.
>>
>In the problem as stated here by Iliaden, the bulb was
>initially off.

I missed that. I just recognised the problem "holistically", as I remembered it from some time ago, without actually reading it.

>Perhaps there are other variants of this
>problem on the internet with different starting assumptions,
>such as an unknown initial bulb state, and the solution you
>presented is for one of those.

Does not look like it. The only discernable difference (besides the initial condition) is that the prisoners are sent to that room "infinitely often, but in a some arbitrary order determined by their jailer." Curious why Winkler settled for 2 actions instead of 1.

>>Your approach will work if originally the light was off. If
>>it was on and Alice counted it as 1, she is bound to cause
>>an action no one of her fellow prisoners would appreciate.
>>However, if she decides to skip the first count and
>>originally the light was off, she will never reach the
>>revelation point.
>>
>Actually, this is easy to fix. Just add a rule that whoever
>is picked to go to the room the first day must turn out the
>light, and then revert to the original rules starting from
>day 2. This adds one day to their 26.2 year wait.

Right.

>By the way, I am thinking of this problem as a programming
>problem, in which there is a controlling process (Alice)
>that receives a series of 1-bit'semaphore flags from some
>other processes in a message register which is only checked
>occasionally.

Winkler spends 1.5 page proving an additional fact that, for n > 2 there could be only 1 controlling process, in the sense that an arrangement wherewith more than 1 fellow gets a chance to determine with certainty that all prisoners went to the room is impossible.

Now, at the risk of appearing denser than I really am, let me quote from your message:

"Suppose Alice has just visited the room, and let K be the number of days that pass before her next visit (so she visits again K 1 days from now), let n be the number of prisoners, ... Then E(K)=1/n,..."

I would assume that, as n grows, the wait period grows as well. Thus E(K)=1/n does not seem right.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mr_homm
Member since May-22-05
Aug-19-05, 06:07 AM (EST)
Click to EMail mr_homm Click to send private message to mr_homm Click to view user profileClick to add this user to your buddy list  
7. "RE: 100 prisoners and a light bulb"
In response to message #6
 
   >Winkler spends 1.5 page proving an additional fact that, for n > 2
>there could be only 1 controlling process

That's interesting; it never occured to me to consider more. I should think it was fairly obvious that only one is possible. Ultimately, some single counter (let's say Alice but it could be any of them) must become certain that all the prisoners have visited the room. If there is more than one counter, this information must come at least partly by communication from the other counters. But there is only one channel of communication, and it only holds one bit, so there is no way for a counter to know whether a signal is coming from another counter or a regular prisoner. Therefore it is impossible for a counter to respond differently to another counter than to a prisoner, so the counter must simply increment her count, just as she would with an regular prisoner.

Therefore the only signal a counter can send to another counter means "increment your count." Her only choice is of the circumstances under which to send it. If she is to transmit to other counters the number of prisoners she has counted, she must signal once for each such prisoner. But she has no control over who receives the signal--in fact, she may receive it herself, and will have no way to know. Therefore, she might increment her own count, and thus overcount the prisoners. This of course destroys the whole scheme.

>I would assume that, as n grows, the wait period grows as
>well. Thus E(K)=1/n does not seem right.

Thanks, that was my mistake. I worked this out on a blackboard, misread my own handwriting and typed what I saw. It'should be E(K)=n-1, which I misread as n^(-1) and typed as 1/n, completely obscuring the connection to the original. The calculations are of course based on the correct value, n-1.

I see that Sheridan beat me to posting the way around the problem of an indeterminate initial bulb state. That's what I get for taking so long writing without checking the page for updates.

--Stuart Anderson


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
sfwc
Member since Jun-19-03
Aug-21-05, 03:25 PM (EST)
Click to EMail sfwc Click to send private message to sfwc Click to view user profileClick to add this user to your buddy list  
8. "RE: 100 prisoners and a light bulb"
In response to message #6
 
   >Winkler spends 1.5 page proving an additional fact that, for
>n > 2 there could be only 1 controlling
>process, in the sense that an arrangement wherewith more
>than 1 fellow gets a chance to determine with certainty that
>all prisoners went to the room is impossible.
In the situation where the bulb is initially off (or the first prisoner knows (s)he is first so can turn it off, and there are three prisoners, all three may use the following strategy:

If the first time you see the bulb it is on, turn it off and then never change it again. When you next see it on, declare that all prisoners have visited the room.

If the first time you see the bulb it is off, turn it on and then never change it again.

Then certainly they will be freed, but there is no controlling process. It is possible to set up strategies with no controlling process in all the variations I am aware of. However, there are some variations in which there must be a single process which obeys different rules to the others.

Thankyou

sfwc
<><


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mr_homm
Member since May-22-05
Aug-29-05, 03:13 PM (EST)
Click to EMail mr_homm Click to send private message to mr_homm Click to view user profileClick to add this user to your buddy list  
9. "RE: 100 prisoners and a light bulb"
In response to message #8
 
   >If the first time you see the bulb it is on, turn it off and
>then never change it again. When you next see it on, declare
>that all prisoners have visited the room.
>
>If the first time you see the bulb it is off, turn it on and
>then never change it again.
>
>Then certainly they will be freed, but there is no
>controlling process. It is possible to set up strategies
>with no controlling process in all the variations I am aware
>of. However, there are some variations in which there must
>be a single process which obeys different rules to the
>others.
>
>Thankyou
>
>sfwc

Prisoner A enters the room on day one and finds the light off, so he turns it on.
Prisoner B enters the room on day two and finds the light on, so he turns it off and notes that he first saw the light on.
Prisoner C enters the room on day three and finds the light off, so he turns it on.
By chance, Prisoner B is called again to the room on day four, finds the light on, reports that everyone has entered the room, and the prisoners are all killed.

Obviously they cannot all have visited by day 4 if there are 100 prisoners. Am I missing something?

--Stuart Anderson


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mr_homm
Member since May-22-05
Aug-29-05, 05:10 PM (EST)
Click to EMail mr_homm Click to send private message to mr_homm Click to view user profileClick to add this user to your buddy list  
10. "RE: 100 prisoners and a light bulb"
In response to message #9
 
   @ swfwc:

Never mind; I missed seeing your first paragraph because there was no space between it and the quoted material. Sorry! Your example certainly seems to work for three prisoners. Do you have any examples of strategies that work with many prisoners and yet have no single overall controlling process?

--Stuart Anderson


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
sfwc
Member since Jun-19-03
Sep-21-05, 07:55 PM (EST)
Click to EMail sfwc Click to send private message to sfwc Click to view user profileClick to add this user to your buddy list  
12. "RE: 100 prisoners and a light bulb"
In response to message #10
 
   >Do you have any examples of strategies that work
>with many prisoners and yet have no single overall
>controlling process?
Yes, but in some sense they feel a bit like cheating. For example, suppose there are 100 prisoners using the simplified strategy you suggest in message 2. Suppose further that the warden is annoyed by the pedantry one of the prisoners, a mathmo called Bob. So he hatches a cunning plot. Bob is the first into the switch room, and of course he turns the light on. After this he is called into the switch room remarkably often, indeed so often that there is never any occasion when two other prisoners consecutively enter the switch room.

One day Alice wins them all their freedom by declaring that they have all been in the room. The previous day, of course, Bob was in the switch room. Because he had been in so often, he had gathered a lot of information. As much, in fact, as Alice has the following day. So he knew that everyone had been in the room. But he pedantically stuck to the strategy as given and did not declare this fact. This caused him a good deal of frustration, which was not helped by the warden's evil cackling at the success of his ploy.

Now, with hindsight, Bob concieves of a new strategy, just like the old one except that a person in his situation may declare that everyone has in fact been in the room. Of course this strategy is certain to work, but it now has no single overall controlling process, since any of the prisoners may make the declaration which wins them their freedom. This is an example of such a cheating strategy.

However, it may be shown for some versions of the problem that if there are at least 4 prisoners there is at least one prisoner in any winning strategy who follows a set of rules different to the rules of any other prisoner.

Thankyou

sfwc
<><


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexbadmin
Charter Member
2448 posts
Nov-03-05, 01:40 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
24. "RE: 100 prisoners and a light bulb"
In response to message #2
 
   Stuart,

I just remembered of my intention to give your response more publicity than it gets in the forum, as it certainly deserves. I thus made a page out of it, of which I hope you approve.

(https://www.cut-the-knot.org/Probability/LightBulbs.shtml)

Thank you,
Alex


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mr_homm
Member since May-22-05
Nov-04-05, 12:11 PM (EST)
Click to EMail mr_homm Click to send private message to mr_homm Click to view user profileClick to add this user to your buddy list  
25. "RE: 100 prisoners and a light bulb"
In response to message #24
 
   >Stuart,
>
>I just remembered of my intention to give your response more
>publicity than it gets in the forum, as it certainly
>deserves. I thus made a page out of it, of which I hope you
>approve.

Yes, thank you! I am very happy that you thought well enough of it to include it as a page.

However, I was embarrassed to find that I had made a typo in one of the formulas in my original post:

In the paragraph


Suppose Alice has just visited the room, and let K be the number of days that pass before her next visit (so she visits again K+1 days from now), let n be the number of prisoners, let c be the number of times she has found the light on so far, and let P(ON) and P(OFF) be the probabilities that she finds the light on or off on her next visit. Then E(K) = 1/n, P(K=k) = 1/n·((n-1)/n)^k, P(K = k|OFF) = 1/n·(c/n)^k, which are fairly obvious.

the very last formula should be P(K = k & OFF) = 1/n·(c/n)^k.

Also, since it it now a separate page on its own, it might be nice to clarify one step of the calculation for those who didn't read it in the context of the thread. Since you have to calculate P(OFF) before you can apply Bayes theorem, I would suggest adding the following sentence at the start of the very next paragraph:

"Summing the last formula over all k gives P(OFF) = 1/(n-c)."

Thanks again for making a page out of this.

--Stuart


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexbadmin
Charter Member
2448 posts
Nov-04-05, 12:18 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
26. "RE: 100 prisoners and a light bulb"
In response to message #25
 
   Many thanks,
Alex


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mr_homm
Member since May-22-05
Nov-05-05, 10:55 AM (EST)
Click to EMail mr_homm Click to send private message to mr_homm Click to view user profileClick to add this user to your buddy list  
27. "RE: 100 prisoners and a light bulb"
In response to message #26
 
   Alex,

There is one more typo to fix. This is one that you noticed in post #6 of this thread and I corrected in post #7 (quoted below). But it was long enough ago now that we both forgot about it.

>>I would assume that, as n grows, the wait period grows as
>>well. Thus E(K)=1/n does not seem right.

>Thanks, that was my mistake. I worked this out on a blackboard, >misread my own handwriting and typed what I saw. It'should be >E(K)=n-1, which I misread as n^(-1) and typed as 1/n, completely >obscuring the connection to the original. The calculations are of >course based on the correct value, n-1.

Sorry for the extra work, and thanks again for making a page out of this posting.

--Stuart


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexbadmin
Charter Member
2448 posts
Nov-08-05, 10:58 AM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
28. "RE: 100 prisoners and a light bulb"
In response to message #27
 
   Stuart:

I am away from my computer. Will fix this on my return.

Thank you,
Alex


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexbadmin
Charter Member
2448 posts
Sep-08-05, 03:39 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
11. "RE: 100 prisoners and a light bulb"
In response to message #1
 
   I wrote to Peter Winkler whose book I mentioned before. As it comes out his problem is somewhat different, and now I quote:


Each of n prisoners will be sent alone into a room, infinitely often, but in some arbitrary order determined by their jailer. The prisoners have a chance to confer in advance, but once the visits begin, their only means of communication will be via a light in the room which they can turn on or off. Help them design a protocol which will ensure that some prisoner will eventually be able to deduce that everyone has visited the room.

Peter's reply was this:


The reason you need two actions is that my puzzle is tougher: the prisoners are not sent to the room once per day, but on an unknown schedule. Thus you can't solve the unknown-initial-state problem by having the first prisoner turn off the light, as he will not know if he is the first.

The two problems are thus related but are not quite the same.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Rod H.
guest
Sep-28-05, 02:46 PM (EST)
 
13. "RE: 100 prisoners and a light bulb"
In response to message #11
 
   I have been following this thread for some time now and am fascinated by the different opinions expressed. This is a great mental exercise, very rich in opportunities for logical reasoning. The mathematics of probable length of stay are beyond my abilities and interest but I will tackle the logic of the problem.

The way I see it there are at least three related but distinct puzzles of varying complexity based on the initial switch position and whether or not a known schedule is followed. The situation where the initial switch position is unknown is included for completeness even though the original post clearly stated that it was 'off'.


A.) First is the situation where the initial position of the switch is unknown, and the prisoners are called at arbitrary intervals (who starts is unknown). This is clearly going to take the most time to free the prisoners. This is where it is necessary to select a 'captain' beforehand who will need to count how many times (s)he turns out the light. Everyone else will need to turn on the light the first two times that they find it off, and leave it alone the rest of the time. In this case the captain can make the claim after finding the light on 2n-2 times.

B.) Second is when the initial switch position is known but the prisoners are called arbitrarily. For the sake of convenience (and consistency with the problem statement) let's say that the switch is initially off. Again, nobody knows if they are first so it is necessary to select a captain beforehand who will maintain a count and turn the switch off whenever (s)he finds it on. Everyone else will turn it on the first time they find it off and leave it alone every other time. This second scenario will require the captain to find the switch on n-1 times before making the claim.

There is very little that can be done to make either of the first two processes more efficient. It is possible for all of the prisoners to keep a count of how many times they find the light off, then find it on, and then making the claim before the captain is called to the room, but the likelihood of this being of any value is remote. This would require a claimant, other than the captain to make at least two visits between each and every pair of visits by the captain. Probably not valuable for any large n (but it may be a way to pass the time in solitary).

C.) The third situation is the most fascinating. The starting time and intervals are known to the prisoners (e.g. every night after supper, starting tomorrow.) This scenario allows the prisoners to pass additional knowledge through the switch. Here is my strategy, which I believe is optimal:

To begin with, the initial position of the switch is irrelevant if everyone knows when the process begins. The first person turns it on or leaves it on. Period.

As in B.) above everyone but the captain will turn the switch on the first time they find it off, and leave it alone on every other visit.

The captain has the dual responsibilities of turning the switch off and maintaining a count of visitors (how many times did I turn it off?). This is the same as in A.) and B.), however, it is not necessary to preassign the captain!

There are additional responsibilities and exceptions for the first few visitors that make use of the knowledge implicit in knowing which day they are called. This additional knowledge can shave huge amounts of time off the sentence (for n=100 roughly 300 days? Again, I'll leave that to the more skilled mathematicians). These time saving, knowledge passing devices are as follows:

Day #1: The first person (knowing that they are first) turns the switch on or leaves it on (this is why the initial position is irrelevant).

Day #2: The second person (knowing that they are second; this is important!) will find the switch on. They know in advance that the switch will be on! EVERYBODY knows that the second person will find the switch on! This provides an opportunity to pass on valuable information! The second person simply leaves the switch on. If, however, the second person was also the day #1 visitor they turn the switch off! This passes information to the day #3 visitor!

Day #3: The third person can find the switch in either the on/off position. (They are receiving valuable information!) The third person can also be a repeat visitor. If (s)he finds the switch on and is not a repeat visitor (s)he leaves the switch on! This lets the Day #4 visitor know that there have been three previous visitors. If the Day #3 person finds the switch off, or is a repeat visitor, they become the 'captain'. (S)he knows how many people have visited the room, (only one other, or none if this is his/her third visit) and it is now up to this newly assigned captain to count the rest of the visitors. This Day #3 visitor makes sure the switch is off and leaves the room with the responsibility of captaincy. This says to the Day #4 visitor, "I am the captain because you have no way of knowing how many visitors have gone before (either one or two)".

Day #4: The person who enters on day #4 will either find the switch off, in which case they follow the normal rules, or they will find the switch on. If the switch is on, they become the captain and know that there had been three different previous visitors (unless they themselves had visited previously, in which case the count is only two).

Day #5 and on: Follow the original rules: on first finding the switch off, turn it on otherwise leave it alone.

It is clear that by dynamically selecting the captain, instead of preselecting, you have guaranteed that by day #3 or #4 you have had your captain visit and the countdown is under way. In fact you are over 94% sure to have a count of 3 by day #4. This is clearly superior to waiting until a preselected captain is called into the room, only to start with a count of 1.


One additional possibility to consider: Is it possible, under the rules to have the visitors unscrew or tighten the light bulb? This could pass even more knowledge, and a higher count to a captain to be determined later than day #4.

Thanks for the great puzzle.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
ramsey2879
guest
Sep-29-05, 07:31 PM (EST)
 
14. "RE: 100 prisoners and a light bulb"
In response to message #13
 
   Rod, you have presented quite a logical solution to shorten the time. But I seem to feel that the whole idea depends to much on everybody following the rules. There is no room for a fadist warden who resets the light himself to throw off the count. No room for a burned out light bulb having to be replaced. No room for a suicidal prisioner. No room for forgetfulness.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Rod H.
guest
Oct-03-05, 12:01 PM (EST)
 
18. "RE: 100 prisoners and a light bulb"
In response to message #14
 
   You are quite right. I totally ignored the sadistic warden, the suicidal prisoner, the forgetful counter, the burned out light bulb, and probably a number of other wicked problems that the poor lost souls could face. Alas, there is no way out. Best to just claim on day 1 and end the suffering.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
iliaden
Member since Aug-14-05
Sep-29-05, 10:02 PM (EST)
Click to EMail iliaden Click to send private message to iliaden Click to view user profileClick to add this user to your buddy list  
15. "RE: 100 prisoners and a light bulb"
In response to message #13
 
   I may be mistaking, but I believe that the first solution you offered is not optimal.

>A.) First is the situation where the initial position of the
>switch is unknown, and the prisoners are called at arbitrary
>intervals (who starts is unknown). This is clearly going to
>take the most time to free the prisoners. This is where it
>is necessary to select a 'captain' beforehand who will need
>to count how many times (s)he turns out the light. Everyone
>else will need to turn on the light the first two times that
>they find it off, and leave it alone the rest of the time.
>In this case the captain can make the claim after finding
>the light on 2n-2 times.


I belive that for n being a large number (let's not discuss what a large number is), we can simply have a captain that counts the number of times he turns the light to the "off" position, as well as a second person, who will turn the light on twice. Everyone else will turn the light on only once, when the find it at the "off" position.
Like this, the captain will only have to count to {n} number of times, which is usually smaller than 2n-2.

However, my solution has a few holes.

The first one I saw is that if the captain comes first and sees the light "on", he will consider that someone has already been in the room. Like that, when he will count to n times. However, it is possible that ONE person has not yet been in the room. I believe (again, I might be mistaking) that we can overlook this problem because we have a hundred prisoners, and chances of such a situation are very slim.

If there is anything else I haven't seen please inform me.

Thank you

P.S. If you want to unscrew the light bulb, you should simply break it into pieces, put all of them in a pile in one end of the room, and when a person comes into the room for the first time, they put a piece of glass from the pile into the center of the room. When there will be 100 glass pieces in the center, everyone would have visited the room. (note: this could not work for large groups)
Yes, I know that this is not the CORRECT or mathematical solution that we are expected to give.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Ramsey2879
guest
Sep-30-05, 05:18 PM (EST)
 
16. "RE: 100 prisoners and a light bulb"
In response to message #15
 
   >P.S. If you want to unscrew the light bulb, you should
>simply break it into pieces, put all of them in a pile in
>one end of the room, and when a person comes into the room
>for the first time, they put a piece of glass from the pile
>into the center of the room. When there will be 100 glass
>pieces in the center, everyone would have visited the room.
>(note: this could not work for large groups)
>Yes, I know that this is not the CORRECT or mathematical
>solution that we are expected to give.
What happens when someone steps of the pile of pieces, do ten pieces become 100? It also doesn't make any sense to believe that either pile would exist for more than a few days without being disturb. Plus, I suggest that anyone thinking that this problem has any merit try to keep an accurate count of how many beers they drank or how many trips they made to the bathroom over the course of several months, without any implement to keep the count. It wouldn't surprise me if some prisoner out of the hundred convince himself that over the course of several months that he is a second time visitor to the room in question when it is actually his first. Wouldn't the problem make more sense if there were only 10 prisoners instead of one hundred. The logic would not be changed much, but the ability of the group to follow the rules without forgetting or giving up would be higher.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
iliaden
Member since Aug-14-05
Sep-30-05, 06:07 PM (EST)
Click to EMail iliaden Click to send private message to iliaden Click to view user profileClick to add this user to your buddy list  
17. "RE: 100 prisoners and a light bulb"
In response to message #16
 
   I hope you can perfectly understand that this question is 100% theoretical, and that such a situation cannot happen in real life.
According to this, we can suppose that every prisoner can follow the pattern without making a single mistake. Otherwise, the problem would have no actual solution.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Rod H.
guest
Oct-04-05, 01:21 PM (EST)
 
19. "RE: 100 prisoners and a light bulb"
In response to message #15
 
   >I may be mistaking, but I believe that the first solution
>you offered is not optimal.
You are probably right. Since the problem stated that the initial switch position is 'off', I didn't give it a whole lot of thought.

>However, my solution has a few holes.
It does indeed. I have tried to avoid these holes by having everyone but the captain turn the light on twice.

>However, it is possible that ONE person has not yet
>been in the room. I believe (again, I might be mistaking)
>that we can overlook this problem because we have a hundred
>prisoners, and chances of such a situation are very slim.
>
Slim chance, yes but still possible. The claimer was to be 100% certain.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
iliaden
Member since Aug-14-05
Oct-16-05, 06:31 PM (EST)
Click to EMail iliaden Click to send private message to iliaden Click to view user profileClick to add this user to your buddy list  
20. "RE: 100 prisoners and a light bulb"
In response to message #19
 
   I got another idea: If the original position of the switch is unknown, we might try the following algorythm:

The captain changes the switch no matter what. Any prisoner will turn the light to the "off" if, and only:

1. they have never done it before
2. they have seen the light in BOTH positions
3. the light is "on" when they enter the room.

Thus, the solution has no chance of failure because when the light is switched for the first time, we can be assured that the captain was already in the room and that the original position of the switch would have no impact.

>Slim chance, yes but still possible. The claimer was to be 100% certain.
This condition is also fulfilled in this solution.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
ramsey2879
guest
Oct-27-05, 06:03 PM (EST)
 
21. "RE: 100 prisoners and a light bulb"
In response to message #20
 
   >I got another idea: If the original position of the switch
>is unknown, we might try the following algorythm:
>
>The captain changes the switch no matter what. Any prisoner
>will turn the light to the "off" if, and only:
>
>1. they have never done it before
>2. they have seen the light in BOTH positions
>3. the light is "on" when they enter the room.
>
It'seems that prisoners have to visit the room too many times for this solution to be optimal. I say that the solution in the earlier post "The problem is indeed popular. It's even included in P. Winkler's Mathematical Puzzles, which is a recommended book in any event. Winkler also lists a slew of sources where the problem appeared, including ibm.com and a newsletter of the MSRI.

The solution is this:

The prisons select a fellow, say Alice, who will have a special responsibility. All other prisoners behave according to the same protocol: each turns the light off twice, i.e. they turn it off the first two times they find it on. They leave it untouched thereafter. Alice turns the light on if it was off and, additionally, counts the number of times she entered the room with the light off. When her count reaches 2n - 3 she may claim with certainty that all n prisoners have been to the room."
is best.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
iliaden
Member since Aug-14-05
Oct-30-05, 08:24 PM (EST)
Click to EMail iliaden Click to send private message to iliaden Click to view user profileClick to add this user to your buddy list  
23. "RE: 100 prisoners and a light bulb"
In response to message #21
 
   >The solution is this:
>
>The prisons select a fellow, say Alice, who will have a
>special responsibility. All other prisoners behave according
>to the same protocol: each turns the light off twice, i.e.
>they turn it off the first two times they find it on. They
>leave it untouched thereafter. Alice turns the light on if
>it was off and, additionally, counts the number of times she
>entered the room with the light off. When her count reaches
>2n - 3 she may claim with certainty that all n prisoners
>have been to the room."
>is best.
>


Do you have the proof that it is the best solution?


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Mendozas
guest
Oct-30-05, 06:35 AM (EST)
 
22. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   Hi,

We arrived at the solution of the leader turning the light 99 times, we also come up with two diferent solutions, they aren't optimal at all but have some laught value:

1) You can detect the special case when everybody enters the room in 100 days without repeating. The person entering the room in day 100n (with n=0, 1, 2, ..., inf) turns the light on, when someone enters the room for the second time in the 100 days period they turn off the light and everybody waits until the next 100n day doing nothing to sync. If in a 100n day the light is already on they can be 100% sure everybody entered the room (in the last 100 days without repeating). We belive the chances of everybody entering the room without repeating in 100 days is 1/(100)^100 so it is far from optimal :P

2) When an infinite time has passed anybody can claim all the 100 prisioners already enter the room (a consequence of the Infinite Monkey Theorem)

--
Mendoza Brothers.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Ghigginson
guest
Feb-04-07, 10:51 AM (EST)
 
29. "RE: 100 prisoners and a light bulb"
In response to message #22
 
   I have a solution.

Not a logical answer but a correct one given the limitations of the problem, since you never mention how long each sentence is for the prisoners, the most simple answer is, only when the last prisoner is left can he make that assertion. It's not logical but it is lateral.

They simply agree not to play the game until there is only one prisoner left.

All one hundred prisoners must of been there, since it's a central room. Even if by chance one prisoner never went there it is true, since it's random this is a possibility. We don't know the duration of their sentences, and even if we did it doesn't matter. Even if they died, they would be carried out through the central room to be buried. In this situation and given the fact that the light bulb is irelevant, it's a possible answer. because the only remaining prisoner is taken out every day.

Or this is my logical answer: every prisoner records if they have never been in the room before by saying: never = down position light off, if you see a down you note it and then proceed by either leaving it down meaning you also have never been in the room before, or by flipping it up(light on) Saying the previous person had not been in the room before but you have: unless you have been in the room before and the light switch was in the up position, then you flip it down as if you have never been in the room before.

When you see 50?(x) consecutive light down(off) Then you make the assertion that everyone has been in the room.

MNot sure of the exact number but I'll leave that for now as it's the principal that is important.

Essentially the answer is as soon as you see x number of down switches you call the warden, x is 50 or 100 depending on how long you've been there using a simple algorythm should reproduce this result.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Ghigginson
guest
Feb-04-07, 10:51 AM (EST)
 
30. "RE: 100 prisoners and a light bulb"
In response to message #22
 
   Not a logical answer but a correct one given the limitations of the problem, since you never mention how long each sentence is for the prisoners, the most simple answer is, only when the last prisoner is left can he make that assertion. It's not logical but it is lateral.

They simply agree not to play the game until there is only one prisoner left.

All one hundred prisoners must of been there, since it's a central room. Even if by chance one prisoner never went there it is true, since it's random this is a possibility. We don't know the duration of their sentences, and even if we did it doesn't matter. Even if they died, they would be carried out through the central room to be buried. In this situation and given the fact that the light bulb is irelevant, it's a possible answer. because the only remaining prisoner is taken out every day.

Or this is my logical answer: every prisoner records if they have never been in the room before by saying: never = down position light off, if you see a down you note it and then proceed by either leaving it down meaning you also have never been in the room before, or by flipping it up(light on) Saying the previous person had not been in the room before but you have: unless you have been in the room before and the light switch was in the up position, then you flip it down as if you have never been in the room before.

Once you have been in the room 50 times and seen 50 consecutive up(light on) and then not necessarily after that but when you see 50 consecutive light down(off) Then you make the assertion that everyone has been in the room.

It came to me in a dream well not really I just figured it out, do I win a prize?

The answer is to watch the patterns of switches, and if you have been in the room with enough frequency x/t times the pattern will be mostly down, mostly up,mostly down, always up, always up or down number of times in the romm/days you can predict with certainty whether the switch will be up or down, once you can do this x number of times making it statistically impossible. you call the warden. If x/t is above y and you have been there x times, then you can claim to have the only possible answer by probability and if your a frequent enough visitor by virtual certainty, everyone has been there.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
The Dog
guest
Feb-05-07, 11:22 PM (EST)
 
31. "RE: 100 prisoners and a light bulb"
In response to message #30
 
   With the one-counter solution, I wrote a simulator and ran it 100,000 times. Of course, this assumes that the prisoner assignment is totally arbitrary and the random numbers are "truly" random (no clustering, but evenly distributed).

Results:

0-999 days: 0 times
1000-1999 days: 0 times
2000-2999 days: 0 times
3000-3999 days: 0 times
4000-4999 days: 0 times
5000-5999 days: 0 times
6000-6999 days: 10 times
7000-7999 days: 459 times
8000-8999 days: 6806 times
9000-9999 days: 27676 times
10000-10999 days: 37769 times
11000-11999 days: 21085 times
12000-12999 days: 5461 times
13000-13999 days: 681 times
14000-14999 days: 52 times
15000-15999 days: 1 time

On average, that means you're looking at about 24 to 33 years before you're POSITIVE that everyone's been in the room. Being overly optomistic, you might actually wait 16 years. And there's about a 0.001% chance that you'll be waiting 42 years or more.

Now, comparaitvely, here's how many days it ACTUALLY took to get all 100 people in the room:

0-99 days: 0 times
100-199 days: 0 times
200-299 days: 409 times
300-399 days: 14543 times
400-499 days: 35987 times
500-599 days: 27511 times
600-699 days: 13046 times
700-799 days: 5353 times
800-899 days: 1998 times
900-999 days: 755 times
1000-1099 days: 266 times
1100-1199 days: 89 times
1200-1299 days: 33 times
1300-1399 days: 5 times
1400-1499 days: 3 times
1500-1599 days: 1 time
1600-1699 days: 1 time

So, if you wait 4 years and then assert that everyone's been in the room, you have around a 99.997% chance of being correct. That means chances are, you're pretty safe NOT using the technique, and just waiting, say, 5 years for a 99.9999% chance of safety, rather than 16-42 years for a 100% chance of safety.

DaveE


The chance has to be 100%, that's the point otherwise it's easy to solve. Now the only method I know that does this in an optimised and 100% situation is to have no counter, but everyone as a counter, the first person to get enough results to call the warden calls the warden, in the unlikely event that the counter is never chosen, here at least you will be 100% corrrect in your assumption not 99.9999996 but 100% as the question asks. This is the point.

You have to bear in mind in the one counter situation if the counter is never chosen, all prisoners will be dead before the counter can make an assumption.

https://www.cut-the-knot.org/Probability/LightBulbs.shtml

This would work of course, but is it optimal? For instance, this would also work, I think:

Alice counts the times she finds the light on, and ensures that it is always off when she leaves the room. Everyone else turns on the light the first time they find it off, and then never touches it again. This way, between visits of Alice, at most one prisoner will turn on the light, and no prisoner turns it on more than once. Therefore the number of times Alice finds the light on is no more than the number of different prisoners that have entered the room. Each prisoner knows he has been counted once he has turned the light on, since he is the only one who touched the switch since Alice last visited. When Alice counts to n-1, she knows everyone has visited the room.

What does optimal mean here? It could only reasonably mean that the prisoners are freed in the shortest time. So what is the expected time they must wait until Alice has counted to n-1? This is a rather elaborate calculation in probability, so the prisoners turn to the actuary (who is in prison for embezzlement) for some answers.

He explains that using Bayes theorem,
P(X|Y)·P(Y) = P(X&Y) = P(Y|X)·P(X)

and the linearity of expected value,
E(X|Y)·P(Y) + E(X|~Y)·P(~Y) = E(X)

you can calculate the expected time in prison like this:

Suppose Alice has just visited the room, and let K be the number of days that pass before her next visit (so she visits again K+1 days from now), let n be the number of prisoners, let c be the number of times she has found the light on so far, and let P(ON) and P(OFF) be the probabilities that she finds the light on or off on her next visit. Then E(K) = n - 1, P(K=k) = 1/n·((n-1)/n)k, P(K = k & OFF) = 1/n·(c/n)k, which are fairly obvious.

Summing the last formula over all k gives P(OFF) = 1/(n-c). Bayes theorem then gives P(K = k|OFF) = (1-c/n)·(c/n)k, and from this you can calculate E(K|OFF) = c/(n-c) and linearity gives

E(K|ON) = ((n-1)(n-c)-c/(n-c))/(n-c-1).

Now let m be the number of times Alice visits and L be the number of days that pass before she next finds it on. Each time she finds it is off, c does not change, so all the calculations regarding the time until her next visit also do not change.

Therefore, the expected number of days until she next finds the light on is found by summing over all possible m to get the expected total time wasted on visits where the light is off, plus the expected time for the one visit where it was on. This gives

E(L) = (1+E(K|ON))P(ON) + sum(m(1+E(K|OFF))P(OFF)m
= n(1/(n-c-1) - 1/(n-c) + 1 - 1/(n-c)2).

Now we know how long we expect to wait from count = c to count = c+1. Therefore, we must sum this up from c=0 to c=n-2 to find the total expected time E(T). The result is E(T) = n2 - n/(n-1) - a, where a = S(1/c2) from 2 to n. Putting n=100 into this gives 9935.5 days, which is 26.2 years.

But (continues the actuary) this is absurdly long to wait. Simple probability shows that we can be almost certain much sooner than this. The probability that on day d the count is c is P(c, d), which is obviously equal to P(c-1,d-1)·(1-(c-1)/n) + P(c, d-1)·(c/n). Of course, P(0, 0) = P(1, 1) = 1 and P(1,0) = 0, so we can recursively calculate the probability P(n, d). It turns out that P(100,1146) = 0.999, and P(100,1375) = 0.9999, P(100,1604) = 0.99999, and P(1833) = 0.999999. That means that in 3.14 years, we have a less than 1/1000 chance of failing, and in exactly 5 years and a week, we have less than one in a million chances of failing. I say we should wait 5 years and then say "let us out, we've all seen the light."

As they are about to kill Alice (who was already a member of Mensa) for coming up with a crazy plan to keep them in prison for 26 years, the game theorist (who is in prison for insider trading on the stock market) steps in to point out that this is a losing move. If they kill her now she will never go into the room, and the warden will keep them here forever.

In the happy ending, they let Alice live, and they all get out of prison in 5 years. Strangely, they all decline to join Mensa, preferring to enter actuarial training.

Q: How can the prisoners tell, with certainty, that all 100 of them have visited the central living room with the light bulb.

The riddle: 100 prisoners are in solitary cells, unable to see, speak or communicate in any way from those solitary cells with each other. There's a central living room with one light bulb; the bulb is initially off. No prisoner can see the light bulb from his own cell. Everyday, the warden picks a prisoner at random, and that prisoner goes to the central living room. While there, the prisoner can toggle the bulb if he or she wishes. Also, the prisoner has the option of asserting the claim that all 100 prisoners have been to the living room. If this assertion is false (that is, some prisoners still haven't been to the living room), all 100 prisoners will be shot for their stupidity. However, if it is indeed true, all prisoners are set free. Thus, the assertion should only be made if the prisoner is 100% certain of its validity.

Before the random picking begins, the prisoners are allowed to get together to discuss a plan. So ---- what plan should they agree on, so that eventually, someone will make a correct assertion?

This is why your idea and all the others are dismissed, not because it isn't likely, but because it does not meet the criteria of the experiment, read the quote again as for why and how this leads to the only conclusion that a single counter or 99 counters is not viable, only all counters will be 100%. Run your tests with that, is it more or less viable? I think you already know the answer, it not only more quickly leads to a result, but it is 100%. This is why he asid he was wrong because quite simply he was wrong, but this leads to the solution.

There answer is different and I can assure you I didn't read it before I came up with mine, so my answer could also be correct, and in fact, if your lucky it's even more optimised. But their answer is to just wait five years, now what if you have both as a precursor, aren't you optimising the situation still further?

Am I right?


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
ryani
guest
Apr-23-07, 03:50 PM (EST)
 
32. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   Selecting one counter gives you about 28 years until escape. The best solution I've found so far takes about 13 years:

First, figure out the expected number of days until everybody has visited the room. This is around 500 in the 100 prisoner case. You aren't going to assert based on this, but you do count it. Call this number the "phase length".

The way the solution works is that every prisoner starts with a "soul", and the goal is for one prisoner to collect all 100 souls, at which point he can assert that everybody has been in the room. The prisoners can transfer one or more souls to another prisoner by turning on the light.

The game starts on day 1 of phase 1. There are 6 phases after which you return to phase 1, about 3000 days later.

The lightbulb always contains 0 souls when it is off. When it is on, it holds 2^(phase - 1) souls. So during phase 1: 1 soul, phase 2: 2 souls, phase 3: 4 souls, up to phase 6 where the lightbulb contains 32 souls when it is on.

Each prisoner follows the following algorithm when they are sent to the room:

First, if the lightbulb is on, you figure out how many souls the lightbulb was worth yesterday and add that to your soul-count. So if it's the first day of phase 3, and the bulb is on, and your soul-count is 5, your soul count is now 7 (since it was worth 2 souls yesterday).

Now, take your soul count in binary and figure out if the current phase's bit is set. So in the last case, the prisoner with 7 souls in phase 3 has 111b souls, and it's phase 3 and the third bit is set. In that case, turn the lightbulb on if it isn't already, and subtract that many souls. Our hero now has 3 souls and the lightbulb contains the other 4.

If that bit is not set, turn the lightbulb off.

If you ever have 64 or more souls, you never leave the lightbulb on; you are now the master collector and your job is to get the rest of the souls and assert that you have them all.

My testing shows that this algorithm completes on average in about 4700 days.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mmc
guest
May-31-07, 08:30 AM (EST)
 
33. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   After 50 days, have the 50th person turn on the light. Then, 50 days later, have the 100th person turn it off again. Repeat this 100 times if the warden does choose repeats, or stop if he does not. If they are allowed to choose their meeting day, have it on the last day of timeline stated above. (even if repeated an infinite # of times, you cannot be 100% certain that everyone has gone in.)


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
maryam
guest
Jul-28-07, 04:08 PM (EST)
 
34. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   hi, solution 1 is incomplete. It'should include that every person turns the light on only once and if he finds it off again he should leave it off.
So when they meet, they pick person X as the leader. every time a person walks into the living room if it is the first time they walk in AND find the bulb off, they turn it on. Each time X walks into the room and finds the bulb on, he turns it off and counts the number of times he has turned the bulb off. once he has turned the light bulb off for the 99th time he is certain that every prisoner has been in the room at least once.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
mpdlc
Member since Mar-12-07
Jul-31-07, 06:07 AM (EST)
Click to EMail mpdlc Click to send private message to mpdlc Click to view user profileClick to add this user to your buddy list  
35. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   Being that question hanging around for almost two year already, I thought that deserves some new consideration. Below I outline a fresh procedure based on primes that, eventually since the process is random, will render with certainty that all prisoners have visited the room. To make more manageable and intelligible the subject we are going to consider as starting point a much smaller numbers for the prisoners let us say five A,B,C,E and D.

First we assign to each prisoner a consecutive prime numbers starting with 3, so prisoners will be renamed as P3; P5; P7; P11 and P13.

Second we will consider two classes of day those multiples of 2 we will call them even days, and those which are not odd days.

Third we instruct all prisoners as follow:

A) If he visits the room in an even day, factorize the number of such day and he will leave the light on if his prime number happens to be the largest of prime numbers contained in the factorization of day number, otherwise he will leave the light off.
For instance if P5 visit the room in day 30 (30 factors 2, 3, and 5) he must leave the light on, but if is P3 or any other who visit the room they must leave the light off in such a manner the visitor on day 31 will know for sure that P5 has been there the day before. P5 will repeat the same action always under those rules for instance if happen that he visits the room on days 40, 50 or 60. But not in day 70 that belong to P7.



B) If he visits the room in an odd day, conventionally subtracts one to that day number which now become an even day. Them he applies the above rule for the even days.
For instance if P7 visit the room in day 43, which result in 42 as above convention (42 factors 2, 3 and 7) he must leave the light on, but if is P3 or any other who visit the room they must leave the light off in such a manner that the visitor on day 44 will know for sure that P7 has been there the day before. P7 will repeat the same action always under those rules for instance if happen that he visits the room on day 71.

Following that strategy eventually if the guard is not lucky enough to select always a prisoner who bears a prime number which it is not a factor of the given day with his randomly selection will be providing information of the prisoner who is visiting the room. The only days which will render no information at all will be those days which number is a power 2. So if every prisoner keeps tracts in a note book of all the visitors he knows about, with certainty there will be one of prisoner who fill up is “bingo” card first.

We can generalize this procedure for any number of prisoners allowing more prime numbers but the number visits necessary to ascertain the premises will increase dramatically.

mpdlc


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
al_q
guest
Aug-02-07, 11:55 PM (EST)
 
36. "100 prisoners and a light bulb: trivial solution"
In response to message #0
 
   Key word: assertion. If you will take this to mean proving the statement as either true OR false, then the solution is trivial. On the first day, whomever is picked may assert that "all 100 prisoners have been to the living room by now" is false. Now how to convince MENSA to induct 100 prisoners is an entirely different problem...


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Arup Roy
guest
Sep-25-07, 00:07 AM (EST)
 
37. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   Hi,
I think this is the solution.
All the prisoners except the designated prisoner switch the light ON only the first time that they enter the room AND find the light switched OFF. After that, whenever they enter the room, they do nothing. The designated person switches the light OFF whenever he/she enters the room and finds it ON. if it is OFF, he/she does nothing. Once, he/she has switched the light OFF 99 times, it is certain that all have entered the room, as each person has switched the light ON exactly once, and only the designated person has switched it off.

Arup Roy

aruproy@bu.edu


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
spags
guest
Mar-28-08, 06:45 PM (EST)
 
38. "RE: 100 prisoners and a light bulb"
In response to message #0
 
   The plan:
1st visit to room turn/leave light on, otherwise turn/leave light off.
Each person records number of times they find the light on.
1st person to count light on 100 times tells warden.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
Kerry
guest
Oct-12-09, 08:07 PM (EST)
 
39. "RE: 100 prisoners and a light bulb"
In response to message #38
 
   MySolution.

Where y=number of years.

My suggested alternate solution

One prisoner thinks 100 days between going to living room (on average) x 99 prisoners at least. 27 years to get out (law of averages.) It feels wrong. Something is really wrong.

Well he thought, what are the chances all the people have gone into the living room after a year, after 2 years etc...

The possibility all 100 people are chosen after a given number of years is:

Mathematica notation:

sum((-1)^k*(100!/((100-k)!*k!) * (100 - k)^(y*365))/100^(y*365),{k,0,100})

Where (y*365) is the number of days, y is the years (it's in there twice)

Latex notation

100^{-365y}\sum_{k=0}^{100}{(-1)^k}{100 \choose k}(100-k)^{365y}


So he will make the claim sometime after 4-5 years. Some designated counter can count whatever lights he wants, but he will free all 100 thanks to the laws of probability. He saved them each over 20 years in jail. That’s over 2,000 man years.

Phew….
My chart


Even more precise, but not significant in the outcome is:

Where t is the number of times he has already been in the living room

Conditions

If t=0 then there is no chance what so ever.
If 365y-t<99 no chance what so ever.

Latex

99^{-365y-t}{\sum_{k=0}^{99}{(-1)^k}{99 \choose k}(99-k)^{365y-t}}

Mathematica

sum((-1)^k*(99!/((99-k)!*k!) * (99 - k)^(y*365-t))/99^(y*365-t),{k,0,99})

Years
1 6.9011% or 14 in 15 of Mass Excecution
2 93.7616% or 1 in 600
3 99.8373% or 1 in 15.8
4 99.9958% or 1 in 23,500
5 99.9998% or 1 in 924,000
6 99.99999724% or 1 in 36.2 million
7 99.99999993% or 1 in 2.4 billion
8 99.999999999% or 1 in 55.6 billion
9 99.999999999... or 1 in 2.18 trillion
10 99.999999999... or 1 in 85.4 trillion (the people on 13,000 planets with equal populations to earth)

Any way I tested the math with a probability chart and 2, 3 and 4 prisoners and up to 10 days. It computes.

For my calculations I eventually settled on this Assuming he is chosen about 3.65 times in each year.

Sum<(-1)^k*Binomial(99,k) * (99 - k)^(Round(361.60*2))/(99^(Round(361.60*2))),{k,0,100}>
<MATH>
\sum_{k=0}^{99}{(-1)^k}{99 \choose k}(99-k)^{361.6y}99^{-361.6y}
</MATH>
https://www.codecogs.com/eqnedit.php?latex=\sum_{k=0}^{99}{(-1)^k}{99 \choose k}(99-k)^{361.6y}99^{-361.6y}


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top
alexbadmin
Charter Member
2448 posts
Oct-14-09, 07:16 AM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
40. "RE: 100 prisoners and a light bulb"
In response to message #39
 
   Just great.

And thank you for intriducing us to https://www.codecogs.com. I was unaware of the existence of this site.


  Alert | IP Printer-friendly page | Reply | Reply With Quote | Top

Conferences | Forums | Topics | Previous Topic | Next Topic

You may be curious to have a look at the old CTK Exchange archive.
Please do not post there.

Copyright © 1996-2018 Alexander Bogomolny

Search:
Keywords:

Google
Web CTK