logo Sign In

Riddles — Page 10

Author
Time
ok well how about they decide that the first time a prisonor goes they turn the light bulb on and then off and each time after that they dont touch the light. so then the prisoners jsut count the numebr of times the light bulb is on and once they reach 100 they will know that everyone has beeen in the room once.
Author
Time
I know it's a particularly nasty riddle. I'll give you the same thing I got that gave me a head-start (I've worked off this idea).... the prisoners agree that:

#1 they are all assigned one token, and a counter will collect all these tokens as to be able to assert that they have all entered the central living area.

#2 During the first 100 days:

If it is their first time in the living room and the light is off to leave it off. They then remove their token.
If it is their second time in the living room and the light is off to turn it on and assign themselves the role of the counter. The count (number of tokens) is equal to the day number minus one (since he's been in the room twice).
If the light is on, do nothing regardless until day 100, in which case switch it off.

This gives a bit of a head-start, on average the initial count is 12. Meaning there are now on average 11 people with no token, 88 people with one token each and the counter with 12 tokens.

I will also give you my main concept, which I came up with myself and is a huge advantage if you couldn't think of it yourself.

The concept is if we were to assert that a prisoner releases his token, wherever possible for the counter to collect by turning the light on, then we expect the counter and everyone else to enter the room once every time a token is released. Meaning there is conceptually 100 room entries per token release. Reducing this ratio should be our main concern.

I believe I've worked out the perfect strategy, but I have to do some pretty heavy number-crunching until I can make it optimal.

Afterwards I believe I could then produce an optimal strategy with the rather nasty alteration:

The procedure ends not when a prisoner asserts that all prisoners have entered the room, rather the prisoner must assert that all other prisoners now know and have asserted that all prisoners have entered the central living room.

Ooooh that's nasty, I shouldn't have thought of it. But it can be done.
Author
Time
?????????????????????????????????????????????????????????????????????
Author
Time
Quote

Originally posted by: DanielB
I know it's a particularly nasty riddle. I'll give you the same thing I got that gave me a head-start (I've worked off this idea).... the prisoners agree that:

#1 they are all assigned one token, and a counter will collect all these tokens as to be able to assert that they have all entered the central living area.

#2 During the first 100 days:

If it is their first time in the living room and the light is off to leave it off. They then remove their token.
If it is their second time in the living room and the light is off to turn it on and assign themselves the role of the counter. The count (number of tokens) is equal to the day number minus one (since he's been in the room twice).
If the light is on, do nothing regardless until day 100, in which case switch it off.

This gives a bit of a head-start, on average the initial count is 12. Meaning there are now on average 11 people with no token, 88 people with one token each and the counter with 12 tokens.

I will also give you my main concept, which I came up with myself and is a huge advantage if you couldn't think of it yourself.

The concept is if we were to assert that a prisoner releases his token, wherever possible for the counter to collect by turning the light on, then we expect the counter and everyone else to enter the room once every time a token is released. Meaning there is conceptually 100 room entries per token release. Reducing this ratio should be our main concern.

I believe I've worked out the perfect strategy, but I have to do some pretty heavy number-crunching until I can make it optimal.

Afterwards I believe I could then produce an optimal strategy with the rather nasty alteration:

The procedure ends not when a prisoner asserts that all prisoners have entered the room, rather the prisoner must assert that all other prisoners now know and have asserted that all prisoners have entered the central living room.

Ooooh that's nasty, I shouldn't have thought of it. But it can be done.


why doesnt my way work.
Author
Time
I'm with Warbler on this one. I hardly even understand the riddle let alone be able to solve it.
"You fell victim to one of the classic blunders, the most famous of which is 'Never get involved in a land war in Asia'."
--Vizzini (Wallace Shawn), The Princess Bride
-------------------------
Kevin A
Webmaster/Primary Cynic
kapgar.typepad.com
kapgar.com
Author
Time
I understood the riddle, and I must say that, if the prisioners cannot comunicate with each other after the whole thing starts, it is IMPOSSIBLE to solve this one. A lamp is like a bit, can hold only two informations at a time, 1 or 0. Since each prisioner can go to the room more than once, they cannot simply turn on the light if it's their second time on the room (by counting the nunber of days like DanielB stated, you would get the number of different prisioners who went to the room before him), if the following prisioner left the light on, the next one wouldn't know how many distinct prisoners have gone before, if he turns the light off, the next prisioner will think that only distinct prisoners have gone through.

So I can surely decrete: mathematically impossible, UNLESS the prisoners can comunicate with each other, or if the prisoners cannot go into the room more than once.
“Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country.” — Nazi Reich Marshal Hermann Goering
Author
Time
No, it's not impossible ricarleite. You just aren't thinking of all the possibilities. The lamp on its own can only hold one bit of information, however the lamp when used in conjunction with the day number can hold all sorts of information.

For instance, say days 1-99 are treated thus (all prisoners initially hold one conceptual token):

If the light is off:

1. And it is your first time in the room, remove your token and leave the light off.
2. And it is your second time in the room, designate yourself the counter, and count Days-1 as your initial count. Turn the light on.

If the light is on do nothing.

On day 100:

If the light is off:

1. And it is your first time in the room, then everyone has been in the room. Demand freedom.
2. And it is your second time in the room, designate yourself the counter, and count Days-1 (=99) as your initial count. Leave the light off in this instance since it is day 100.

If the light is on:

Turn it off.

That method gives you a head-start. On average the initial count is 12, however it is not an optimal head-start. For instance there is no reason to dedicate the first 100 days to it, in fact the first 20 days would be more than enough. It is so improbably that your initial count will be more than 20 you may as well save the other 60 days for better use.

Like I said, that concept I didn't think of initially myself. However my concept is that the more people you have on zero tokens the faster you will be able to transfer all the tokens to the counter. If you were to designate the first 20 days to this step you would instead have:

For instance, say days 1-19 are treated thus (all prisoners initially hold one conceptual token):

If the light is off:

1. And it is your first time in the room, remove your token and leave the light off.
2. And it is your second time in the room, designate yourself the counter, and count Days-1 as your initial count. Turn the light on.

If the light is on do nothing.

On day 20:

If the light is off:

1. And it is your first time in the room, then designate yourself the counter and start the count at 20. Leave the light off.
2. And it is your second time in the room, designate yourself the counter, and start the count at 19. Leave the light off.

That works much better, you can also improve your chances by having a special case for days 2 and 3 - that is, there is a 1% chance that the same person will be chosen twice in a row, if this happens you could insert the rules for days 2 and 3:

Day 2:

If it is your second time in the room, switch the light on but do not designate yourself the role of counter.

Day 3:

If the light is on, and it is your third time in the room (0.1% chance) then designate yourself the role of counter and start the count at 1.
If the light is on, and it is your second time in the room then designate yourself the role of counter and start the count at 2.

You get away with this because according to the rules for this period if on the third day the light is on, you know with certainty only one person had been in the room before you. On the forum which discussed this riddle over 3 years, no one ever mentioned that (at least I don't think so, I didn't go through all of it). What no one figured out, on the forum that discussed this riddle (in over 3 years), is that you can give yourself a further head-start by repeating this step! I couldn't believe it either. I know the average for repeating it goes down and down, but you only need to designate a certain number of days to it.

I would designate 20 more days for repeating it (possibly 1 or 2 days less). Thus:

The rules for days 21-39:

If the light is off:

And you are not the counter, and you have one token then remove your token and leave the light off.
And you are not the counter, and you have no tokens, then turn the light on and your new token count = days - 21.
And you are the counter then switch the light on and amend your count days - 21. Turn the light on.

I do not yet know the optimal number of times to repeat this, but I imagine it might be 3 or 4 times. The whole idea is to get as many people onto zero tokens as quickly as possible. Yes, you will have people with counts of any possible number, but they can be transferred to the counter in larger clumps at later times.

People on zero tokens are passive, that means when they enter the room they don't have to get rid of any tokens by switching the light on, and they don't have to collect any tokens by turning the light off. This is a huge advantage. by the end of 80 or 100 days, I imagine you could have average it to ~20 people on zero tokens (that is just an estimate at this stage). Compare that to running it once with 100 days allocated to it - which has an average of just 11 people on zero tokens. You've got a huge head-start.

Anyhow, that's not as far as I've got, but that's as far as hints from me come. I'm sure you can easily take this in the right direction to find the optimal plan now (something that apparantly no one from the original site could find).
Author
Time
I think I understand it a little the "tokens" are imaginary right?

I still don't see how you transfer the counts to the counter.
Author
Time
Quote

Originally posted by: Warbler
I think I understand it a little the "tokens" are imaginary right?
Well yes, for the most part. They could be recorded on paper or something in each prisoner's cell, if he has memory problems - I'll talk about the transfers later.
Author
Time
Transfers?? Well, like I said, and I'm PRETTY sure of myself: if the prisoners absolutely cannot comunicate with each other, with no "token transfer" or anything like that, then it's IMPOSSIBLE to solve this one.
“Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country.” — Nazi Reich Marshal Hermann Goering
Author
Time
Quote

Originally posted by: ricarleite
Transfers?? Well, like I said, and I'm PRETTY sure of myself: if the prisoners absolutely cannot comunicate with each other, with no "token transfer" or anything like that, then it's IMPOSSIBLE to solve this one.
They're using the light bulb to comunicate and transfer the tokens.
Author
Time
Imagine there are only 5 prisoners, not 100, under the same rules. Before the 5th day, a prisoner CANNOT ask for freedom, as it is impossible that every other prisoner was called. So, after the 5th day, if a prisoner is called to the room and hasn't been called before, he can asume that either everyone was in the room before, or that there is someone still waiting to go. If the lamp is off, that means he was the last one and should ask for freedom.

But WHY did the other prisoner set the light off? Basically, what you said is: the last prisoner set the light off if he has been into the room before, but this can lead to an error. Let's asume only ONE prisoner is called for 5 straight days, and he sets the light off when he is called again the last day. So another prisoner gets called, it is the 6th day and the light is off, so he claims to be the last one, and is wrong.

I say it's mathematically impossible, DanielB says it can be done. Anyone else here might want to give an opinion, so we can decide once and for all if this one has a solution?
“Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country.” — Nazi Reich Marshal Hermann Goering
Author
Time
You're confusing yourself. Imagine there are only 5 prisoners. If they agree:

that the first time they enter the room while the light is off to remove their token and leave the light off,
the second time someone enters the room while the light is off to turn it on and deisgnate himself the role of counter.

then for the rest of that period the light remains on, to signal to the others that a counter has been chosen, and to ensure there is no error. Therefore on the last day - say day five, there are two posabilities. Either the light is on because the counter turned it on some time before, or it is off because there is no counter.

If it is off and it is your first time in the room, then you know everyone else was in the room. If it is off and it is your second time in the room you know one person is left to enter the room. if it is on you don't know how many people entered the room, but you know the counter counted all the ones to enter while the light was still off.
Author
Time
Just so you know I'm cruncing the numbers. There is a 1.097% chance that the counter counts 30+ people initially with that starting stratergy. So it seems it is a wise idea to allocate, say 35 days to the initial counting period (since there is a .11% chance you'll get to day 35 with the light off). the rest of the first 100 days would be wasted.
Author
Time
OK I finally understood your solution. Unfortunally it is not 100% accurate, and is based on an assumption (depending on how the prisoners are chosen, you can either be sure, or be almost sure). It is a good solution, but still not completly mathematically correct. I think it goes to your definition of "practical mathematics", agains my clear notion of "logical mathematics".

As I said before I'm completly sure that it is "logically" impossible, but I'll try to think of a way to improve your solution - even though I'll never get to 100% accuracy, it might lead to an error, even though the chances of getting it right are huge.

I must say it was one of the most intriguing logical problems I've ever seen. I'll ask this one to some people I know, see if they can come up with a better answer - chances are they won't.
“Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country.” — Nazi Reich Marshal Hermann Goering
Author
Time
I'll give you my full answer shortly, when I have built a VB program to run the entire algorithim with different settings. It is 100% accurate, and I believe the best possible algorithim (you would have to find the most optimal settings yourself, however). Everyone else has to be on 0 tokens for the counter to get to 100 tokens.
Author
Time
I tried to think of a recursive algorithm to solve the riddle but I wasn't able to. It would be something like:

b = 0;

function PrisonerRiddle(a, b){

//a = status of the lamp
//b = number of days

b = b + 1;

if b < 100 then PrisonerRiddle(a, b);
else

//do stuff

//the solution would be something like:
if a == 0 then print("I am the last prisoner!");

end if

}



Come to think of it, I think I can do it creating threads for the prisoners, and all of them accessing the function. Which brings me to another riddle proposed by a "operating systems" profesor back in college, which I've solved by programming threads in Java. It's an easy one, and it goes like this:

Imagine that there are five filosofers sitting on a round table, each with a plate with spaghetti on it. These filosofers eat the spaghetti using 2 forks at the same time. Now, between each plate there is only one fork, so that a filosofer can see his plate, a fork on the left side, and a fork on the right side. OK? Now, every filosofer will start eating his spaghetti at a random time, eat it for a random time, and stop eating it at a random time, the proceed to eat again, ad infinitum. When a filosofer decides to eat the spaghetti, he'll reach for BOTH forks and proceed to eat. The problem is, if a filosofer grabs a fork, let's say, on his left side, the filosofer to his left can't grab his RIGHT fork, get it? Now, if a filosofer wants to eat, and he can't get both of his right and left forks, he'll just stay there, waiting for the fork. Unfortunally, this can lead to a lock up if every filosofer grabs one fork. Now, you gotta decide a special rule so that this scenario never happens, and the filosofers never lock up.
“Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country.” — Nazi Reich Marshal Hermann Goering
Author
Time
Well I'm getting there. Currently I've only programmed in Phase1 (what I've discussed here) with the latter Phases to be coming (however, the program does take the cycles from the Phase1 settings textbox). You can see how the tokens are transferred:



Also, you'll notice the light is on at the bottom. All this means (in this instance) is that one token is currently being held by the light - so that when you add up the tokens they should tally. 21 (counter) + 1x9 + 1x6 + 1x2 + 61x1 + 1 (light bulb) = 100. I should note the example portrayed in the screenshot is not an average count at the end of those 4 cycles, it's just a random case. The get averages button does nothing yet.
Author
Time
Phase 1:

As you know, the average after 1 cycle is 11 people on zero. The average after 2 cycles is 14 people on zero. The average after 3 cycles is 17 people on zero. The average after 4 cycles is 19 people on zero. Now if after phase 1 you have the counter on only 1 or 2 (there's a total 1% chance of this) then it means you might want a fifth cycle.

Optimise the day numbers for each cycle.

There is a 0.545% chance that after the first cycle you reach 30+ people on zero. So, allocate 30 days for it.

If you reach 11 people on zero after the first cycle then there is a 0.509% chance that after the second cycle you have 31+ people on zero. So allocate 20 days for it.

If you reach 14 people on zero after the second cycle then there is a 0.518% chance after the third cycle that you have 32+ people on zero. So allocate 18 days for it.

If you reach 17 people on zero after the third cycle then there is a 0.576% chance after the fourth cycle you have 34+ people on zero. So allocate 16 days for it.

If you reach 19 people on zero after the fourth cycle then there is a 0.564% chance after the fifth cycle you have 34+ people on zero. So allocate 15 days for it.

Complete. Allocate 5 cycles for phase 1 as above. Phase 2 coming next....
Author
Time
I see. Well, uh... good to know you have free time on your hand, in order to program a VB module that contains a complex algorithm that solves a riddle few people understand.
“Voice or no voice, the people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same in any country.” — Nazi Reich Marshal Hermann Goering
Author
Time
It's all part of the challenge. Ironic I know, me being the one to post it... and then solve. I'm about half-way through phase 2, I completely programmed it, but it isn't optimal yet, I'm going to make a few fundamental changes to phase. The idea is that you can normally expect (in, say 99% of cases) the counter to have collected all 100 tokens by the end of phase 2. It should be less than 3000 days for this. Of course, this isn't, and can never be guaranteed - so after that you enter phase 3 which will basically last until the count is completed (so it'll have no set time-limit). It could still have recurring cycles, if it'd help, but I don't think it would. At the moment with my pseudo-phase two I am achieving more than 90 people on zero tokens (taking less than 2,000 days and with the counter on anything from 10 to 50 tokens) by the end of it. The way it's set up at the moment you can't expect the counter to have all the tokens by the end of it. I'm going to re-program it with more optimised rules.
Author
Time
I might add the place I got this riddle from had been able (after years and years and many many people trying) to get the average run-time down to 3,500 days. Well, I think - I didn't check the forum for it all the way through, so it is possible someone did better. Even so, I believe I will beat that. And that is without using (or even knowing) their formulas. I also believe my formula is the best possible method.