\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\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 \#3 \hfill Due: 2/07/2014

\textbf{Name:} your name here

\textbf{e-ID:} your e-ID here

\textbf{Acknowledgement statement:}


\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{hw3.tex} and \texttt{hw3.pdf} files via Canvas before 1:00 PM
on the due date. As a reminder, late work will NOT be accepted.


\section*{Section 4.5 (page 292)}

\subsection*{Exercise 4}

\subsection*{Exercise 16}

\section*{Section 4.6 (page 304)}

\subsection*{Exercise 8}
\textit{Hint: Try running the code from the ``Python 101'' slides.}

\begin{lstlisting}
# paste your python code here
\end{lstlisting}

\subsection*{Exercise 14}

\subsection*{Exercise 24}

\subsection*{Exercise 26}



\section*{Section 2.1 (page 125)}

\subsection*{Exercise 18}
\subsection*{Exercise 20}
\subsection*{Exercise 32}

\section*{Section 2.2 (page 136)}

\subsection*{Exercise 4, a--d}
\textit{Complete this exercise using Python, i.e., write code for sets $A$ and $B$. Include both your code and the answers to parts a--d below.}

\begin{lstlisting}
# paste your python code here
\end{lstlisting}

% don't forget to write your answers

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

\section*{Section 2.3 (page 152)}
\subsection*{Exercise 8, a--d}
\subsection*{Exercise 12}


\section*{Section 2.4 (page 167)}

\subsection*{Exercise 10, b--c}
\textit{Implement each recurrence relation in Python as a recursive function. Then use your code to complete the exercise. The solution for part A is provided as an example. For simplicity, define your functions as \texttt{b(n)} and \texttt{c(n)}.}

\medskip
\textbf{Part A}

\begin{lstlisting}
def a(n):
    if n == 0:
        return -1
    return -2 * a(n-1)

if __name__ == "__main__":
    print "\nPart A\n"
    for i in range(6):
        print a(i)
\end{lstlisting}

$a_n = -1, 2, -4, 8, -16, 32, \ldots$

\subsection*{Exercise 10, d--e}
\textit{Now complete parts d and e, and name your functions \texttt{d(n)} and \texttt{e(n)}. Note that each recurrence relation is defined as $a_n$ in the book, so make sure you don't accidentally call \texttt{a(n)} in your code!}

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

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

\end{document}
