# Digicode cracking problem

I have a digicode to enter my home. Let's say the combination is 4432.

This morning, I got it wrong, so I retyped it, and the door opened. But the final code I entered was 4424432. That made me realize that the door opens for any sequence of number containing 4432, in fact any sequence that matches [0-9]*4432[0-9]*. And I asked myself the question: what is the optimal way of cracking it, if you don't know the code ?

To simplify, let's assume a couple of things:

• The combination is a sequence of 4 digits.
• All combinations are equiprobable.

If you could submit one code at a time. For example, if you have to press 4 buttons then press "submit", the approach would be a simple bruteforce. You try out all the 10000 solutions one by one: 0000, 0001, 0002 etc...

But given the fact that 2 combinations somewhat overlap, you can optimise your search, and I'm interested about what is the best optimisation you can do.

-

## migrated from stats.stackexchange.comAug 14 '12 at 12:56

This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.

De Bruijn sequence? – Jyrki Lahtonen Aug 14 '12 at 13:01