7aaddb3d31
Create a frequency table of alphabetic characters by reading each character in "Alice in Wonderland"; use this frequency table to score cleartext when decoding ciphers. Change-Id: Id322af64d792c15231a1a02794f396c46196c207 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4788 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com> Autosubmit: wpcarro <wpcarro@gmail.com>
23 lines
564 B
Python
23 lines
564 B
Python
import c3
|
|
|
|
content = None
|
|
with open('4.txt', 'r') as f:
|
|
content = f.read().splitlines()
|
|
if not content:
|
|
raise Error("Need content to proceed")
|
|
|
|
xs = []
|
|
for line in content:
|
|
try:
|
|
x = c3.decode_cipher(line)
|
|
if x: xs.append(x)
|
|
except:
|
|
continue
|
|
|
|
freqs = c3.frequency_table()
|
|
print(max(xs, key=lambda x: c3.score(x, freqs)))
|
|
|
|
################################################################################
|
|
# Answer
|
|
################################################################################
|
|
"Now that the party is jumping"
|