Need help building an efficient, comprehensive search algorithm

There are 10 buttons. These buttons can unlock the lock when pressed in the correct order (5 clicks in sequence). Each press of the button starts an unlock test.

Example: “password” is 123456, and I press the buttons 0 1 2 3 4 5 6 I will unlock the lock from the 6th button.

I need to develop an algorithm that most effectively uses all possible combinations (i.e., I need to press the minimum number of buttons).

I can interpret the button number as a number and the number of the pressed button in the sequence as a digit position, and then try all 99999 combinations in an attempt to unlock the lock, but I think there is a more efficient algorithm for this.

Is there anything you can do to optimize this search?

+3
source share
1 answer

To optimize a brute force attack on a block, you can use De Bruijn sequences .

The sequence can be used to reduce brute force attacks on a code lock similar to a PIN code that does not have an enter key and accepts the last n digits entered. For example, a digital door lock with a 4-digit code would have B (10, 4) solutions with a length of 10,000. Therefore, to open the lock, only no more than 10,000 + 3 = 10,003 are needed (since the solutions are cyclic). For each code individually, 4 × 10,000 = 40,000 presses would be required.

+6
source

Source: https://habr.com/ru/post/1444138/


All Articles