Using it I noticed that the code was checked on the last 5 things entered. If I were to try every code on the keypad, I simple answer would be to start from 00000,00001,00002... BBBBB.
However, that would mean that time was wasted in the process. Consider someone typing 123456789 on the keypad.
In this case, if the door doesn't open, we know that the following codes are invalid:
What I'm looking for is an algorithm, or at least the name of, to find the path with the fewer key presses.
I'm not looking for a "clever way" of guessing the code, as in look at what digits are dirty.