code creating during live programming at code break party

This commit is contained in:
Simon Pirkelmann 2020-01-28 18:45:31 +01:00
parent 657a447733
commit fdb7b78b24

25
code/fried.py Normal file
View File

@ -0,0 +1,25 @@
import numpy as np
transposes = ['GADSJFEDVAWFYJSGLSGFVELTSWZGKNYGWGKWFZWZJFJZFDLFJKFLLJLESJUVFHMJWKJNWAVSKSHWSWHGWEZWGATVDJLMWWWWODAUUJFTSDFFLSWAAEUFKJQSKJFGYWAAVFVLSSVLJWTVSWJLJFFFZJWLQSAGQFAZEDFSZGDFVSKEJXDLFOZGVKHNGETLLKGKWHJLZLJEXGWDHWAGLJGGOKSLHMSXWAVWGZWEWAAJVSJGWYXUAKXYZVXJGYFDGXMKFASFAAHGDAHYJJZWXWWGWXJZWLHVLDIFJWJWLGALFEWWMAFKZLAWLAZGVHXQSKGZJLLDVWFWAYWFZFVWYFSDDDXMWWAWQQLXZGFYFAVBSALVJDAJGELLGDW', 'BUSYARSCSBFUSOAAHHFCWSVSFFCCVOVAOFHFHSBSSGIDHZOSSHUCWSFPHSSCRFZVBOISPKGACAWFFOSCFCOFRBHFSSVBGBCGVSGVYSROAZAOOHTRGMSKOMVAASRDHBFBOCOVBACKRRSIZADOSMUHSBQKQBGQUHBHSMWBSFZZWWOSSCDBPOGJCHHSCSIHVDBGKCHSSSQIFKASSTFFVCOIVWBTDBGORGSRDCCCBBBOOHRCJWHMBCMFOCMCFOUSHWFCRBRWCBZSJBZCSSHBFBFCRZWZGVWBVSISUBODVDFVHDSGBGQVOFGPSASFWFPHHPHWFVOQAOCORSEBOCCYUHBISIHZOGHAPVVASFBGUBPIAGVSSOACBMVZBZF', 'CHIAACORDGEANPBEEMOTSMERAWSREITMSRLAMAORAASUHESVSIOOSNAEEAAONEGENILNUAOEFENDCRNRERTITGIEVAEBTONPINPOTMNCBMEGPLOISWLHNEEOYTNEHWTTSFYECIRIOARPLYENTBMOGDOORDARRRGLWNGSREEYSNNALRAOESEEOUUHRATIEOEOOUHRRRETINOASODEEKPB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GZNZZZRNRJXACLKVBRUOUVHRIGNLUUYSHREEZZKZXUKZOKORXNTNXBGGVORRXNNSKOGKKAHXTXYUYGNUALAGAIGKLZRNTKXGYETJYIMNUOKURAZYTUKGOIYRYHJZOKGZNJOEGJTXKYGMYCHYONRYOGKBOGORSACKTEKQKOGZNKGUUUTLZNUJVLNYZZKRZJNUSXKGKNXGORRZKKRYCGGZZRGSGUBKOOXOQYYXQTYTOWUZZQUNXBOZZRGIJRLYNXZUTANTNK', 'BWSSOIBRDVWSUVGIUCRVSBADPUZWKIFQGCVOHZGCSBQWWBGCCWGUCBOZHBFOSCSVFHWFGBQRQDPQVCRVUHSCFIUORHGVJVFSRVSOCOSVOWCOVPOHHWSWSAZWCOSBVZFSSMHGHSICVASDJCOCCWWHSVWVBIBZSFUZRSWHASWFZHSSSSOOHHPFOZCROSWBHHWBHOHHHOBFZVZCPPAHPGRWWYVOAGRKVFVVQFFJZMHSSWRVBZBVWCGUBCQABWPHSPCOJSWVBARSBABDCURRQGTZRQHVOGBATVRCZSFWFPSSSVRZVSWFSSFRWHAWZWPVIPHCWBZSVSFOBFSHUFWBWHDSDCCZBIJVASTHASBWHWGVVZORSVVKRHOUOJ']
def compute_frequencies(block):
letter_count = {}
letters = [chr(i) for i in range(ord('A'), ord('Z')+1)]
for l in letters:
letter_count[l] = block.count(l)
return letter_count
def coincidence(block):
compute_frequencies(block)
freq = compute_frequencies(block)
sum = 0
for f in freq:
sum += freq[f] * (freq[f]-1)
kappa = float(sum)/(len(block) * (len(block)-1))
return kappa
for t in transposes:
print("kappa", coincidence(t))
for t in transposes:
d = compute_frequencies(t)
print(chr((ord('E') - ord(d.keys()[np.argmax(d.values())]))%26+65))