diff --git a/code/ciphertext.txt b/code/ciphertext.txt new file mode 100644 index 0000000..4a4858a --- /dev/null +++ b/code/ciphertext.txt @@ -0,0 +1 @@ +Tg stgsf Djia tf Ejnsg, nm dseqs stg Ajeetq. Gtiaq tg stgsf csriaqsg, piafrqythsg Djia, vj sp gmia Fjnso otsiaq rgn Vrofytkcsd ujg nsg Vmsgnsg asomeamsghsg, rgn mria gtiaq tg stgso qojibsgsg, bmadsg Pmgnhores jags Qtpias rgn Pqrsads, vj fmg ptia yrf Sppsg atgpsqysg bjsggqs: gstg, nmp Djia vmo stgs Ajeetqajsads, rgn nmp astppq, sp vmo psao bjfcjoqmesd. diff --git a/code/frequency.py b/code/frequency.py new file mode 100644 index 0000000..9d2e717 --- /dev/null +++ b/code/frequency.py @@ -0,0 +1,27 @@ +import matplotlib.pyplot as plt + +f = open('ciphertext.txt') + +ciphertext = f.readline().upper() + +letter_count = {} + +letters = [chr(i) for i in range(ord('A'), ord('Z')+1)] + +for c in letters: + letter_count[c] = 0 + +for c in ciphertext: + if c in letter_count.keys(): + letter_count[c] += 1 + +print(letter_count) + +x = range(0,26) +y = [letter_count[chr(ord('A')+i)] for i in range(0,26)] + +plt.bar(x, y) +plt.xticks(x, letters) # Set locations and labels + + +plt.show()