Enter the maze

Hotel Doors and Keycode algorithms

question marks. image: wwww.istock.com 39391754

A Computer Science Education trains you to think in a different way - a kind of thinking called "Computational Thinking". Much of computer science is about problem solving, but solving problems that have a particular character. They tend to be problems of the kind: Come up with a sequence of steps (an algorithm) that if followed allow something to be done. Or come up with a way of storing information (a data structure) so that something can be done. Or both. Coming up with those kinds of solution are Computational Thinking skills. The problems can be about anything: even as simple as how to design a door. Here is a problem suggested as a cs4fn puzzle by Prof Harold Thimbleby of the University of Swansea. It is a real problem though, not just a puzzle.

You are revamping a hotel and are introducing new card locks rather than ones with keys. The current key system has a problem. Sometimes guests leave with the keys, or lose them. Then if you check-in a new guest to that room, you don't know for sure that an intruder can't get in using an old key. Changing physical locks all the time would cost too much.

Electronic cards seem to be much better. Each card has a secret code number on it. The code is like a PIN used with bank cards (though a lot longer). If the code matches the door, then you can get in. You can give each person a new card with a new code set by the computer when you check the person in. Ahhh, but there is the problem! Somehow the door needs to know what the new code is each time a new guest checks in. That could be every night.

Your first thought is to connect all the doors to a computer network. That would work. Whenever you set a new code on a key, you also send a message over the network to the appropriate door telling it its new number. Trouble is that turns out to be very expensive - every door becomes a much more complex computer that must be connected to a network somehow. You also now you have to be sure that the network of doors can't be hacked allowing someone to listen for the door codes.

A second idea is that a porter could take a Master key (that is one with a special code all doors know is special) with the new code and unlock the door for the guest the first time, passing the new code on. Problem there is not every guest wants a porter to escort them (some actively refuse) and extra porters actually cost money.

Can you come up with a better way to do it? It must work in a way so that the doors aren't connected to a network in any way. All the new guest has to do is take their new key card. It lets them in from then on. However the previous guest even if they have an old key should not be able to get in. Hotel staff can stay put in reception. Problems to watch out for in your solution - a new guest getting the room mixed up shouldn't lock anyone else out.

There are probably lots of ways to do it (patented presumably and making the inventors lots of money). Read on to find one solution...