You are standing before two doors. One of the path leads to heaven and the other one leads to hell. There are two guardians, one by each door. You know one of them always tells the truth and the other always lies, but you don’t know who is the honest one and who is the liar.
You can only ask one question to one of them in order to find the way to heaven. What is the question?
This is one of the classic puzzles asked in Infosys interview.
The question you should ask is “If I ask the other guard about which side leads to heaven, what would he answer?”. It should be fairly easy to see that irrespective of whom do you ask this question, you will always get an answer which leads to hell. So you can chose the other path to continue your journey to heaven.
This idea was famously used in the 1986 film Labyrinth.
Here is the explanation if it is yet not clear.
Let us assume that the left door leads to heaven.
If you ask the guard which speaks truth about which path leads to heaven, as he speaks always the truth, he would say “left”. Now that the liar, when he is asked what the other guard (truth teller) would answer, he would definitely say “right”.
Similarly, if you ask the liar about which path leads to heaven, he would say “right”. As the truth teller speaks nothing but the truth, he would say “right” when he is asked what the other guard ( liar ) would answer. So in any case, you would end up having the path to hell as an answer. So you can chose the other path as a way to heaven.