Prisoner hat and light riddles?
Riddle 1:
A prison has 1000 inmates and a room with a light switch, initially off. Every day, a random prisoner is let into the room, and they may flip the switch if they wish. Once a prisoner believes every prisoner has been in the room, he may tell the warden. If he's right, all the inmates are let go, but if he's wrong, they're all killed. The prisoners are allowed to decide on a strategy before any of them are put into the room. How can they all survive?
(Assume the random prisoner choice never "gets stuck", that the prisoners live forever, that they all want out alive, etc.)
Riddle 2:
A prison has infinitely many inmates, one for each integer, and they're numbered. The warden is insane. One night, she decides the next day she'll line up all the inmates and randomly give them either a red or a blue hat. They won't be able to look at their hat or tell others about their hat, but each prisoner can instantly see every other prisoner's hat color. They will be taken in order into a secluded room, asked the color of their hat, and put back in line. The other prisoners are unable to hear their response. After every prisoner has had their turn, all those who answered wrong are killed, and the rest are set free.
The janitor overhears her plans and lets the prisoners know beforehand. They meet and decide on a strategy where no matter what the warden does, only finitely many of them will die. What is their strategy?
I have a solution to (1) and two solutions to (2), but more would be welcome, and at any rate I found these to be interesting so I thought I'd try sharing them.
@Scythian: that was my solution to (1) as well. I tried improving it for a while with multiple "collectors" but got nowhere, though I'm almost sure much better solutions exist.
@Michael/jibz: Excellent idea to keep track of the number of days. I had neglected that information. I'll think about it more now.
@Michael: Riddle (2) has an actual, non-trick, non-wordplay, etc. answer. Actually, at least two; one of mine uses your observation (and more, of course).
@Scythian: Extended. Assuming god-like powers of observation, memory, and reasoning for the inmates is fine. You can phrase the question purely in terms of sets but it's not as interesting or memorable :)
@jibz: For Riddle 1, the prisoners aren't allowed to "call out" numbers, though otherwise I like that solution quite a bit. ("The other prisoners are unable to hear their response.")
@Brian: I didn't link to that Wikipedia page originally since I was hoping not to "taint" people's solutions. Still, I suppose Riddle 2 hadn't had any progress for a few days. For what it's worth, my own solution was different; I heard Wikipedia's solution from the person who first asked me the riddle.
@Scythian: The axiom of choice is accepted by almost all modern mathematicians. Existence of choice functions isn't terribly controversial, though in some sense it is speculation about the nature of infinity. I have ideas for ensuring at least one inmate lives in the finite version; I don't believe "a solution exists only if there's an infinity of inmates".
@Michael: I had thought of similar strategies, but how can you be sure it
@Michael: (second try) I had thought of similar strategies, but how can you be sure it terminates? What if the warden never picks the super tracker during phase 3? I had interpreted the riddle as requiring a strategy where the prisoners are guaranteed to get out, not just get out with "high probability" in some sense.