Let's say I have a keycode doorlock which accepts 4 digit passcodes. In order to enter, you must type the 4 digits of the passcode in a row, but there is no "Enter", and it doesn't reset after 4 digits. Thus, if you entered "11112222", the lock wouldn't just unlock if the passcode was "1111" or "2222", but also if it was "1112", "1122", and "1222". Given this, what is the most efficient series of digits to enter to go through all possible passcodes?
There is a strong connection between your question and De Bruijn Sequences. The wikipedia link even gives examples and python code for finding these sequences.
The core difference between what you're asking is that De Bruijn sequences are cyclic (subsequences can go "off the end and pick back up at the beginning"). But if you find such a sequence of length $n$ which is minimal, and you are looking at subsequences of length $4$, you could get a non-cyclic sequence of length $n+3$.