My alarm system has a $4$ digit numeric code with keys $0-9$.

Brute force unlock for a typical alarm system would typically require pressing:

  • $0001$ enter
  • $0002$ enter
  • etc.

However to simplify the system there is no enter key. The alarm will unlock if the last $4$ pressed digits match the code, whichever keys were pressed beforehand.

My question is how much does this reduce the effort to brute force search. For example if I type


In only $6$ characters I have tested $3$ possible codes

  • $0123$
  • $1234$
  • $2345$

Is there an elegant way to construct a sequence that visits all possible combinations of $4$ neighbouring digits optimally and brute force unlock the system in a minimum number of key presses. By my reckoning this would be $10003$ key presses.

Does this generalise to different lengths of code and different sets of possible digits.

By all means add some formal set theory terms to any answers though I'm afraid it's been a long time since I did any set theory....



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.