I'm sure there's an optimal sequence of keypresses that tests all 10000 codes in something like 30,000 keypresses rather than the naive 40,000.
I'm sure there's an optimal sequence of keypresses that tests all 10000 codes in something like 30,000 keypresses rather than the naive 40,000.
https://en.wikipedia.org/wiki/De_Bruijn_sequence
It seems that you can do it in 10003 key presses. Calculation for this this exact example is in the Wikipedia page.
This made me uncomfortable when I was selling a house, so naturally I wrote some code to generate a string of digits that would cover the full solution space most efficiently.
Armed with this "master key", I had the lockbox open in negligible time. Honestly I think it was just a few minutes, and I was about halfway through the string.
This let me put the key out only when a showing was happening, and I brought the lockbox to the closing, which baffled the real estate agent.