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