54 lines
1.5 KiB
TeX
54 lines
1.5 KiB
TeX
\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
|
|
previous inputs.\hspace{-0.5ex}\footnotemark{} For example, if the correct code is \text{10}, the lock will open
|
|
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}
|
|
|
|
|
|
\problem{}
|
|
Consider the same lock, now set with a three-digit binary code.
|
|
\begin{itemize}
|
|
\item How many codes are possible?
|
|
\item What is the shortest sequence that is guaranteed to unlock the lock? \par
|
|
\hint{You'll need 10 digits.}
|
|
\end{itemize}
|
|
|
|
\begin{solution}
|
|
\begin{itemize}
|
|
\item $2^3 = 8$
|
|
\item \texttt{0001110100} will do.
|
|
\end{itemize}
|
|
\end{solution}
|
|
|
|
|
|
\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}
|
|
|
|
\vfill
|
|
\pagebreak |