\documentstyle[12pt]{report}

\pagestyle{myheadings}
\def\headlineaux{\sc Math 322: C Programming and Unix
\hrulefill
}
\markboth{\headlineaux}{\headlineaux}

\setlength{\textwidth}{6.25in}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}

\newcommand{\assignmentNumber}{1}
\newcommand{\outdate}{1 September, 1994} 
\newcommand{\duedate}{13 September, 1994}

\begin{document}
\begin{titlepage}\begin{centerline}{\Huge \framebox{Burt Rosenberg}}
\end{centerline}\end{titlepage}

\section*{Problem Set \assignmentNumber \hfill{\parbox{3in}
    {\small\sc\begin{flushright} Out: \outdate
     \\ Due: \duedate\end{flushright}}}}


\subsection*{Goals}

To review arrays, files and the handling of characters and text.

\subsection*{Reading Assignment}

Read Chapters 1 and 2 from {\sc A Book on C.}

\subsection*{Programming Assignment}

\begin{enumerate}
\item
Write a program that counts the number of appearances
of each letter {\em a} through {\em z} in an input text.
Print out a table showing the frequency of each letter,
that is, the ratio of the letter's occurrences to the
total number of letters in the text.

Upper case letters and lower case letters are not to be 
distinguished: an {\em A} is counted the same as an {\em a}.
Any character which is not a letter, for instance,
a digit, a space, a punctuation mark, is ignored.

\item A simple cryptographic protocol is called the
{\em Caesar Cipher,} named after the Roman Emperor and inventor
of the Caesar Salad. 
The two correspondents must first agree upon a small integer $k$.
Before the secret message is sent,  it is turned into {\em ciphertext}
by shifting each letter forward in the alphabet by $k$ places.
When received, the ciphertext is turn back into {\em plaintext}
by shifting each letter backwards by $k$ places.
To shift beyond {\em z}, consider the alphabet as a ring of
characters, so that the next letter after {\em z} is {\em a}.
For instance, the encoding
of {\em sneeze}, for shift value $3$, is {\em vqhhch}.

A Caesar Cipher is a very easy cipher to break. It is the ease-dropper's
task to determine the secret value of $k$ by looking
only at the ciphertext.
The frequency of letter use in English has a very distinctive
shape and is not hidden by this cipher, it is only shifted over.
The ease-dropper can determine $k$ by making graphs of the letter
frequencies in the ciphertext and in a sample English language
text and sliding them across each other until there is a good match. 
This will give away the correspondence between ciphertext and
plaintext letters.
Often the ease-dropper must try a few likely possibilities before
succeeding.

Use your program on an English language text of your choosing
to get sample frequency counts for letters, and use these to
decode the following hilariously funny joke:
\begin{verbatim}
   doha kv fvb jhss h ulhy zpnoalk kpuvzhby? h kvfvbaopurolzhdbz!
\end{verbatim}
If there are no word breaks, it becomes harder, but longer text
gives a more decisive frequency count. Try this important news item. 
\begin{verbatim}
pybio kbcdr opyvu csxkv sddvo dygxs
xdohk czbyz yconx kwocd ydros bvymk
vzycd yppsm oyxol iyxod rozyc dkvco
bfsmo botom dondr owkvv psxkv visxo
sqrdo oxrex nbonk xnosq rdidr oigby
dokps xkvpe bsyec voddo bdydr oboqs
yxkvz ycdwk cdobg sdrdr scmvy csxqp
bywxy gyxmy xcsno becxk wovoc ckxnc
ydroi nsnxk wovoc cdohk csckl yeddg
oxdiw svocx ybdrg ocdyp kecds xtecd
yppyp xkwov occby kn
\end{verbatim}
\item
{\sc Extra Credit:} A Vigen\`ere cipher works as follows:
A keyword is chosen, say ``ignatz''. It is endlessly repeated,
\[{\tt ignatzignatzignatz} \ldots\]
The text is written underneath the repeating string, and
each letter is shifted according the the letter in the 
string. That is, if ``a'' falls under ``i'', then ``a''
becomes ``i'', if ``b'' falls under ``i'', then ``b'' becomes
``j'', if ``c'' falls under ``t'', then ``c'' becomes ``v''.
Write a program that automatically breaks Vigen\`ere ciphers.
\end{enumerate}


\end{document}
