Skip to content

Instantly share code, notes, and snippets.

@kira924age
Created October 15, 2017 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kira924age/17c34531eedb2d5cfdc5e0cb364e7347 to your computer and use it in GitHub Desktop.
Save kira924age/17c34531eedb2d5cfdc5e0cb364e7347 to your computer and use it in GitHub Desktop.
シーザー暗号(AOJ0017)
#!/usr/bin/env python2
# coding: utf-8
def caesar(s, n):
d = {}
for c in (65, 97):
for i in range(26):
d[chr(i+c)] = chr((i+n) % 26 + c)
return "".join([d.get(c, c) for c in s])
while True:
try:
encrypt_txt = raw_input()
except EOFError:
break
for i in range(26):
t = caesar(encrypt_txt, i)
if "the" in t or "this" in t or "that" in t:
print t
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment