Homework 6
Due on Dec 9 Friday

For this homework, you only need to submit a Haskell file containing your solution functions. You can start your work from the provided script.

In class, we described histograms, -square test, and index of coincidence over strings that contain only upper-case letters. The following questions ask you to generalize those constructions to strings of both upper and lower case letters.

## 1. Text Sanitization and Histograms

• [1 point] Write a Haskell function sanitize that will filter out all English letters (without changing their capitalization) from its input string.

• [2 points] Write a Haskell function histogram that computes the histogram of a string with respect to a 52-letter alphabet. (You don't need to unify the values by the length of the string)

## 2. Chi-Square Test

• [2 points] Write a Haskell function chi_square that computes the -square value, with respect to a 52-letter alphabet.

• [2 points] Write a Haskell function chi_square_distance to compute the -square distance between any two strings. What is the -square distance between the following two quotes.

From the beginning of Apple’s fight with the FBI, there’s been an inconvenient question: why can’t the NSA just break into the San Bernardino iPhone?

The cryptologic history of the NSA is layed out in several (internal) publications that have been written over the years by NSA historians. In recent years, the NSA has (partly) declassified some of these publications, regarding WWII, the Cold War and some other events.

## 3. Index of Coincidence

• [3 points] Write a Haskell function ioc that computes the index of coincidence for a given string.