I came up with a logic puzzle inspired by this xkcd comic. I don't yet have an answer, and I am wondering if anyone can come up with one.

You are in a room with three doors. Two of the doors lead out, but one of them leads to certain death. Each door has a guard holding a spear stationed in front of it. One of the guards always lies, one always tells the truth, and the third guard will fatally stab you if you ask a tricky question. If the question isn't tricky, he will tell the truth.

For this puzzle, "tricky question" is a question that is:

  • A "meta-question" about the guards.

    Example: "If I asked Guard X about topic Y, what would he say?"

  • A question that asks about a hypothetical situation.

    Example: "If I asked you about Topic Y, what would you reply if you were a liar?"

    Another example: "If there were N doors, and I asked you question X, what would you respond?"

  • 36
    Will he fatally stab me? – Will Sep 23 '16 at 22:49
  • 7
    What does the third guard do if you ask him a non-tricky question? – gtwebb Sep 23 '16 at 22:54
  • 6
    What about shooting the guard before you get stabbed? – Oriol Sep 23 '16 at 23:04
  • 5
    Without some definition of what a "tricky question" consists of, I don't think an accurate one-question answer can be determined. – Siyual Sep 24 '16 at 0:16
  • 6
    You don't state a limit on the number of questions which can be asked, nor if there are any other limitations on what can be asked (other than not "tricky"). This effectively results in an infinite number of accurate answers. – Makyen Sep 24 '16 at 6:11

13 Answers 13

up vote 24 down vote accepted

With two questions, you can ask for the first question:

What planet are we on?

Based on the answer you'll know if they speak the truth or lies.

If they're lying:

Since two speak the truth, and only one lies, just pick any other guard and ask them which door leads to safety.

If the they're telling the truth:

Just ask the same guard which door leads to safety.

  • 7
    Perhaps you might want to generalize it to any true, non-tricky questions for the first question. You may not know the planet you are on ;) – Conor O'Brien Sep 24 '16 at 3:31
  • 24
    Replace the planet question by asking a guard whether they are a guard. That's a known fact in the puzzle. – user5971 Sep 24 '16 at 10:49
  • 1
    Or ask "Am I myself?" If they say yes, then you have the truth teller. If they say no, then you have the false teller. And, of course, if you find yourself gasping for breath with a sharp pain in your side, it's probably a good time to think about whether self-referential statement qualifies as "tricky," even if the answer is pretty obvious to most people. – Cort Ammon Sep 24 '16 at 16:47
  • 7
    @RenéG One of the guards always lies Always – Destructible Lemon Sep 25 '16 at 9:26
  • 1
    @ReneG a)wrong, and b) if right, this puzzle has no solution cause the lying guard could ALWAYS behave like a truth telling guard until he betrays you, so you just cannot win. – Patrice Sep 25 '16 at 13:49

Now that "Tricky" has been defined, I can easily do this in one question which, while tricky, does not violate any of the constraints.


Asked to Guard 1: Is exactly one of the statements "you always lie" and "the door you guard leads to certain death" true?

This has four possible cases: Liar + Death, Liar + Safe, Truthteller + Death, Truthteller + Safe. A quick check of the logic shows:

Liar + Death = Guard says Yes
Liar + Safe = Guard says No
Truthteller + Death = Guard says Yes
Truthteller + Safe = Guard says No

Thus, if the Guard says No, pick their door. If they say Yes, pick one of the other doors.

  • I dont think the first question would be tricky. It asks if someone is a liar. I would think a question is tricky if its more like "if i asked gaurd 2 if he was a liar would he say yes" because you are then basically running the question through 2 gaurds. – gtwebb Sep 24 '16 at 0:09
  • 1
    @gtwebb we are getting back to the fundamental definition of what makes a question "tricky", and the reality is that the OP provided no such definition and one is not clear from context. This means that solutions are inherently subjective. – Robert Columbia Sep 24 '16 at 1:06
  • Edited based on definition of "Tricky". – Zerris Sep 24 '16 at 3:44
  • 7
    I would definitely argue that this question is very meta, considering that you specifically want the guard to reveal his status as a liar. – pipe Sep 24 '16 at 7:19
  • 1
    Doesn't matter, I don't think - the individual statements aren't questions, just features of the world. It's like asking "is either 3 or 5 less than 4?" - a liar has to say "No", because there's only one thing to lie about. – Zerris Sep 25 '16 at 3:07

My strategy:

Ask the first guard three questions:
"Does the first door lead out?"
"Does the second door lead out?"
"Does the third door lead out?"
Either all answers will be the truth, or all answers will be lies. Since two doors lead out, and one leads to death, I just have to take one of the two doors for which he gives the same answer.

  • 10
    You only need to ask 2 questions about the 1st and 2nd doors. If the answers are the same, either door leads out. If the answers are different, you know the 3rd door leads out. – Paul Evans Sep 25 '16 at 15:42
  • @PaulEvans: Good point. – celtschk Sep 25 '16 at 19:12

