Skip to content

Instantly share code, notes, and snippets.

@mosmeh
Created March 9, 2020 20:22
Show Gist options
  • Save mosmeh/31b07b34297ff4a5393bd45d68e8ef02 to your computer and use it in GitHub Desktop.
Save mosmeh/31b07b34297ff4a5393bd45d68e8ef02 to your computer and use it in GitHub Desktop.
code="""spwwz pgpcjzyp! hpwnzxp ez esp hzcwo zq nzxafepc dntpynp!
nzxafepc dntpynp td l mldtd zq esp xzopcy tyqzcxletzy lyo
nzxxfytnletzy epnsyzwzrj dfns ld mtr olel lylwjdtd, lt, lyo lwdz
nzxafepc rlxp. awpldp pyuzj esp hzcwo zq nzxafepc dntpynp. dpp
jzf lrlty le seea://end.n.etepns.ln.ua/ndmzzv/"""
def rot(c, n):
if 'a' <= c and c <= 'z':
return chr((ord(c) - ord('a') - n) % 26 + ord('a'))
else:
return c
def count_e(n):
count = 0
for c in code:
if rot(c, n) == 'e':
count += 1
return count
counts = sorted([(i, count_e(i)) for i in range(0, 26)], key=lambda x: x[1], reverse=True)
n = counts[0][0]
print(n)
print(''.join(rot(c, n) for c in code))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment