Quant Memo
Foundational

One Question, Two Guards, One Door

The classic logic puzzle — one guard always lies, one always tells the truth, you can ask a single question to find the safe door — solved with the self-canceling-lie trick that generalizes to any single-liar setup.

The problem. Two doors, one leads to safety, one to danger. Two guards stand in front of the doors — one always tells the truth, the other always lies, but you don't know which is which. You may ask exactly one yes/no question, directed at only one guard of your choosing, to determine the safe door. What do you ask?

Why the obvious question fails

Asking either guard directly "is this the safe door?" fails, because you don't know if you're talking to the truth-teller or the liar — a "yes" from the liar means no, and a "yes" from the truth-teller means yes, and you have no way to tell which situation you're in from a single answer.

The trick: ask about what the other guard would say

Point at one door and ask either guard: "If I asked the other guard whether this is the safe door, what would they say?" Then do the opposite of the answer you get.

Ask truth-teller Ask liar honestly relays liar's lie lies about truth-teller's truth same false answer received invert it to get the true answer, either way
Whichever guard you ask, exactly one layer of falsehood gets applied to the report — honest relay of a lie, or a lying relay of the truth — so both paths land on the same wrong answer, and inverting it always works.

Why this works — trace both cases:

  • You ask the truth-teller. They accurately report what the liar would say. The liar would lie about the door, so the truth-teller faithfully reports that lie back to you — meaning the answer you receive is the liar's false answer, passed through honestly.
  • You ask the liar. They must lie about what the truth-teller would say. The truth-teller would answer honestly, but the liar reports the opposite of that honest answer — meaning the answer you receive is again the false answer.

In both cases, the answer you receive is the wrong answer, filtered through one layer of either honest-reporting-of-a-lie or dishonest-reporting-of-truth. Either path lands you on the same false answer, so the safe door is always the opposite of whatever you're told.

Worked example: playing it out with labels

Say the truth-teller is guard T and the liar is guard L, and the safe door is Door 1. Ask guard T: "What would guard L say if I asked whether Door 1 is safe?" Guard L, asked directly, would lie and say "no" (Door 1 is safe, so the liar denies it). Guard T reports this honestly: "L would say no." You do the opposite of "no" — you correctly conclude Door 1 is safe.

Now ask guard L the same question: "What would guard T say if I asked whether Door 1 is safe?" Guard T, asked directly, would truthfully say "yes." Guard L must lie about this and reports: "T would say no." Again you hear "no" and do the opposite — correctly concluding Door 1 is safe. Same question, either guard, same (wrong) answer received, same correct conclusion after inverting.

The general technique: nesting a lie inside a report cancels it out

This puzzle is a template for a broader class: whenever you have exactly one reliable source and one unreliable source but don't know which is which, asking either one to report on the other's answer forces a lie to pass through the system exactly once — either as an honest relay of a lie, or a dishonest relay of the truth — and a single pass through exactly one layer of falsehood always flips the answer you'd want. The fix is universal: invert whatever you're told.

When exactly one of two informants lies and you don't know which, ask either one to report what the other would say, then invert the answer. A single question forces exactly one layer of falsehood into the chain regardless of who you ask, so the received answer is always wrong and the true answer is always its opposite.

Whenever a logic puzzle gives you "one truth-teller, one liar, one question," the "ask about the other's answer" trick is almost always the intended solution — look for a way to route the question through the unreliable source exactly once.

Related concepts

Practice in interviews

Further reading

  • Smullyan, What Is the Name of This Book?
ShareTwitterLinkedIn