# 4 digit door entry systems

Our office block is protected by a keypad. The entry code is 4 digits long and the pad has the numbers 0 to 9. Now I noticed the other day, and have discovered that this is quite common with these entry systems, that there is no kind of punishment for getting the number wrong. The pad just looks at the last 4 numbers you have typed.

So you can try numbers over and over at quite a high speed till you get the right four, with no delay enforced for getting anything wrong.

So I’m thinking, could you make a small device with 10 solenoids that tried every number in turn? How long would it take?

There’s 10,000 four digit combinations, or 40,000 keypresses, but as it only looks at the last four digits we can seriously shorten that.

For example if I type 012345 then I’ve just tested 0123, 1234 and 2345. I looked about a bit and found something called de Bruijn sequences. A de Bruijn sequence is the shortest sequence containing all possible words of a certain length.

So it turns out that the shortest sequence is 10,003 digits long. Googling about some more I discovered this site, which generates de Bruijn sequences for you.

Say for example the keypad can manage 10 digits a second then we need 1000 seconds to try every possible combination. That’s roughly 15 minutes. Not bad down from an hour but I’m sure it could be faster.

Now, the person who regularly resets the code on my building is obviously fond of history, as the codes are always famous dates.We have not, for example, ever had a code that didn’t start with “1”.

I expect many people come up with a year or a day/month combination when asked to generate a 4 digit code. I wonder how many people pin numbers start with 0, 1, 2 or 3? Given this is there a way to order the sequence to increase the probability of an earlier win?

Humans are rubbish at being random. If we concentrate on years then it would seem to make sense to check 19[0-9][0-9] first or just the first 2000. If we are thinking many people choose day/month combinations such as then we shoud check for [0-3][0-9][0-1][0-9] or for US month/day [0-1][0-9][0-3][0-9].

To test any of this we really need sample data to work on. I reckon we need a sampling of the kind of 4 digits humans would choose, that would be a good start. How to go about gathering that data though?

## 2 thoughts on “4 digit door entry systems”

1. michael says:

Wow thats confusing but interesting

2. jake says:

dude i love u man u r the greatest man thanks a lot, lot, lot, lot,lot,lot,lot.