suppose you are in a room that has two identical doors. Behind one door is riches, wealth and fame beyond your wildest dreams. Behind the other door is a firing squad that does not miss. Youdo not know which door is which, however there are two identical twins in the room that do. The only problem is one of the twins always tells the truth and the other always lies and you do not know which twin is which. If you can ask one of the twins one question before opening a door, what would that question be?

Ask one twin what the other twin would answer if asked what's behind one of the doors :)

Here's a similar problem with an explanation.

A logic problem: What question should the princess ask?

A princess visits an island inhabited by two tribes. Members of one tribe always tell the truth, and members of the other tribe always lie.

The princess comes to a fork in the road. She needs to know which road leads to the castle so as to avoid the fire-breathing dragon and rescue the prince from the wizard holding him captive in the castle. (Although the princess doesn't know it, the south road leads to the castle and the north road leads to the dragon.)

Standing at this fork in the road is a member of each tribe, but the princess can't tell which tribe each belongs to. What question should she ask to find the road to the castle?

--------------------------------------------------------------------------------

Simply asking which road leads to the castle won't help. The answer won't tell us which native is lying and which native is telling the truth. However, we really only need to talk to one of the natives. The trick is to ask a question where the response will be the same from both natives: a question that incorporates how a member of the tribe not answering would respond to the same question.
For example, what if we say to one of the natives, "If I asked a member of the tribe you don't belong to which road I should take to get to the castle, what would he say?"

If we ask a truthteller, the response will be: "He would say to take the north road." The road to the castle is the south road so the liar will tell us to take the north road, and the truthteller will faithfully report this to us.

If we ask a liar, the response will be: "He would say to take the north road." The road to the castle is the south road and the truthteller will tell us to take the south road, but the liar will not report this faithfully to us - he will say the opposite.
In both cases we'll get the same response. We should do the opposite of what we have been told because, regardless of whether we are speaking to a liar or a truthteller, our question will always produce the wrong answer to which road we should take.

http://mathforum.org/dr.math/faq/faq.liar.html

In this scenario, where there are two identical doors and two twins who know what's behind each door, one lying twin and one truthful twin, you can ask one twin the following question: "If I asked the other twin which door leads to riches, what would they say?"

Let's break down the possible outcomes:

1. If you ask the truthful twin: In this case, the truthful twin will tell you what the lying twin would say. Since the lying twin always lies, the truthful twin would tell you that the lying twin would point to the door that leads to the firing squad. Therefore, the truthful twin would tell you that the firing squad door is the one that leads to riches.

2. If you ask the lying twin: In this case, the lying twin will also tell you what the lying twin would say. Since the lying twin always lies, the lying twin would intentionally give you false information about what the truthful twin would say. Therefore, the lying twin would also tell you that the firing squad door is the one that leads to riches.

In both cases, you will receive the same answer - that the door leading to the firing squad is the one that leads to riches. Therefore, you should choose the other door to maximize your chances of finding the door that leads to riches.

This question is similar to the logic problem involving the princess and the two tribes. In that situation, the princess needs to determine the correct road to the castle by asking a member of one of the tribes. The trick is to frame the question in a way that the response will be the same regardless of whether the native is a truthteller or a liar.

By asking a native, "If I asked a member of the tribe you don't belong to which road I should take to get to the castle, what would he say?", the princess will receive the same response regardless of whether the native is a truthteller or a liar. This allows her to deduce that she should take the opposite road to find the castle.

By using these logic-based questions, you can navigate through situations where you need to differentiate between truth-tellers and liars to make the best decision.