219 - combination locks

You would think that locks of the type ¹ shown here had an awfully large number of possible combinations. They do not have anything like as many as you think, and I wrote a set of questions about the associated thinking as long ago as 1995. See the Lower School Q2²  While one starts with 7.5 million possible combinations, one ends up with a very much smaller number of available possibilities, more like 1300. Most of this is because the order in which the keys are depressed makes no difference, as the keys are physically unconnected (in terms of the mechanism), reducing what you at first think is a large number by a factor of 120. However, that also means that multiple depressions of a key don’t affect success; you have to press all of the ‘right’ keys and none of the ‘wrong’ ones. ³

If you’re going to buy one of these locks, go for one with as many codes as you can; I noticed that one of the sub £25 class offers codes of 4-7 length, which often means one fewer than you think as explained above, but having six usable digits from 13 would be a big improvement. I count 4004  codes. 


While working at PMC, I was once in the copying room, protected by such a lock, with another teacher, let’s call him Simon. While we were chattering and copying exam papers, there was a thumping at the door and I opened it to find another teacher, who we will call Mike, failing to remember the code. The mathematician and scientist–myself and Simon–expressed surprise that the incoming history teacher couldn’t remember the code, and without previous discussion I said that he’d remember it as the Battle of Culloden, while Simon added that we meant the last one. Mike’s response, a classic for his subject, was “Not my period”.   And a marked absence of humour. Offers for the maths equivalent? 


However, since the order of buttons matters not, it makes sense that no order matters, so you can push all the buttons at once, or in two tranches as suits you, or any mode at all, as long as the right buttons are pressed. With some of these locks the C (for Clear) is necessary on all occasions; on some it is only necessary if someone has last input a code and not opened the door (failed to open the door in any sense). Once past the single act of C or not-C state, what you might learn is not what the labels are but merely the pattern of fingers. There were several occasions, typically the start of a new term in my many years at that school, where I had no idea what the code was but my fingers remembered the pattern.


An entirely different sort of lock was in use in the boarding house and sadly I have failed to find a picture of any current model of a similar type, but the one pictured will serve for discussion. See the five buttons? Well, a ‘code’ for this allows up to five key depressions where one ‘press’ may include up to five of the five buttons. Imagine you have decided to use two presses; choose up to three for the first press and any of the remainder for the second. Just this particular arrangement gives 180 possibilities. Any ‘wrong’ press prevents access. Failing to press buttons sufficiently simultaneously produced failure, too. As I remember this lock, it was possible to use any button in each press, which increases the possibilities very effectively – just using two (non-zero) presses, you would have (my count) 391 possibilities.

Exercise for those interested, which lock offers more? 


DJS  20170421 
pics c/o Google images


1  Code locks, push button digital locks, keypad locks.


2  Q2.Tim’s Gameboy has been confiscated and he wants it back as fast as possible, even to the point where he is contemplating cracking the combination to the lock on the relevant cupboard. The lock uses a numeric keypad with 14 keys, 0-9, X,Y,Z and C. He has observed just six key depressions when watching the lock be operated and is keen to establish better information.

i) How many different selections are possible from the information so far?[2]

ii) In practice, all users of this type of lock start with C, the cancel key, so in effect only 5 depressions matter. How many of the previous answer can be discarded?[2]

iii) Furthermore, the machinery inside is much simpler than you might expect and cannot tolerate repeated characters. What is the current number of different selections?[3]

iv) Having digested all of this, Tim overhears a teacher commenting that they should have used more letters in the combination. How many ways now?[3]

v) Amazingly enough, the order of characters is immaterial with these locks. Rework the last calculation with this information.[2]

vi) Tim wonders whether his best strategy is to suggest that the code is already known so that it will be changed. If he assumes that when the combination is changed, all the letters will be used, suggest his next course of action[3]


3    

(i)  14 = 7,529,536

(ii)  13 is new total, 371,293, which is not the answer sought.

(iii)  13.12.11.10.9 = 154,440

(iv)  not three letters, probably only one, not none (unless the teacher was a mathematician). One gives 3.10.9.8.7.  Two letters and 3 numbers gives 3.2.10.9.8  So probably 3.10.9.8 (7+2) = 19440

(v) Divide all answers by 5! = 120. So, assuming at least one letter included but not three, (iv) reduces to just 162

(vi)  Use all three letters and none of the previous numbers (four of the unused seven) and order irrelevant  => 3.21.(7.6.5.4)/3!4! = 35. Yes, only 35.   It is likely that many will treat 0 as O and so will act as if there are four letters and nine numbers. A few will treat 1 as I and treat the set as five letters and eight numbers. Knowledge of the personnel involved (and how they think) will determine the ‘best’ attempts at a guess of the new combination.

Classroom discussion (this question was often suppressed since it made it apparently so easy to get past the lock) showed the class that the ‘real’ number of possibilities was the result of choosing 5 from 13 (13C5 = 1287). When you know who (exactly or generically) has chosen the code, you can reduce this hugely. For example, almost everyone will include exactly one letter, reducing you immediately to 3C1 x 9C4 = 378. A very large number of choices will include the 1 as, predictably, so many think ‘date’ when asked for a 4-digit code (and this was before 2000). Indeed, there is other measurement that says that numbers used everywhere are distributed logarithmically, so 30% of all numbers in use start with a 1 (etc). See Benford’s Law. So if you really need to get past one of these locks without destroying it, you don’t need to see very much operation before you have reduced your guess-list to surprisingly few combinations. Conversely, if you’re trying to protect one then your best action is to hide the numeric pad from casual view.


4 13C6 + 13C5 + 13C4 + 13C3 = 1716 + 1287 + 715 + 286 = 4004. I assume that all possible ‘codes’ start with C, so effectively codes are 3-6 characters long, not 4-7.


5  Is it not obviously 1745 and an X for battle? In the end we found a telephone number Mike knew that used only those digits, since he remained uninterested in Culloden. Or said he did. It was probably the betting shop’s number.


6  If teaching at A-level, then some boards offer a large number of possible modules, so the equivalent to ‘period’ would be ‘module’. Probably what results from asking a mechanics question of someone who only teaches statistics, or vice versa. The equivalent of a historian’s ‘period’ must be a mathematician’s specialities, which probably means their applied knowledge, rather than some pure. At PMC (’95–’05) most of us had at some time taught each module. I taught 20 of 21 in the time I was there (’93–’07), missing only the advanced stats coursework-only module (no, beyond S3).


7 Both locks offer 5 buttons. The first one is permitting the choice of 5 from 13, which is 1287 possibilities (yes, that’s all, folks!!). The second offers any possible combination of five, up to five times and, if my memory was right, permits repeated use of a digit: If I am right about that then using only one key and five choices each time gives you 5 = 3125, so many more than the other lock.  If I am wrong and repetition is not possible, then up to five depressions where order matters gives you a problem in counting and a very similar number to the other lock, where I get a total of 1051 – at the moment. Discuss!!

Email: David@Scoins.net      © David Scoins 2018