This is a puzzle question ....

The 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.' and be 100% sure.

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

What is the strategy they come up with so that they can be free?

Answers were Sorted based on User's Feedback



This is a puzzle question .... The warden meets with 23 new prisoners when they arrive. He tells..

Answer / mahesh shiwani

The team nominates a leader. The group agrees upon the
following rules:

The leader is the only person who will announce that
everyone has visited the switch room. All the prisoners
except for the leader will flip the first switch up when
possible, but only for their first two visits to the room.
If the first switch is already up, or they have already
flipped the first switch twice, they will then on flip the
second switch. Only the leader may flip the first switch
down, and if the first switch is already down, then the
leader will flip the second switch. The leader remembers how
many times he has flipped the first switch down. Once the
leader has flipped the first switch down 44 times, he
announces that all have visited the room. It does not matter
how many times a prisoner has visited the room, in which
order the prisoners were sent or even if the switch was
flipped up by the warden. In the example of three prisoners,
the leader must flip the first switch down four times to be
sure all prisoners have visited the room.

Is This Answer Correct ?    29 Yes 14 No

This is a puzzle question .... The warden meets with 23 new prisoners when they arrive. He tells..

Answer / adrian may

They all have to signal twice, because the first signal the
caller sees might just have been that the warden left the
switch on to begin with. In that case he'll see 45
altogether if he waits long enough. But maybe the switch
was off to begin with and he only gets 44. If one prisoner
had never been in, the most the caller could see is 43. If
each prisoner only signals once, you can't tell if somebody
is still waiting when you see 22.

Is This Answer Correct ?    5 Yes 1 No

This is a puzzle question .... The warden meets with 23 new prisoners when they arrive. He tells..

Answer / z

the problem is that the leader will never know whether the
switch was up or down at the beggining. So he has to wait
until he will switch it down 23 times(or 45, because if its
only 44 he wont know if the last prisoner has visited the
switch room, its the same thimg).But in case the switch was
down at the beginning he will have to wait forever for the
23th or 45th time and that will never happen. So there's no
way with this solution that he can be absolute sure(except
ofcourse if one day he switches it down for the 23th or 45th
time respectively)

Is This Answer Correct ?    1 Yes 1 No

This is a puzzle question .... The warden meets with 23 new prisoners when they arrive. He tells..

Answer / pawan

THere are two cases : 1) switch 1 is on and 2)switch 1 is
off. And all except leader will on the first switch if it of
only during their first visit. The position of second switch
i not necessary. 1st case : If the leader goes first he will
make the switch off. so the remaining if goes will turn it
on...so 22 will be wrong because leader started with it so
he cannot be sure after turning off 22 times that all have
visited because therse possibility that one of them have not
visited. If leader does not go first then 22 is enough ...to
be same he tells after 23 switches......case 2: it doesnt
matter if leader is sent first or later...after 23 he can
safely say all have visited

Is This Answer Correct ?    0 Yes 0 No

This is a puzzle question .... The warden meets with 23 new prisoners when they arrive. He tells..

Answer / dave peck

The team nominates a leader. The group agrees upon the
following rules:

The leader is the only person who will announce that
everyone has visited the switch room. All the prisoners
except for the leader will flip the first switch up when
possible, but only for their first visit to the room.
If the first switch is already up, or they have already
flipped the first switch twice, they will then on flip the
second switch. Only the leader may flip the first switch
down, and if the first switch is already down, then the
leader will flip the second switch. The leader remembers how
many times he has flipped the first switch down. Once the
leader has flipped the first switch down 23 times (once for
each of the other 22 prisoners, and once just in case it
started in the up position), he announces that all have
visited the room. It does not matter how many times a
prisoner has visited the room, in which order the prisoners
were sent or even if the switch was
flipped up by the warden.

Is This Answer Correct ?    1 Yes 3 No

This is a puzzle question .... The warden meets with 23 new prisoners when they arrive. He tells..

Answer / samy

The above answer is correct. But not optiomized. Onr small
correction. Everyone need to Flip the first switch only
once. And leader Need to Flip the first switch 22 times.

Is This Answer Correct ?    9 Yes 32 No

Post New Answer

More Programming Languages AllOther Interview Questions

what is the diffrence between occur 0 and occur 10 in ABAP.

0 Answers  


How to print a name "ARCHANA" in any programming language

6 Answers   Value Labs,


whats the use of following Good Coding Practices?

2 Answers  


Hi all... I had completed MSC(Computer) and had join the construction company based on sap.they want me to work on abap.but software company is totally different from construction company and they want me 2 grasp it as fast i can.i am finding it difficult.what should i do??????

0 Answers  


what is meant by trigger?

8 Answers   IBM,






Data Structure:  How many comparisons are necessary to find the largest and smallest of a set of n distinct elements?  

0 Answers   Student,


This is a puzzle question .... The 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.' and be 100% sure. "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." What is the strategy they come up with so that they can be free?

6 Answers  


What is meant by spooling

2 Answers   Qiscet,


design a counter with the following repeated binary sequence: 0, 1, 2, 3, 4, 5, 6, 7, 8 using JK Flip Flop.

3 Answers   College School Exams Tests, IBD, IBM, Ignou, IIIT, Nortech, TCS, UOS,


difference between list and display command ?

3 Answers  


What do you mean by text editor?

1 Answers   Infosys,


1. Write a program to create a sentence at runtime and count number of vowels in it ? 2. Write a program to get a string and to convert the 1st letter of it to uppercase ?

0 Answers   HTC,


Categories