13
$\begingroup$

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.
$\endgroup$
  • 1
    $\begingroup$ and do we know which guard tells the truth or lie? $\endgroup$ – Oray Oct 7 at 8:27
  • 2
    $\begingroup$ How would the guard who lies answer 'Which key doesn't do anything?'? $\endgroup$ – JMP Oct 7 at 8:31
  • 1
    $\begingroup$ @Oray Nope, it's not given $\endgroup$ – Sinh Oct 7 at 8:34
  • 1
    $\begingroup$ @JMP they will point to one of the other 2 keys, of course. $\endgroup$ – Sinh Oct 7 at 8:34
  • 2
    $\begingroup$ 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? $\endgroup$ – hdsdv Oct 7 at 10:07
4
$\begingroup$

Hmm..my head is hurting

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.

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – Admiral Jota Oct 8 at 17:42
  • $\begingroup$ @AdmiralJota Right, but he can lie about which one he would use. $\endgroup$ – Trenin Oct 8 at 18:33
  • 1
    $\begingroup$ @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. $\endgroup$ – Admiral Jota Oct 8 at 22:00
  • $\begingroup$ @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.) $\endgroup$ – Michael Oct 9 at 1:55
  • 1
    $\begingroup$ @AdmiralJota Thats a good point, lettme change that real quick $\endgroup$ – Michael Oct 9 at 2:07
19
$\begingroup$

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.
So instead, you ask the hypothetical "What would you have answered, if I had asked you that?" To lie about yesterday's answer, they must point to their own key, because anything else would be telling the truth.

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

$\endgroup$
  • 1
    $\begingroup$ I don't see your logic. Rot13(Jul jbhyq gur yvne unir gb cbvag gb gur qvssrerapr xrl?) $\endgroup$ – Sinh Oct 7 at 8:53
  • $\begingroup$ @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.) $\endgroup$ – Deusovi Oct 7 at 8:57
  • 1
    $\begingroup$ @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.) $\endgroup$ – Deusovi Oct 7 at 15:09
  • 4
    $\begingroup$ @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". $\endgroup$ – Deusovi Oct 7 at 16:12
  • 4
    $\begingroup$ @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. $\endgroup$ – Deusovi Oct 7 at 20:18
2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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.) $\endgroup$ – enjayem Oct 8 at 7:51
  • 3
    $\begingroup$ You missing the "You can only ask one specific question to both guards." condition. $\endgroup$ – Sinh Oct 8 at 15:15
  • $\begingroup$ Ah, I read it as one question to each guard. $\endgroup$ – enjayem Oct 8 at 16:27
2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ welcome to Puzzling, you seem to have a right ideal but maybe I really need to clarify more. $\endgroup$ – Sinh Oct 8 at 15:52
  • $\begingroup$ 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 :( $\endgroup$ – Joe DF Oct 8 at 20:42
  • $\begingroup$ @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. $\endgroup$ – Loduwijk Oct 9 at 14:39
  • $\begingroup$ @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. $\endgroup$ – Loduwijk Oct 9 at 14:42
  • $\begingroup$ @Loduwijk makes sense, thanks :) $\endgroup$ – Joe DF Oct 9 at 18:45
0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Trenin Oct 7 at 13:56
0
$\begingroup$

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?"

$\endgroup$
  • $\begingroup$ @Loduwijk My answer unlocks both locks. What you say is only true if both guards are closest to the same door. $\endgroup$ – David J. Oct 8 at 16:29
  • $\begingroup$ @DavidJ. so same logic and wording as Deusovi♦ then. well I glad you got it. $\endgroup$ – Sinh Oct 8 at 16:53
  • $\begingroup$ @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. $\endgroup$ – David J. Oct 8 at 16:58
-1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Can you explain why this answer works? Answers without explanations are usually deleted. $\endgroup$ – Deusovi Oct 9 at 5:45
  • $\begingroup$ 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. $\endgroup$ – John Oct 9 at 10:16
-1
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ 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 $\endgroup$ – Sinh Oct 8 at 15:12

protected by Community Oct 8 at 15:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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