2024-03-20 19:38:35 -07:00
|
|
|
\section{Introduction}
|
|
|
|
|
|
|
|
\example{}<lockproblem>
|
|
|
|
A certain electronic lock has two buttons: \texttt{0} and \texttt{1}.
|
|
|
|
It opens as soon as the correct two-digit code is entered, completely ignoring
|
2024-04-02 21:15:34 -07:00
|
|
|
previous inputs. For example, if the correct code is \text{10}, the lock will open
|
2024-03-20 19:38:35 -07:00
|
|
|
once the sequence \texttt{010} is entered.
|
|
|
|
|
|
|
|
\vspace{2mm}
|
|
|
|
|
|
|
|
Naturally, there are $2^2 = 4$ possible combinations that open this lock. \par
|
|
|
|
If don't know the lock's combination, we could try to guess it by trying all four combinations. \par
|
|
|
|
This would require eight key presses: \texttt{0001101100}.
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
There is, of course, a better way. \par
|
|
|
|
Unlock this lock with only 5 keypresses.
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
The sequence \texttt{00110} is guaranteed to unlock this lock.
|
|
|
|
\end{solution}
|
2024-04-02 21:15:34 -07:00
|
|
|
\vfill
|
2024-03-20 19:38:35 -07:00
|
|
|
|
2024-04-02 21:15:34 -07:00
|
|
|
Now, consider the same lock, now set with a three-digit binary code.
|
2024-03-20 19:38:35 -07:00
|
|
|
\problem{}
|
2024-04-02 21:15:34 -07:00
|
|
|
How many codes are possible?
|
|
|
|
\vfill
|
2024-03-20 19:38:35 -07:00
|
|
|
|
|
|
|
\problem{}
|
2024-04-02 21:15:34 -07:00
|
|
|
Show that there is no solution with fewer than three keypresses
|
|
|
|
\vfill
|
2024-03-20 19:38:35 -07:00
|
|
|
|
2024-04-02 21:15:34 -07:00
|
|
|
\problem{}
|
|
|
|
What is the shortest sequence that is guaranteed to unlock the lock? \par
|
|
|
|
\hint{You'll need 10 digits.}
|
2024-03-20 19:38:35 -07:00
|
|
|
|
|
|
|
\begin{solution}
|
2024-04-02 21:15:34 -07:00
|
|
|
\texttt{0001110100} will do.
|
2024-03-20 19:38:35 -07:00
|
|
|
\end{solution}
|
|
|
|
|
2024-04-02 21:15:34 -07:00
|
|
|
|
|
|
|
%\problem{}
|
|
|
|
%How about a four-digit code? How many digits do we need? \par
|
|
|
|
%
|
|
|
|
%\begin{instructornote}
|
|
|
|
% Don't spend too much time here.
|
|
|
|
% Provide a solution at the board once everyone has had a few
|
|
|
|
% minutes to think about this problem.
|
|
|
|
%\end{instructornote}
|
|
|
|
%
|
|
|
|
%\begin{solution}
|
|
|
|
% One example is \texttt{0000 1111 0110 0101 000}
|
|
|
|
%\end{solution}
|
|
|
|
|
2024-03-20 19:38:35 -07:00
|
|
|
\vfill
|
|
|
|
\pagebreak
|