\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\setlength{\parindent}{0pt}
\setlength{\parskip}{4pt}

\usepackage[usenames,dvipsnames]{color}
\usepackage{listings}
\lstset{
    language=python,
    basicstyle=\tt\small,
    commentstyle=\color{Green},
    keywordstyle=\color{blue},
    stringstyle=\color{Orange},
    keepspaces=true,
    showstringspaces=false,
    emphstyle=\color{Maroon},
    emph={__name__}
}

\begin{document}

\large
CS 228, HW \#4 \hfill Due: 10/04/2013
\begin{center}
\textbf{Name:} your name here
\par
\textbf{e-ID:} your e-ID here
\end{center}
\hrule
\normalsize

\bigskip
Unless otherwise specified, the exercises listed below are from the textbook \emph{Discrete Mathematics and Its Applications, 7th Ed.}, by Kenneth H.~Rosen. \textbf{Please show all of your work and explain your reasoning; don't just give the final answer.} Submit your \texttt{hw4.tex} and \texttt{hw4.pdf} files via Canvas before 9:00 AM on the due date. As a reminder, late work will NOT be accepted.

\section*{Section 5.1 (page 329)}

\subsection*{Exercise 4, a--d}

\subsection*{Exercise 4, e--f}

\subsection*{Exercise 10, a--b}

\subsection*{Exercise 20}

\section*{Section 5.2 (page 341)}

\subsection*{Exercise 4, a--c}

\subsection*{Exercise 4, d--e}

\section*{Strong Passwords}

\textit{In today's world we need to have a lot of passwords, and some passwords are stronger than others. Ideally, one should use a mix of capital and lowercase letters, punctuation marks, and/or numbers when choosing a password. And the longer a password, the harder it is to crack---I mean, recover.}

\textit{Implement the Python function below, and use it to complete the following table. For each row, compute the number of passwords for the given alphabet size and lengths. Then calculate how long it might take a computer to ``recover'' such a password, assuming it takes 50 ns for each guess. (Hint: You may use Google to convert very large numbers of nanoseconds to days, years, etc.)}

\subsection*{Count Function}

\begin{lstlisting}
def count(asize, minln, maxln):
    """Number of passwords for the given alphabet size and lengths."""

if __name__ == '__main__':
    print count(10, 4, 4)
    # TODO: write more print statements
\end{lstlisting}

\subsection*{Password Table}

\begin{tabular}{c|c|c|c|c}
Alphabet & Min Len & Max Len & \# of Passwords & Crack Time \\
\hline
10 & 4 &  4 &  &  \\
10 & 4 &  8 &  &  \\
36 & 4 &  4 &  &  \\
36 & 4 &  8 &  &  \\
\hline
62 & 6 &  8 &  &  \\
62 & 8 & 16 &  &  \\
95 & 6 &  8 &  &  \\
95 & 8 & 16 &  &  \\
\end{tabular}

\section*{Section 6.1 (page 396)}

\subsection*{Exercises 8, 16}

\subsection*{Exercises 28, 52}

\section*{Section 6.2 (page 405)}

\subsection*{Exercise 32}

\subsection*{Exercise 44}

\end{document}
