5 ms·
The answer: http://www.cartalk.com/content/prison-switcharoo-0?answer http://www.cartalk.com/content/prison-switcharoo-0?answer
by lisper 13y ago
The answer: http://www.cartalk.com/content/prison-switcharoo-0?answer http://www.cartalk.com/content/prison-switcharoo-0?answer
- no_wave 13y agoIt should be 43 instead of 44, right?
- colanderman 13y agoNo, then he could have only counted 21 prisoners (43 = 1 initial + 21 * 2). The system will "stabilize" at either 44 or 45 "offs", depending on the initial state.
- deleted 13y ago[deleted]
- delinka 13y agoThe answer explains this. The number should be (p - 1) x 2 where p is the number of prisoners. (23-1) = 22 * 2 = 44
- TobbenTM 13y agoBut would it not be sufficient to count p? If switch A starts out in the ON position it would equal one 'fake' prisoner. If the counter just counts one extra (which equals p - 1 (himself) + 1 (fake prisoner) = p) it should be enough, no?
- Serplat 13y agoThe issue is that the counter doesn't know the state of the first switch at the start. If it's on at the start, then sure your solution will work. But if it's off at the start and they all agree to only flip on the switch once, then the counter will sit around forever waiting for p flips, when only p - 1 will ever happen. They need a solution that will work no matter what state the switch is in at the start.
- michael_h 13y agoI'm a bit sleepy, but I can't get this to work. For 3 prisoners, what if the sequence is (P1 T P1 T P1 T P1 T P2 P2 P2 P2)? Where T is the tally keeper. They've all gone the same number of times (given enough time), but the tally keeper would declare that they had all flipped a switch before P2 had gone in at all. Thus, alligators. Did I miss something?
- ironmagma 13y agoDoesn't this solution make the assumption that the guard will continue to pick prisoners to enter the switchroom indefinitely? If he picked P1, P2, P1, P2, Counter, Counter, <end> would the solution still work?
- vanschelven 13y agoThis assumption is part of the original puzzle: "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."
- mischanix 13y agoAnd here's the answer in Go: http://play.golang.org/p/m_biT7Dfmo http://play.golang.org/p/m_biT7Dfmo
- joenathan 13y agoI don't see this working, if the prisoner who flipped the switch on is brought back into the room immediately after the counter turns it off, then that one prisoner will be assumed to be two different people.
- christiangenco 13y ago> '"Now I want each of you to flick Switch A to the "On" position twice, and only twice. So if you go in there and Switch A is already on, that doesn't count. I want each of you to actually flick it "On" two times. You got that?"'
- deleted 13y ago[deleted]
- codyps 13y agoI'm not seeing why they need to turn the switch ON twice. Couldn't they flip the switch only once and have the counter wait for <number of prisoners> ONs (N - 1 + 1)?
- lisper 13y agoBecause the switches start in an unknown state. So the first time the counter enters the room and sees switch A on he has no way to know if that's because another prisoner turned it on, or because he's the first one in the room and it started in the on position.