That sounds similar to the concept of Gray code [0].
For electronic locks, there is a similar method that allows you to try a 4-digit code for each key press [1].
[0] https://en.wikipedia.org/wiki/Gray_code [1] http://alvaray.org/brute-forcing-pincode-keypads-using-combi...