here is a problem I have to try to figure out for my computer class. I'm thinking that the binary code is involved in solving this problem somehow but I'm not really sure. I can't seem to figure it out, all my ideas lead to dead ends.
Nineteen students are given the opportunity to win a prize by playing a game. After some time to decide on a strategy, all the students will be placed into separate soundproof isolation chambers with absolutely no way to communicate.
The game is played as follows. There are two light switches in a room that will begin in the "off" position. I will bring students into this room one at a time. Each time a student enters the room then he or she must flip one of the switches. All the students will eventually be brought into the room, but some students may be brought in more than one time.
If one person correctly tells me that everyone has been in the room, then everyone wins the prize. However, if someone incorrectly tells me that everyone has been in the room then everyone will be fed to the alligators! Note that either all the students win the prize or else everyone loses.
Your task is to determine a strategy that will be sure to allow everyone to win the prize (and not be eaten by alligators).
Copyright © 2024 EBIN.TIPS - All rights reserved.
Answers & Comments
Verified answer
Have you heard of "prisoners and light switch"?
http://theweeklyriddle.blogspot.com/2009/11/prison...
That's the solution to your problem.
Consider prisoners as students in your case. And consider the single switch. No one will flip the second switch.
The prisoners will select one among them to be the designated Counter. When a prisoner enters the Rec Room, he will check to see if the light switch is in the 'off' position. If he has never flipped the switch before, he will turn the switch on. He will only do this once. If he has flipped the switch before, he won't do anything. The only person that will not flip the switch up to 'on' is the Counter. When he comes to the Rec Room, if he sees that the switch is on, he will turn it off and add one to his mental prisoner count. As long as each prisoner only flips the switch up once, the Counter will flip the switch down once for every prisoner in the prison. Once he has flipped the switch down 19 times (once for every prisoner other than himself), he can confidently say that everyone has been to the Rec Room at least once.