# 2 Guards, 3 Keys, 2 Locks

There are 2 guards: one only tells the truth, the other only lies.

There are 2 locks and 3 keys: each lock can only have 1 key matched - the 3rd key doesn't do anything.

• You can only ask one specific question and can expect both guards to answer that one question.
• The guards will only answer your one question by only pointing to a key, and only to one key.

What do you ask to know which key unlocks which lock?

• The keys to both locks must be identified, not just one lock.
• and do we know which guard tells the truth or lie?
– Oray
Oct 7, 2019 at 8:27
• How would the guard who lies answer 'Which key doesn't do anything?'?
– JMP
Oct 7, 2019 at 8:31
• @Oray Nope, it's not given
– Sinh
Oct 7, 2019 at 8:34
• @JMP they will point to one of the other 2 keys, of course.
– Sinh
Oct 7, 2019 at 8:34
• What do they do if I ask them a question that they cannot determine the truth value of? For example, "which key unlocks Lock A and also doesn't unlock Lock A?" How does each person respond to exactly that question? Oct 7, 2019 at 10:07

Using Deusovi♦ way of assigning locks to guards, lock one to Guard A and lock two to Guard B
Which one of the keys will the other guard never choose if I ask him to unlock there lock?(Thanks to Admiral Jota for pointing out some bug)

Since

If its the True guard will point to the key that will unlock the Lying ones door, since the Lying guard will have a chance of choosing any of the wrong keys, by not doing so he will only choose the real key.

And

If its the Lying guard then he will always point at the True guards key, since True guard will have chance of picking any of the wrong keys.

• I don't think this quite works. If the Liar needed to unlock his lock, he wouldn't use the wrong key for it just because he's a Liar. Oct 8, 2019 at 17:42
• @AdmiralJota Right, but he can lie about which one he would use. Oct 8, 2019 at 18:33
• @Trenin The True guard will still point to either his own key or the useless one, though. Because that's the correct answer to the question about what the Lying guard would (or in this case, wouldn't) do. Oct 8, 2019 at 22:00
• @AdmiralJota Actually since rot13(Gur Gehr thneq jvyy cbvag ng gur bar gung gur Ylvat thneq jvyy cbvag, vg jvyy or gur fnzr nf nfxvat gur ylvat thneq juvpu bar gurl jvyy arire fryrpg gb bcra gurer ybpx, va gung pnfr fvapr ur vf ylvat ur jvyy nyjnlf fryrpg gur evtug xrl.) Oct 9, 2019 at 1:55
• @AdmiralJota Thats a good point, lettme change that real quick Oct 9, 2019 at 2:07

As long as the two locks are distinguishable somehow, this can easily be solved with a variation on the 'standard' trick:

First, assign each person a lock: "Let's say that lock 1 "belongs to" guard A, and lock 2 "belongs to" guard B."
Then ask the question: "If I asked you yesterday which key opened your lock, what is one key you might have pointed to? [¹]"

[¹] As Trenin points out, you need a clause here like "...assuming that if you are the liar, your algorithm is to point to any wrong answer, rather than defaulting to a particular wrong answer", to avoid the case where the liar is deterministic.

This works because:

The truthteller will obviously point to their own key - if you had asked them yesterday, they would tell the truth, and so today they will tell the truth about their hypothetical answer, and point to the correct key.

But what about the liar?If you had asked the question "Which key opens your lock?" to the liar, the correct answer could be either of the two wrong keys.

(If the two locks are indistinguishable, there is of course no way to determine which key unlocks which lock.)

