= Caesar cipher
:imagesdir: images
:icons: font
:source-highlighter: rouge
:stem: latexmath

== Task

The messages in link:./ciphertext.txt[this file] are encrypted with the caesar cipher, all messages are seperated with newline. Each line uses a different letter for the caesar-shifting.
Your task is to decrypt all messages. Of course, this can simply be done by brute forcing each line and manually select the assumed semantic correct sentence. However, your task is trying to do the selection of the correct messages automatically.

[TIP]
====
The file link:./english_freq.txt[letter frequencies list] contains the statistical standard distribution of letters for the english language. _The first line corresponds to `A`, the last line corresponds to `Z`._ 
Enhance your Frequency Analyzer and write a function that determines to what extend a given plaintext aligns with the standard distribution for the language. This can be done by using the so called *_chi square_* test: +

stem:[\displaystyle \sum_{i=0}^{k=25}{\frac{(observed_i - expected_i)^2}{expected_i}}] +

In each case, select the plaintext with the lowest score from the _chi square_ test.
====
