In The Pyramids of Mars, Sarah-Jane Smith is trapped. There are two switches, one of which will release her, one of which will kill her. There are two guardians, one of which tells the truth, the other always lying. The Doctor can ask one guardian one question. He asks,
“If I asked the other guardian which was the life switch, which would it indicate?”
The liar will lie about the truth-teller, and so indicate the death switch. The truth-teller will tell the truth about the liar, so indicate the death switch. The Doctor presses the other switch and Sarah is released.
John Finnemore did a sketch in which the guardians are fed up because everyone now knows what to ask- so they introduce a third guardian who strictly alternates, lying in one answer then telling the truth in the next. You will not know whether the alternator will lie or tell the truth, because you do not know which it did last time, to the last intrepid explorer. It will only change from lying to telling the truth if asked a question. There are still a life switch and a death switch. The only permitted questions are those which can be answered by a guardian pointing at a switch.
If you ask the first guardian, which is the Life switch, then ask the first the same question again, and the answers are different, you know that the first is the alternator, and you can ask the second guardian the Doctor’s question about the third. If the first’s answers are the same, and you ask the second guardian the same question twice, if the second’s answers are the same the third is the alternator: ask the first the Doctor’s question about the second; but if the second’s answers differ then it is the alternator, and you ask the first the Doctor’s question about the third. So you can always identify the life switch in five questions, and sometimes with three.
However, I can always identify the life switch with three questions.
What questions do you ask so that, whatever the answers, you can always find the life switch with three questions?
Call the guardians 1, 2 and 3 and the switches X and Y. Kudos to anyone who answers this. If anyone asks, I will answer it in a week, in the comments. (Added: The answer is now below, in the comments.)
I have no idea if anyone else has worked on this puzzle. It seems likely someone has. I thought I had answered it, then found a flaw in my argument, and scheduled this post for 1 April; but now, I am clear that I have answered the puzzle.