This is related to Hacking an electronic keypad.
You are a spy trying to break into an enemy facility. The back door is protected by an electronic keypad lock. You know that this particular lock is opened by a three-digit code only and you also notice that luckily the keypad only consists of 4 keys ($1$, $2$, $3$ and a $cancel$ button). It sounds pretty easy right? Only $3^3=27$ combinations.
Moreover, this electronic keypad is very special - it also counts the key entrances in the reverse, cyclic and circular orders:
- Reverse Acceptance: Let's say the actual code is $321$. If you enter $123$, the keypad considers you have entered $321$ too.
- Circular Acceptance: Let's say the actual password is $212$. After you press $1$, it will try to read the code until it reaches 3 digits in total and it will consider you have entered $111$ because of circular reading until 3 digit read so it will not open yet, then pressing $2$ will cover $121$, $212$ as well, so the lock will open. If we had added $3$ at the end, the reading principle would become like this:
1 / \ 2 - 3
and the machine will try to start reading straight/reverse and circular from every digit, so the possible combinations will become then: $123$,$132$,$321$,$312$... etc.
- Cancel Key: If you press the cancel key, it will reset all previous key presses.
Note that, for counting 3 digit codes, the machine counts starting at every digit entered while using reverse or circular reading the codes.
So:
At least how many times you need to press the keys (including $cancel$) on the keypad to guarantee to open the door?