# Key and lock puzzle

The idea is to place all the yellow keys into the red locks. There is at least one guaranteed way to do this as the locks as created from the keys and then 'blurred' by adding extra gaps. Solutions however are not (yet!) unique - I haven't figured out how to add gaps without getting more than one solution.

The full white spaces in the red locks take the yellow key bits, the half-red squares are blocked.

For example key 1 goes into locks 4 and 8.

• Could you explain a bit more, please, what the boxes and colors mean? Commented Jan 29, 2016 at 15:07
• I assume that one line is one key / one lock and we have to assort each key to one fitting lock? Commented Jan 29, 2016 at 15:11
• @friedemann_bach; in 1!
– JMP
Commented Jan 29, 2016 at 15:15
• While both mine and @friedmann_bach have correct answers, I believe that theirs is superior to mine and should get accepted. Commented Jan 29, 2016 at 16:49
• @BearArmatis; very noble - yours was in first however. i'm waiting to see if there are any others - probably decide tomorrow
– JMP
Commented Jan 29, 2016 at 17:14

I found two solutions.

I numbered the keys and locks from 1 to 9 and built a simple matrix:

A "0" means that the key would not fit into the corresponding lock. A "1" means that the key fits. Then, a -1 means that a key would fit, but that the lock is already occupied by another key.

In the last row you can see how the deduction works. First (1.) I assumed that K3 fits only into L5 and K5, and (2.) K5 only into L4. This (3.) blocks K1 for L4, so it needs to be put into L8, and so on (4. to 7.). Two keys (K4 and K7) and two locks (L2 and L3) remained, which can be put into either of them.

So my solutions would be:

1. K1-L8, K2-L1, K3-L5, K4-L2, K5-L4, K6-L7, K7-L3, K8-L6, K9-L9

and

2. K1-L8, K2-L1, K3-L5, K4-L3, K5-L4, K6-L7, K7-L2, K8-L6, K9-L9

If you organize the keys A-I and the locks 1-9 here is a solution:

A 8, B 1, C 5, D 2, E 4, F 7, G 3, H 6, I 9,

• H doesn't go in 7
– JMP
Commented Jan 29, 2016 at 15:34
• You're right, I've revised my answer. Commented Jan 29, 2016 at 15:37