As long as the floodgates have opened, and people are submitting responses with three questions:

Pick a door.
Ask the first guard, "Does this door lead out?"
Ask the second guard, "Does this door lead out?"
Ask the third guard, "Does this door lead out?"
Two of the answers you get will be the truth, so, if you get "Yes", "Yes" and "No" (in any order), the door leads out, so you can use it, and if you get "Yes", "No" and "No", the door leads to death, and you should use one of the others.

Trivial optimization: if the first two guards give the same answer, you know that's the truth, and you don't need to ask the third guard.

  • Your optimization isn't necessarily right, what if the liar is guarding the door to death? He would say yes too. – dcfyj Oct 13 '16 at 15:32
  • @dcfyj: I don’t understand your comment. You’re right, up to a point.  If I pick the door that leads to death, and I ask “Does this door lead out?”, the liar will say “Yes”.  But the other two guards will say “No”. If I happen, by random choice/good luck, to ask the two honest guards first, I’ll get two “No” answers, and the optimization works.  If I happen, by random choice/bad luck, to ask the liar first or second, then my first two answers will be one of each (“Yes” and “No”), then the optimization does not apply, and I am forced to ask the third guard (who is guaranteed to tell the truth). – Peregrine Rook Oct 13 '16 at 17:22
  • Ok, I misread what you said. I thought you were saying that you were asking each guard about his own door. Rather than asking each guard about a specific door. – dcfyj Oct 13 '16 at 17:29
  • @dcfyj: That answer wouldn’t work at all if the liar was guarding the death door.  If I asked each guard, “Does your door lead out?”, they would all say “Yes”, and I’d learn nothing useful.  Only if an honest guard was guarding the death door would I get two negative answers and one affirmative, and I would go through the door whose guard said “Yes” (because he would be an honest guard in front of an exit door). … (Cont’d) – Peregrine Rook Oct 13 '16 at 17:50
  • (Cont’d) …  And I can optimize that: if the first two guards that I asked said “No”, I would know that the third door was the exit.  And if the first two guards gave one of each answer, I would know that the one who said “Yes” was guarding an exit.  … … … … … … … … … … … … … … … … … … … … … … … … … …  My point is that, if my answer had been what you thought it was, then the whole answer would have been flawed, and not just the optimization. – Peregrine Rook Oct 13 '16 at 17:51

Two questions and no trickery:

Ask the 1st guard "Does your door lead to certain death?"
Ask the 2nd guard "Does the 1st guard's door lead to certain death?"

Take these actions depending on their answers:

1. Yes and yes, they are both telling the truth, use a different door.
2. Yes and no, one of them is telling the truth, use a different door.
3. No and yes, one of them is telling the truth, use a different door.
4. No and no, both are telling the truth, use that door.

  • simplest answer :) – Wasiq Shahrukh Oct 6 '16 at 4:17
  • -1, uses a "meta-question" about the first guard. – Buffer Over Read Oct 15 '16 at 17:02
  • 2
    How is it a meta question? I'm asking the guard a single question, not a question about a question. – jstnthms Oct 23 '16 at 3:24

A lot depends on your definition of tricky, as has been commented. It could be that any question that gets you out is tricky, making it unsolvable.

Would you like me to buy you all a beer?

Then regardless of how they answer, you can just follow them out to the nearest pub and buy them a beer.

The question does not specifically disallow this yet, so you could:

Ask in a loud voice and a general manner: "Does this door lead out"? If you get two "Yes" and one "No" then go out through it. If not, then go out through one of the other ones.

The title text states

And the whole setup is actually a trap to capture escaping logicians. None of the doors actually lead out.

Given the scenario in the comic, you die regardless. However, if one of the doors did actually lead to freedom, I would use the Monty Hall problem to my advantage using the following steps...

  1. Choose a door randomly in your head.
  2. Announce your choice to the guards.
  3. Ask one of the guards "Is your spear pointy?" If the guard says no, you know that he is the liar.
  4. Instruct one of the truth-telling guards to open a door that leads to death.
  5. Go through the door you originally chose. There is a 2/3 chance you will live.
  • 3
    If you've established who are the truth-telling guards, why not just ask them to point you to a safe door? – Arkku Sep 24 '16 at 12:44
  • Since there's only one door leading to death, as soon as he opened it, it doesn't matter which of the other doors you use. – celtschk Sep 24 '16 at 13:02
  • 3
    And BTW, if a 2/3 chance is enough for you, you can just randomly choose one of the doors and ignore the guards altogether. ;-) – celtschk Sep 24 '16 at 13:19
  • I assumed only one door led to life. I was also trying to get away with asking only one question. – Caleb Reister Sep 24 '16 at 15:45
  • 1
    Go through the door you originally chose. There is a 2/3 chance you will live. - there was already a 2/3 chance that you chose a safe door. 2-4 have no real bearing on anything. I don't think the Monty Hall problem is really applicable here. – Ant P Oct 6 '16 at 12:23

