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 / 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 |
Post New Answer View All Answers
Write a program to reverse a number?
In an customer exit (include Z) program, only the last record is getting fetched. The exit is getting called after pressing save button. What to write for fetching the first record ? Before saved to a SAP table how can i call all these records in an itab in the exit ?
why we use mantis? what u mean mantis in IT trends? addvantages of mantis?
How to connect the .accdb database file of microsoft access to the Visual Basic 6.0 forms?
i want to improve my english vocab for racking campus written exam plz tell me best book for prepration......
Write a shell program. Enter number of days from keyboard. Find out the number of years, month and days it contains
details description on this mantis? who is founder of this mantis?
how to convert infix expression to prefix expression?
Have you used callsymputx? what points need to be kept in mind when using it?
what is the similarity between networking devices?
Need provab technical test questions
What is the entry point function of a DLL?
could u please also write an example of a code that involves instances from an abstract class just as u did for interfaces because u said it could also work which i really doubt. thanks
sample code for data transfer between two r/2 systems and r/3 systems?
Write a program to swap the content of two variables without using a third variable.