Live data from Hacker News

Prison Switcharoo

cartalk.com

31–40 of 81 posts

Re: Prison Switcharoo

#32
post #23
post #10

Earlier quoted context omitted.

It should be 43 instead of 44, right?

The answer explains this. The number should be ( p - 1) x 2 where p is the number of prisoners. (23-1) = 22 * 2 = 44

But 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?

Re: Prison Switcharoo

#35
post #31

[deleted]

>'Now I want each of you to flick Switch A to the "On" position twice, and only twice.'

At #5 in your example, P1 would need to flick switch B.

Re: Prison Switcharoo

#36

Since there's a password article on the front page too... This problem is very clever, and there is a very clever way to solve this, assuming everyone plays nice. However, that solution assumes perfect collusion. These are prisoners we're talking about, so at least in some cases, we have to assume there may be bad actors involved. I mean this is a cute problem assuming the following: 1. All the prisoners have perfect…

You are really overthinking this. The Car Talk puzzlers are straight forward and should be taken at face value.

Re: Prison Switcharoo

#37
post #35
post #31

[deleted]

>'Now I want each of you to flick Switch A to the "On" position twice, and only twice.' At #5 in your example, P1 would need to flick switch B.

It's a null op, that's why I left it out.

Re: Prison Switcharoo

#38
post #31

[deleted]

Prisoners only flip the switch twice. You have p1 flipping it 4 times.

Ah, f*ck, thank you. I should sleep more. I still don't get how it works if Prisoner 2 is never at the switch at all before the Counter gets to his magic number, but I'm going to defer this to superior puzzle-solving minds :)

Re: Prison Switcharoo

#39
post #23

Earlier quoted context omitted.

The answer explains this. The number should be ( p - 1) x 2 where p is the number of prisoners. (23-1) = 22 * 2 = 44

But 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?

The 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.

Re: Prison Switcharoo

#40

Since there's a password article on the front page too... This problem is very clever, and there is a very clever way to solve this, assuming everyone plays nice. However, that solution assumes perfect collusion. These are prisoners we're talking about, so at least in some cases, we have to assume there may be bad actors involved. I mean this is a cute problem assuming the following: 1. All the prisoners have perfect…

You are really overthinking this. The Car Talk puzzlers are straight forward and should be taken at face value.

Since this problem comes around a lot as a programmer interview question, it seems like a good idea to discuss actual systems stuff associated with it. I mean, if I'm hiring a programmer I want them to be good at useful software, not at perfect condition algorithms.
Post reply on HN