24

I'm working as a file manager. My company bought me three safes and assigned me three assistants. I'm busy most of the time and I can't manage the safes myself, so I need to let my assistants access them.

I want to allow all three assistants to open any of the safes independently, without the presence of the other two assistants, but there are only two keys shipped with each safe, so I can't assign a key to each safe to every assistant. I am not allowed to replicate the keys. Is there a way to do it? (Note: Nobody else should be able to open the safes)

iBug
  • 3,166
  • 11
  • 28

2 Answers2

23

Organization:

Let the safes be labeled 1, 2, 3 and their keys respectively be labelled A, B, C. Note that there are two of each key so we have the keys A, A, B, B, C, C. Also, let the A's open safe 1, the B's open safe 2, and the C's open safe 3.

The Setup:

Now, put a single key labelled B in safe 1, a key C in safe 2, and a key A in safe 3. Now, give the other keys A, B, and C to each of the assistants you have (Doesn't matter what order. The assistants are indistinguishable).

The Procedure:

Whenever one assistant wants to open any of the safes, he'll just try his key on each of the safes until he gets it (or if he already knows which one it'll be better). (He's guaranteed to be able to open one of the safes, as you gave one of each type of key to each assistant). Then, he pulls out the key in the safe and opens the next safe and then the next one until he has opened all three. Then, he pulls whatever you want out of it, and returns everything to its original state.

Why it works:

I placed the keys in each safe so that they were each shifted from their original place by one. Hence, each safe contains the key to another safe, and hence by opening a single safe, I am able to open all of the safes.

Tada! Any Questions or Clarifications you want?

NL628
  • 7,490
  • 3
  • 34
  • 77
  • 2
    The "try every safe" part is probably unnecessary as the assistants may know which safes their keys are to. – iBug Mar 21 '18 at 03:48
  • Yep! I was just making it more complete :D I'll fix it if you want! Ok done, fixed it :D – NL628 Mar 21 '18 at 03:50
  • 17
    While highly interesting as a puzzle, the real world situation frightens me. Three humans, forced to perform an annoying task of opening unnecessary safes, and being taught to lock safe keys into safes? I'll give it six months before one of the safes has both of its keys locked inside it. – Bass Mar 21 '18 at 04:18
  • @Bass Exactly. I prefer buying a bigger safe and putting all my files in it :D – NL628 Mar 21 '18 at 04:19
  • 2
  • @Bass FWIW somewhere I used to work did something like this where one safe had the key to another in it so only the small safe's key was available to get at. Still just as frightening though. – TheLethalCipher Mar 21 '18 at 09:13
  • 4
    @Bass If the key is required to lock the safe (no self-locking door), you cannot get stuck with a safe with both keys in it. – Alexander Mar 21 '18 at 09:17
  • This scheme is prone to deadlock. If assistent with key B needs a resource from safe 1, she opens safe 2, takes key C. If then the assistent with key A wants to acquire a resource in safe 3, she can't acquire key B, and will wait for the assistent with key B to be done. If then the last assistant opens safe 3 to aquire key A, none of the assistants can acquire the next key that leads to the resource they want. Of course, at this point all safes are open, so a solution is possible. – Martijn Mar 21 '18 at 14:15
3

The slightly simpler explanation of the arrangement I thought of is to label the assistants as A, B, C, who are each designated as the guardian of one safe, which can then also be referred to as safes A, B, C for simplicity.

Each assistant will carry the primary key for their own safe. Let's call the secondary key for each safe a, b, c.

Then, for everyone to be able to access every safe, we just need to put the secondary keys in the safes A, B, C like this:

A[c]
B[a]
C[b]

Now everyone can open any safe by finding secondary keys in their own safe in a maximum of two steps.
Eg. If C wants to open safe A, she will take the b key from her own safe to open safe B and get the a key.

Edit:

After a little more thought, there is an obvious second solution if the safe labels are fixed:

A[b]
B[c]
C[a]

That leads to the insight that this method will in fact work for any number of 2-key safes, given an equal number of assistants. The number of different permutations of secondary key storage will be n-1, where n is the number of safes, with each assistant needing to open (n+1)/2 safes on average.

Eg. extending it to 4 safes, there are 3 permutations:

   A B C D
   - - - -
   b c d a
   c d a b
   d a b c
Amit Naidu
  • 2,009
  • 13
  • 19
  • 1
    I believe this is the exact same arrangement as mine, but good job finding it still! :D – NL628 Mar 21 '18 at 04:16