Data Structuresand Algorithms Good OldJava AdvancedInterview Topics Cloud andDatabases Web Designand Development Must-knowTools Good ToKnow

## Road to the heavens

Puzzle: Once upon a time, a man reached a strange place from which two roads were starting off in two directions.
It is fabled that out of these two roads, one goes to the Heavens and other to the Hell.
The strange place also has two creatures - One of them always lies and other one is always truthful.

Not knowing which road leads to Heavens and which creature speaks the truth, how will you find the road to Heaven out by just asking one question ?

Solution: The road to Heaven can be found by asking the following question to any creature:

What would the other creature say if I were to ask the way to Heavens ?

If the question was asked to the truthful creature, it knows that the other creature is a liar and would tell the wrong way.
So the truthful creature would rightfully point to the wrong road because that would have been the answer given by the lying creature.

If the question was asked to the liar, it knows that the truthful creature would have pointed to the right way.
So he would lie and point to the wrong road.

So in both cases, answer would point to the wrong road.
You say Thank You and take the other road.

Like us on Facebook to remain in touch
with the latest in technology and tutorials!

Got a thought to share or found a
bug in the code?
We'd love to hear from you:

 Name: Email: (Your email is not shared with anybody) Comment:

Facebook comments:

Site Owner: Sachin Goyal