This question already has an answer here:

A friend of mine whom I have repeatedly tried to visit has upgraded his house‘s security system. Instead of using doorkeys which were quite easy to borrow, he‘s using one of these fancy new electric keys to show of his wealth.

enter image description here

It‘s not as easy to visit him now. To make it a surprise visit, I don’t want to ring the doorbell. I‘ve tried to convince him to let me know the code as well, but for some reason he‘s a bit reluctant.

The new security system is all fancy: He can enter many digits, and the keypad will keep listening and unlock if the correct sequence has been part of the typed stream. Dunno why someone would invent stuff like this. It just makes life a lot harder as it is impossible for me to observe the actual sequence.

I‘ve been trying around for a bit and I‘ve found a loophole however: The maximum number of digits entered is not capped. If I therefore enter all possible combinations of 4 and press enter, the door will unlock and won’t trigger brute-force prevention.

Now, typing in 94 different combinations (or 4 • 94 digits) will take me too long. But here‘s the catch: The 6-digit stream 0 1 2 3 4 5 will in fact check 3 possible sequences at once: 0 1 2 3, 1 2 3 4 and 2 3 4 5.

How many digits will I need to enter at least?


marked as duplicate by Jaap Scherphuis, Narusan, Community Aug 31 '18 at 11:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Well, I don't know if this is correct, because I found it too simple. There are four such $6$ digit streams that can exist (because the first one ends in $5$ and the last one ends in $9$, and $9-5=4$.) Thus we now have $6\times 3 = 18$ possible sequences checked. Now we do $4\times 9^4 - 18$...? That doesn't involve combinatorics, though, so I'm probably wrong.. Is the sequence 0 1 2 3 4 5 the only $6$ digit stream with this checking property? $\endgroup$ – Mr Pie Aug 31 '18 at 11:36