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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In OB52 , How to define two open posting period, Like only 5 and 8 posting should be open.. should not open 6 and 7..period..

989


What is the difference beween joblib and steplib statements

1783


Definition of Singleton Class? what is the Purpose of it? what is the advantage?

1588


What is abstract Method i want the exact definition and is there any possibility to declare class as abstract without any abstract methods in that class?If it is possible then tell me why and how?

1472


Please describe an example where you used object orientation in one of your programs.

1489






What is dialog programming?

1580


what is difference between object oriented programming structure and object oriented programming system?

1440


what is throws keyword

2990


what do u mean by tagging

1616


What is easiest way to get the PL/i compiler,I didn't have found the compiler in my library. Is there any extra cost if we want to access the PL/1 programs?Actually we r having Mainframe rented training Ids

1615


Given an array of size n, containing every element from 1 to n+1, except one. Find the missing element.

643


what is the last ant version you worked?how to get it

1461


Explain polymorphism. Provide an example.

617


Find out the list of authorization objects which contains activity as a field? Thanks in advance.

1761


How many forms can you create in a Visual Basic 6 Standard EXE project? Is there any limit on that?

1538