Had a quick stab at this, could probably work it out a bit more...

Anyway, I started using statistics mixed with logic to try and maximise the chance of living.

One Question, nothing tricky:

Ask any guard- Is this door safe?

This won't give a definite answer, but can increase the chances of your survival (if you are lucky). Here's my reasoning behind it:

Since we're using a simple question, there's a 2/3 chance that the guard will tell the truth.
If we were to pick any random door, there's a 2/3 chance that we are safe anyway.

Using these two facts, we can try to scrape together some stats to increase our chance of survival:

I'll use the abbreviations T for 'Truth-teller', L for 'Liar', S for 'Safe' and D for 'Death', Yes for 'Yes' and N for 'No'

  • 2/3 T AND 2/3 S = 4/9 Y S
  • 2/3 T AND 1/3 D = 2/9 N D
  • 1/3 F AND 2/3 S = 2/9 N S
  • 1/3 F AND 1/3 D = 1/9 Y D

With these results, we can further group things by the answer given.

If answer is Yes- 4/9 Chance of Safety, 1/9 Chance of Death
This becomes 80% Chance of Safety, 20% chance of Death.

If answer is No- 2/9 Chance of Safety, 2/9 Chance of Death
Which works out as 50/50.

So, given all this info, you could make a decision:

If they Answer 'No', Pick any door, it's a 2/3 chance of survival.
If they Answer 'Yes', Pick this door, it's a 80% chance of survival.

Like I said, this was just a quick stab, Maybe someone else could stack the odds a bit better with a different question?

Since I don't yet have enough reputation to comment, I'm asking this in an answer.

How many questions are we allowed to ask the guards?

The other answers that have been suggested have varying numbers of questions suggested, and the task becomes fairly trivial if there's no limit to the number of questions askable. In order to prevent the puzzle from being too open-ended, I think that a maximum number of questions should be specified.

I'm operating under the assumption that we're only allowed one question. I also believe my one question does not fall under the two current "tricky" guidelines. It's definitely not a hypothetical, and I don't think it counts as "meta", since it's very straightforward. But you be the judge.

For ease, assume the doors are numbered 1, 2, 3 and the guards are similarly numbered. Rephrasing the question to get the same result is easy if they're not. The question is...

Ask guard 1 : Is exactly one of the statements "Guard 1 is the liar" and "Door 1 is safe" true?

If you get the response "yes":

If Guard 1 tells the truth, then exactly one of the two statements is true. Clearly the first is not true, so Door 1 must be safe. If Guard 1 lies, then the first statement is true. So in order for the guard to lie, both statements must be true and Door 1 is safe. Conclusion: Door 1 is safe.

If you get the response "no":

A truth telling Guard 1 answering "no" means either both statements are true or both are false. The first is clearly not true. Therefore the second must also be false and Door 1 is not safe. If Guard 1 is lying, that means exactly one of the two statements is true and it must be the first, so the second is false and Door 1 is not safe. Either way, Door 1 is not safe - pick a different one.

I'm curious if this would fall under the "meta" category the OP described. To me, it's a straightforward question about the truth values of two statements.

I'll assume "tricky" means you can't ask questions about the guards.

If the "stabby" guard answers randomly,

Then you're better off just taking a random door and skipping the questions. Asking questions results in a 50% of being directed to the wrong door (and probably a greater chance of being stabbed), just going through doors gives you a 67% chance of surviving.

If the "stabby" guard is just silent:

Ask an easy question (is 1+1 2?). If he's silent then just pick a door and skip the 2nd question. If he answers then you'll know if he's the liar and can use your 2nd to find the door.

Edit: A truthful tricky guard is handled just like if you'd talked to the truthful guard to start with.

  • Mr. Stab will tell the truth, if it's not a tricky question. (Definition of tricky is in the original question) – margalo Sep 24 '16 at 2:49
  • Please edit this into the original question for clarity. – Shawn V. Wilson Sep 24 '16 at 3:08
  • 2
    Also, there's some disagreement whether the question "Is Guard 2 the guard that always lies?" a tricky question or not. – Shawn V. Wilson Sep 24 '16 at 3:17

Pick 1 door. For each guard, ask: "Is that door leading out?"

if it is: Mr.Truth & Mr.Stab: "Yes" Mr.Lie: "No". if it is not: Mr.Truth & Mr.Stab: "No", Mr.Lie: "Yes".

if you get 2 yes, go out that door. else, go out any other door.

Ask each guard this question:

Are you the guard that stabs?

With that information:

You know that the one who answers "No" tells the truth.

And so, finally:

Ask the truthful guard for directions on the way out.


The stabby guard will answer "Yes" because he tells the truth. The liar will know the answer is "No", but will lie and answer "Yes". Only the truth-teller will answer "No".

But I bet that the whole labyrinth is just a trap to capture escaping logicians.

Question Stats: Two on a best-case scenario, four on a worst case scenario.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.