TRUTH OR LIES | Microsoft interview

You’re walking down a path and come to two doors. nike free run swarovski One of the doors leads to a life of prosperity and happiness, and the other door leads to a life of misery and sorrow. You don’t know which door is which. In front of the door is ONE man. Maglia Hakeem Olajuwon You know that this man either always lies, or always tells the truth, but you don’t know which. The man knows which door is which. Nike Air Max 2016 Heren grijs You are allowed to ask the man ONE yes-or-no question to figure out which door to go through. To make things more difficult, the man is very self-centered, so you are only allowed to ask him a question about what he thinks or knows; your question cannot involve what any other person or object (real or hypothetical) might say. new balance 530 online shop What question should you ask to ensure you go through the good door?         Solution :

You should ask: "If I asked you if the good door is on the left, would you say yes?" Notice that this is subtly different than asking "Is the good door on the left?", in that you are asking him IF he would say yes to that question, not what his answer to the question would be.  Los Angeles Angels Jersey Thus you are asking a question about a question, and if it ends up being the liar you are talking to, this will cause him to lie about a lie and thus tell the truth. The four possible cases are: * The man is a truth-teller and the good door is on the left. He will say "yes".  Nike Lebron 13 * The man is a truth-teller and the good door is on the right.  New Balance 1500 damskie He will say "no". * The man is a liar and the good door is on the left. He will say "yes" because if you asked him "Is the good door on the left?", he would lie and say "no", and so when you ask him if he would say "yes", he will lie and say "yes". * The man is a liar and the good door is on the right.  Adam Wainwright Jersey Similar to the previous example, he'll say "no". 

Leave a Reply

Your email address will not be published. Required fields are marked *

For Inserting code :
Paste your code in the comment form, select it and then click the language link

C | C++ | Java |

*