# Puzzle: How do you get out of the prison (Part II)

The previous puzzle was solved correctly in the comments. So I thought to present with another prison-style puzzle:

A warden meets with 23 new prisoners when they arrive. He tells them, "You may meet today and plan a strategy. But after today, you will be in isolated cells and will have no communication with one another.

"In the prison is a switch room, which contains two light switches labeled A and B, each of which can be in either the 'On' or the 'Off' position. I am not telling you their present positions. The switches are not connected to anything.

"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. This prisoner will select one of the two switches and reverse its position. He must move one, but only one of the switches. He can't move both but he can't move none, either. Then he'll be led back to his cell.

"No one else will enter the switch room until I lead the next prisoner there, and he'll be instructed to do the same thing. I'm going to choose prisoners at random. I may choose the same guy three times in a row, or I may jump around and come back.

"But, given enough time, everyone will eventually visit the switch room as many times as everyone else. At any time anyone of you may declare to me, 'We have all visited the switch room.'

"If it is true, then you will all be set free. If it is false, and somebody has not yet visited the switch room, you will be fed to the alligators."

Tags

1. My Blobby says:

ROT13 encrypted. I’m not sure if this is the most efficient solution, but it works.

Cvpx n yrnqre, cevfbare 1. Bayl gurl pna zbir fjvgpu N sebz ba gb bss.

Nffhzr lbh ner cevfbare k, abg rdhny gb 1.

Vs jura lbh tb gb gur ebbz fjvgpu N vf bss NAQ lbh unira’g orra gurer orsber, fjvgpu vg ba.

Vs lbh unir nyernql orra gurer orsber, be fjvgpu N vf nyernql ba, gura syvc fjvgpu O.

Abj jura cevfbare 1 pbzrf, vs fjvgpu N vf ba gura gurl xabj gung n cerivbhfyl hapbhagrq cevfbare unf pbzr vagb gur ebbz fvapr ynfg gvzr. Fb gurl pna pbhag hagvy nyy 22 bgure cevfbaref unir orra nppbhagrq sbe. Cevfbare 1 fubhyq nyjnlf yrnir gur ebbz jvgu fjvgpu N va gur bss cbfvgvba.

2. IngisKahn says:

Not sure that will work…

If Switch A is off initially then Prisoner 1 will have to count to 22, if it’s on initially then he’ll have to count to 23…

3. IngisKahn says:

OK, Blobby based on your idea here’s the solution:

Gur yrnqre qbrf gur pbhagvat nf orsber ohg abj uvf gnetrg pbhag vf sbhegl-sbhe. Abj gur bgure cevfbaref jvyy syvc fjvgpu N bayl vs vg vf bss naq gurl unir abg lrg syvccrq fjvgpu N gjvpr. Bapr gur yrnqre ernpurf sbhegl-sbhe ur pna or fher gung rirelbar unf ivfvgrq gur fjvgpu ebbz ng yrnfg bapr rira vs fjvgpu N jnf ba vavgvnyyl.

4. IngisKahn says:

OK, Blobby based on your idea here’s the solution:

Gur yrnqre qbrf gur pbhagvat nf orsber ohg abj uvf gnetrg pbhag vf sbhegl-sbhe. Abj gur bgure cevfbaref jvyy syvc fjvgpu N bayl vs vg vf bss naq gurl unir abg lrg syvccrq fjvgpu N gjvpr. Bapr gur yrnqre ernpurf sbhegl-sbhe ur pna or fher gung rirelbar unf ivfvgrq gur fjvgpu ebbz ng yrnfg bapr rira vs fjvgpu N jnf ba vavgvnyyl.

5. IngisKahn says:

Sorry for the repeat post.

6. Luke says:

Entropy questions are fun! OK, the prisoners agree to organize into 22 signalers and one captain. When a signaler goes to the room, the first two times that he finds the left switch off, he turns it on, thereby signalling; otherwise, he flips the right switch. Each time the captain goes to the room, if he observes the left switch on, he adds one to his tally and turns it off, accepting the signal; otherwise, he flips the right switch. Once the captain has collected 44 signals, he knows that everyone else has signaled exactly twice, with the possible exception of one who has only signaled once if the left switch was initially on, therefore everyone has been to the room, so he calls the warden and everyone goes free.

7. Mr Blobby says:

Yes, I forgot that the initial state isn’t known <blush>.

Also, where I said ‘haven’t been to the room before’ I (obviously?) meant ‘haven’t flipped switch A before’…