Problem of the Day
A new programming or logic puzzle every Mon-Fri

Gift Exchange

Those with a CS background should recognize this problem. Enjoy your weekend!

Tom wants to give his fiance Sally an expensive gift, but they are currently thousands of miles apart. The big problem is that everything sent through the mail is stolen unless there is a lock put on it. Both Tom and Sally have plenty of locks and keys but they don't have any of the same locks or keys.

How can Tom send Sally the gift without it getting stolen?

Permalink: http://problemotd.com/problem/gift-exchange/

Comments:

  • Anonymous - 10 years, 9 months ago

    Tom send two separate locked mails. One with gift with LockT1 and other mail with the KeyT1(key to Lock1), locked with LockT2. Both the envelops reach sally.

    Sally puts a new lock LockS1 together with already placed LockT1 on the second envelop and sends it back to Tom. He unlocks LockT2 and send the envelop back to Sally.

    Sally now unlocks LockS1 with KeyS1. This yields KeyT1 which can then open LockT1 reviling the gift.

    reply permalink

  • Anonymous - 10 years, 9 months ago

    I don't understand the use of the first envelop. Why not just replace KeyT1 with the gift?

    reply permalink

  • Anonymous - 10 years, 9 months ago

    Your adding an unnecessary step. Assuming that a lock within a lock can be opened so long as you have the key then there is no need for Tom to send Sally his key.

    He simply places the gift in LockT1 and sends it to Sally. Sally will then add her LockS1 to LockT1 and send the package back to Tom. Tom will then use his KeyT1 to unlock LockT1 and send the envelope back to Sally. Then Sally simply needs to use her KeyS1 to unlock the remaining LockS1 and receive her gift.

    reply permalink

  • Anonymous - 10 years, 9 months ago

    If the lock can be locked without the key(like most of them) sally can send an opened lock in a mail, and Tom just locks the present.

    reply permalink

  • Anonymous - 10 years, 9 months ago

    Don't the lock will get stolen before it reach Tom?

    reply permalink

  • Anonymous - 10 years, 9 months ago

    As stated in the problem: "...everything sent through the mail is stolen unless there is a lock put on it.." . So if Sally sends an opened lock in the mail and the mail is not locked, then the mail will be stolen. So this approach, according to the problem, would fail.

    reply permalink

  • Anonymous - 10 years, 9 months ago

    Ez. Tom sends Sally the gift using one of his locks. When it reaches Sally, she breaks the lock, allowing her access to her gift.

    reply permalink

  • Anonymous - 10 years, 9 months ago

    Perhaps I don't understand the analogy properly; but to answer this from public key cryptography perspective: Sally publicly gave away a diagram to make her lock (she is the only person to have the key for this lock and is unknown to others how to make this key). Tom creates the lock and sends his gift with this lock. Sally receives it and unlocks it; and she's extremely happy with the ticket to meet her fiancee.

    reply permalink

Content curated by @MaxBurstein