Need help in building efficient exhaustive search algorithm
There are a 10 buttons. These buttons can unlock the lock if pressed in correct order (5 presses in sequence). Every button press triggers unlock check. Example: "password" is 123456 and I press buttons 0 1 2 3 4 5 6 I unlock the lock from 6th button press. I need to design algorithm that tries all possible combinations in the most efficient way (i.e. minimum amount of buttons should be pressed). I can interpret button number as digit and number of pressed button in sequence as digit position and then try all 99999 combinations in attempt to unlock the lock but I feel that there is a more