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
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 |
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 |
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 |
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 |
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 |
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 |
what is the diffrence between occur 0 and occur 10 in ABAP.
How to print a name "ARCHANA" in any programming language
whats the use of following Good Coding Practices?
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??????
what is meant by trigger?
Data Structure: How many comparisons are necessary to find the largest and smallest of a set of n distinct elements?
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?
What is meant by spooling
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 ?
What do you mean by text editor?
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 ?