Optimal algorithm for code cracking
Hi! I've thought of a problem concidering door codes. A door code consists typically of 4 digits, i.e. any number between 0000 and 9999. When I enter 5 digits, for instance 1 2 3 4 5, I test two codes if they match the correct code, namely 1 2 3 4 and 2 3 4 5. For every new digit I enter, I test the code for this digit combined with the three preceding digits. I've wondered what the optimal way of choosing my entered number sequence could be, namely the least total amount of numbers in the sequence that has to be used to test all 10000 combinations. If there is a way to construct the sequence so that every new guess is unique, the total amount of numbers in the sequence would be 10003. But using a simple brute force approach, namely entering 0000 0001 0002 etc. I guess several codes multiple times, entering a total amount of 40000 digits. So there has to logically be an optimal way of entering the sequence with a total amount of between 10003 and 40000 numbers. I have thought of the problem a little bit, but I haven't been able to draw any further conclusions. If anyone has an answer to this question, I won't use the algorithm for any bad purposes, I promise (Angel). I'm just interested from a mathematician's point of view.
Thanks in advance.