• I don't see your logic. Rot13(Jul jbhyq gur yvne unir gb cbvag gb gur qvssrerapr xrl?)
– Sinh
Oct 7, 2019 at 8:53
• @Sinh rot13(Gur pbeerpg nafjre gb gur dhrfgvba "Juvpu xrl bcraf lbhe [gur yvne'f] ybpx?" vf bar cnegvphyne xrl: yrg'f pnyy guvf xrl N. Fb gur yvne jbhyq tvir bar bs gur bgure gjb nafjref: xrl O be xrl P. // Fb vs V vafgrnq nfx gur ulcbgurgvpny "jung jbhyq lbh cbvag gb vs V nfxrq [gung dhrfgvba] lrfgreqnl?", gur pbeerpg nafjre vf xrl O be xrl P: gubfr jbhyq or gur xrlf gung gur yvne jbhyq unir cbvagrq gb. Fb gur yvne zhfg tvir na vapbeerpg nafjre, juvpu zhfg or xrl N.)
– Deusovi
Oct 7, 2019 at 8:57
• @DrXorile Yes, this should work with any number of keys. (It would also work with any number of locks, provided there were as many guards as locks -- and with any combination of truthtellers and liars.)
– Deusovi
Oct 7, 2019 at 15:09
• @Sinh This may not be your intended answer, but it's completely correct. I'm not interested in "guess which solution the questioner is thinking of".
– Deusovi
Oct 7, 2019 at 16:12
• @temporary_user_name Oh, that's Rot13, a common cipher used to hide spoilers without explicit spoiler formatting. Just copy-paste the text into that site to decode it.
– Deusovi
Oct 7, 2019 at 20:18

Ask one guard: "Which key would the other guard say opens at least one of the locks?" This will tell you which key does not open any of the locks. Then, ask the other guard: "Which of these two keys would the other guard say opens lock A?" This will tell you which one opens lock B. At that point, you know that the other one opens lock A.

• Explanation in rot13(Ol svygrevat gur thneqf guebhtu rnpu bgure, lbh'er thnenagrrq gb trg n yvr. Bapr lbh fbyir gur thneqf va guvf jnl, vg'f fvzcyl n znaare bs fvsgvat guebhtu gur xrlf. Svefg, jr erzbir gur xrl gung qbrfa'g bcra nal ybpxf ol nfxvat sbe gur erirefr: "Juvpu xrl bcraf ng yrnfg bar ybpx?" Gurer vf bayl bar jebat/yvr nafjre gb guvf. Ryvzvangr gung xrl. Gura lbh fvzvyneyl nfx sbe na bccbfvgr nzbat gur erznvavat gjb xrlf.) Oct 8, 2019 at 7:51
• You missing the "You can only ask one specific question to both guards." condition.
– Sinh
Oct 8, 2019 at 15:15
• Ah, I read it as one question to each guard. Oct 8, 2019 at 16:27

Choose a guard and lock at random. Point to the lock and say

"Which key would the other guard NOT point to if I were to ask which one opens this lock?"

The truthteller knows that the liar would not point to the correct key, so they point to the correct key. The liar knows that the truthteller would point to the correct key, so they lie and point to the correct key.

Now you have one lock open and have eliminated a key, so ask the same question to the other guard, pointing at the remaining unopened lock.

If the question needs to be asked simultaneously of both guards, then we need to add a little more information, so it becomes:

Assign a lock to each guard. Ask:

"Which key would the other guard NOT point to if I were to ask which one opens their lock?"

The truthteller knows that the liar would not point to the correct key, so they point to the correct key. The liar knows that the truthteller would point to the correct key, so they lie and point to the correct key.
Since each guard was assigned a different lock, we now know the keys for each lock.

• welcome to Puzzling, you seem to have a right ideal but maybe I really need to clarify more.
– Sinh
Oct 8, 2019 at 15:52
• What if it's the other way around, and they fall into recursive thinking? Let's somehow you started with the liar: he would think... Hmmm the truthteller will know that me the liar would think that the truthteller would point to the correct key, so I point to the wrong key but since that might be a possibility the truthteller could have thought of, I could gamble to point to the right key, at which point, the other might have thought that the other might know that the other might think the other might know that the other might think that.... HELP :( Oct 8, 2019 at 20:42
• @JoeDF "The liar always lies" in these puzzles means that the liar always makes statements that are factually false, not that they try to deceive you any way possible such as using reverse psychology. They simply make factually false statements. So there is no "but since that might be a possibility the truthteller could have thought of, I could gamble to..." No gambling, just factually false statements. Oct 9, 2019 at 14:39
• @void The question has been edited to clarify what "one question of both guards" was intended to mean. It has been revised such that one question is asked initially and both guards answer that same question. Oct 9, 2019 at 14:42
• Amended to cater for the case where the question must be asked simultaneously, rather than in sequence.
– void
Oct 11, 2019 at 8:20

I can figure out the fitting key for one lock specifically with the question:

If I asked you which key you need for lock A, to which key would you point?

Because:

Obviously the truth teller points to the right key. The liar has to also point to the right key because if he pointed to one of the wrong keys he would answer the question correctly and tell the truth.

My solution would work with one question if I'm allowed to ask a question to which the guards can point to multiple keys or if each lock belongs to one guard.

• I like this answer. But what if the liar thinks "Well, I can point to either of the bad keys as the answer, so I will point to the one that opens lock B. So since he is asking which one I would point to, I cannot point to that one so I must point to either the one that does nothing, or lock A." So I don't think it is guaranteed that the liar would agree in this case. Oct 7, 2019 at 13:56

This answer only assumes that the guards and the keys are taking up physical space, i.e. each guard has a door to which they are closest, and each door has a guard to which it is closest (i.e. a one-to-one relationship).

"If and only if you are a truth-teller, which key opens the door closest to you?"

Edit: I realized I need to update my answer to prevent the lying guard from pointing to the non-working key:

"If I had asked you yesterday which key unlocks the door closest to you, which key could you have possibly pointed to?"

• @Loduwijk My answer unlocks both locks. What you say is only true if both guards are closest to the same door. Oct 8, 2019 at 16:29
• @DavidJ. so same logic and wording as Deusovi♦ then. well I glad you got it.
– Sinh
Oct 8, 2019 at 16:53
• @Loduwijk I didn't look at any of the other answers. Just realized you are right, mine is equivalent to the top answer at the moment. Oct 8, 2019 at 16:58

Totally using Deusovi's logic here, so credit to him:

Which key might you choose?

But I'm stuck if each guard doesn't have their own lock.

• Can you explain why this answer works? Answers without explanations are usually deleted.
– Deusovi
Oct 9, 2019 at 5:45
• Ok. If you ask the liar, they might choose the extraneous key or they might choose the erroneous key, which means they can choose neither.
– John
Oct 9, 2019 at 10:16

Further clarification on the rules suggests that the problem is solvable. I will leave this answer as I find it humorous and interesting, but it was only true according to my original interpretation of the rules. And I will delete my other answer.

This is a trick question and the riddle can be solved without even asking the guards any questions. It is impossible to deduce logically with only 1 question total, so the question is irrelevant, and the fact that you can ask a question is extraneous information unrelated to the problem. Instead, just try each key in each lock since there is nothing in the rules stopping you from trying more than once.

• the fun of the "1 question total" is how you can chain multi condition to 1 question that make sense. & I think you miss understood my point "What do you ask to know which key unlocks which lock?" means you get the knowledge of keys only by the answer from guard, not by doing whatever
– Sinh
Oct 8, 2019 at 15:12