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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between HTML and DHTML?

1660


Is there any standard procedure to test the application as a whole? Or How can I test complete application right from the requirement gathering?

1467


As per interoperatbility programs written in one language can be used by other language. How can we restrict the features of one language (say C#) in the programmer written in another language (say VB)..for example we have some features like operator overloading which is possible C#.NET (not in VB.NET), how can we restrict that when we are using this code in VB.NET.

1447


how much fee for deccan soft institute .how to block seat for sandeep sir class reply soonnnn 

1652


THE CHANNEL IN DATA COMMUNICATION CAN BE?

1566






How will you prove that java swing is multithreaded?

1694


what are all the ant command options

1504


Always use scope terminator like End-If with IF, End- Evaluate with Evaluate statement.Can somebody explain me the detail logical explanation?

1538


Difference between delegates and Events?

1708


1. How many jobs can we write in a single file? 2. How many maximum members can exist in a single partition data set(pds) in jcl?

1916


how to stop execution of step 3 in a job mainframe

1709


what is woransient key word? how it is used in java

1798


what are the things i had to say in personal introduction in hr round mail me to prasanna.1867@rediff.com

1674


How to call dll API sub routine in VB Form.

1905


Plz sent me in .net 2.0 interview Question & answers?

1639