An electronic lock can be opened by entering three numbers from $\{0,1,2\}$ and this independent from what we enter before. For example if the correct password is $012$, then $11012$ will open the lock. The question is how long the minimum sequence of numbers that open for sure the lock.\
I have tried to write the problem as a graph problem, in fact there are $27$ possibilities for the correct password. Let consider the oriented graph with vertices the set of possible passwords and $(xyz, tuv)$ is an edge in the graph if $xyz \neq tuv$ and $y = t,~ z = u$. I claim that to answer the problem it is enough to find the length of a shortest path which goes through every vertex. I tried to find an Hamiltonian path, but I did not find a good algorithm to check if one exist (the problem of finding the hamiltonian path is NP-complete). Does any one have a suggestion to solve this problem ?