This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
ProgrammingChallenges/googlerese.py

59 lines
1.3 KiB
Python
Raw Permalink Normal View History

2019-03-28 09:20:40 +00:00
#!/usr/bin/env python3
import sys
#y = a
#h = b
#e = c
#s = d
#o = e
#c = f
#v = g
#x = h
#d = i
#u = j
#i = k
#g = l
#l = m
#b = n
#k = o
#r = p
#z = q
#t = r
#n = s
#w = t
#j = u
#p = v
#f = w
#m = x
#a = y
#q = z
T = ['y', 'h', 'e', 's', 'o', 'c', 'v', 'x', 'd', 'u', 'i', 'g', 'l', 'b', 'k',
'r', 'z', 't', 'n', 'w', 'j', 'p', 'f', 'm', 'a', 'q']
def translate(A):
r = ''
for i in range(len(A)):
c = ord(A[i]) # get ascii code for A[i]
if A[i].isupper(): # If the character is an uppercase letter
tmp = T[c - ord('A')] # T[0] for 'A', T[1] for 'B' and so on
r = r + tmp.upper() # Convert back to uppercase
elif A[i].islower(): # If the character is a lowercase letter
r = r + T[c - ord('a')] # T[0] for 'a', T[1] for 'b' and so on
# Already lowercase, so no conversion needed
else: # otherwise, just append the character as-is
r = r + A[i]
return r
if __name__ == "__main__":
count = int(sys.stdin.readline())
for i in range(count):
A = sys.stdin.readline().rstrip() # Read a line of input stripping the end of
# line character at the end. Needed because print() is going to put a new
# line for us and we don't want two
print('Case #' + str(i + 1) + ": " + translate(A))