Problem:


Caesar Cipher

In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:

this is a pen

is would become:

uijt jt b qfo

Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".

Input

Input consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters.

You may assume that you can create one decoded text which includes any of "the", "this", or "that" from the given input text.

The number of datasets is less than or equal to 20.

Output

Print decoded texts in a line.

Sample Input

xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.

Output for the Sample Input

this is the picture that i took in the trip.



Sample input:
xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.


Sample output:
this is the picture that i took in the trip.

Submission status: WA: Presentation Error

Solution code:
import sys
def main():
    ex = ["the", "this", "that"]
    lc = [chr(i) for i in range(97, 97 + 26)]
    #lowwer case

    for line in sys.stdin:
        s = line.split()

        for i in range(len(s)):
            a = s[i]
            cnt = 0
            while a not in ex and cnt < 25:
                a = list(a)
                for j in range(len(a)):
                    if a[j] == "z":
                        a[j] = "a"
                    elif a[j] == ".":
                        pass
                    else:
                        a[j] = lc[lc.index(a[j]) + 1]
                hoge = ""
                for j in a:
                    hoge += j

                a = hoge
                cnt += 1
            if cnt != 25:
                break

        for i in range(len(s)):
            a = list(s[i])
            for j in range(len(a)):
                if a[j] == ".":
                    pass
                else:
                    fuga = lc.index(a[j]) + cnt
                    if fuga > 25:
                        a[j] = lc[fuga - 26]
                    else:
                        a[j] = lc[fuga]
            else:
                hoge = ""
                for k in a:
                    hoge += k
                else:
                    s[i] = hoge

        for i in s:
            print(i, end = " ")
        print()
        print()


if __name__ == "__main__":
    main()

Submission status: WA: Presentation Error

Solution code:
# Aizu Problem 0017: Caesar Cipher
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def caesar_decrypt(N, cipher):
    text = ""
    for char in cipher:
        if 'a' <= char <= 'z':
            k = (ord(char) - 97 - N) % 26
            text += chr(97 + k)
        else:
            text += char
    return text


for cipher in sys.stdin:
    for k in range(26):
        decrypted = caesar_decrypt(k, cipher)
        if "this" in decrypted or "the" in decrypted or "that" in decrypted:
            print(decrypted)
            break

Submission status: WA: Presentation Error

Solution code:

import string
import sys

def CaesarCipher():
    
    low=string.ascii_lowercase
    
    for cry in sys.stdin: 
        for i in range(1,27):
            
            dec=cry.translate(str.maketrans(low,low[i:]+low[:i]))
    
            if 'this' in dec or 'that' in dec or 'the' in dec:
                print(dec)
            
                
    
CaesarCipher()

Submission status: WA: Presentation Error

Solution code:
import sys
for s in map(list, sys.stdin.readlines()):
    while True:
        for i, c in enumerate(s):
            char_code = ord(c)
            if 97 <= char_code <= 122:
                char_code = char_code+1 if char_code < 122 else 97
                s[i] = chr(char_code)

        _s = "".join(s)
        if "this" in _s or "the" in _s or "that" in _s:
            print(_s)
            break

Submission status: WA: Presentation Error

Solution code:
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)

Submission status: WA: Presentation Error

Solution code:
import sys
for b in sys.stdin:
 for i in range(26):
  c=''.join([e,chr((ord(e)-96+i)%26+97)][96<ord(e)<123]for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)

Submission status: WA: Presentation Error

Solution code:
import sys
a = "abcdefghijklmnopqrstuvwxyz"
x = str.maketrans(a, a[1:] + a[:1])
for s in sys.stdin:
    while True:
        s = s.translate(x)
        if "the" in s or "that" in s or "this " in s:
            print(s)
            break

Submission status: WA: Presentation Error

Solution code:
import sys
def rp(char,n):
    p=ord(char)+n
    if 97 <= p-n <= 122:
        if p<=122:
            return chr(p)
        else:
            return chr(p-122+96)
    else:
        return char

def find(str):
    for j in range(-25,25):
        l="".join([rp(i,j) for i in str])
        if "this" in l or "the" in l or "that" in l:
            return l

for text in sys.stdin:
    print(find(text))

Submission status: WA: Presentation Error

Solution code:
import sys
def rp(char,n):
    p=ord(char)+n
    if 97 <= p-n <= 122:
        if p<=122:
            return chr(p)
        else:
            return chr(p-122+96)
    else:
        return char

def find(str):
    for j in range(-25,25):
        l="".join([rp(i,j) for i in str])
        if "this" in l or "the" in l or "that" in l:
            return l

[print(i) for i in [find(text) for text in sys.stdin]]

Submission status: WA: Presentation Error

Solution code:
import sys
def rp(char,n):
    p=ord(char)+n
    if 97 <= p-n <= 122:
        if p<=122:
            return chr(p)
        else:
            return chr(p-122+96)
    else:
        return char

def find(str):
    for j in range(-25,25):
        l="".join([rp(i,j) for i in str])
        if "this" in l or "the" in l or "that" in l:
            return l

[print(i) for i in [find(text) for text in sys.stdin] if i]

Submission status: WA: Presentation Error

Solution code:
#! /usr/bin/python

import sys
from string import ascii_lowercase, whitespace

def datasets():
    for line in sys.stdin:
        yield line

hints = ('the', 'this', 'that')

inclement_chars = lambda cs, n: ''.join(
    [succ_char(c, n) 
    if all([c not in case for case in (whitespace, '.', '\n')]) 
    else c 
    for c in cs])

make_picklist = lambda s: [inclement_chars(s, n) for n in range(1, 27)]

def main():
    for problem in datasets():
        picklist = make_picklist(problem)
        for n, candidate in enumerate(picklist, 1):
            if any([case in candidate for case in hints]):
                break
        print picklist[n-1]


def succ_char(c, n):
    succ_ord = ord(c)+n
    z = ord('z')
    if succ_ord > z:
        succ_ord = ord('a') + (succ_ord - z - 1)
    return chr(succ_ord)

if __name__ == '__main__':
    main()

Submission status: WA: Presentation Error

Solution code:
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from string import ascii_lowercase as letters, maketrans

table = maketrans(letters, letters[1:] + letters[:1])
for line in stdin:
    while True:
        line = line.translate(table)
        if 'the ' in line or 'this ' in line or 'that ' in line:
            break
    print(line)

Submission status: WA: Presentation Error

Solution code:
import sys,string
rot1 = string.maketrans("abcdefghijklmnopqrstuvwxyz. ",\
                        "bcdefghijklmnopqrstuvwxyza. ")
for line in sys.stdin:
    while 1:
        if line.count("the") or line.count("this") or line.count("that"):
            print line
            break
        line = line.translate(rot1)