logo Sign In

Post #90718

Author
DanielB
Parent topic
The DanielB Prisoners and Lightbulbs Thread
Link to post in topic
https://originaltrilogy.com/post/id/90718/action/topic#90718
Date created
29-Jan-2005, 5:44 PM
Hmm,

Phase 1:

For days 1 to n-1 of an n day cycle, and where m = number of the 1st day of the n day cycle:
1. If the light is off and you have one token then remove it and leave the light off.
2. If the light is off and you have zero tokens then turn the light on and add to your count DayNumber - m. Turn the light on. If this was the first cycle then you are now the counter.
3. If the light is off and you are the counter then turn it on. Add Daynumber - m to your count.