Created
October 15, 2017 23:20
-
-
Save kira924age/17c34531eedb2d5cfdc5e0cb364e7347 to your computer and use it in GitHub Desktop.
シーザー暗号(AOJ0017)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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