-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRot13 | 5 kyu
45 lines (45 loc) · 1.46 KB
/
Rot13 | 5 kyu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def rot13(message):
a = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5,
'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10,
'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15,
'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20,
'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25,
'z': 26}
za = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5,
'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10,
'K': 11, 'L': 12, 'M': 13, 'N': 14, 'O': 15,
'P': 16, 'Q': 17, 'R': 18, 'S': 19, 'T': 20,
'U': 21, 'V': 22, 'W': 23, 'X': 24, 'Y': 25,
'Z': 26}
a2 = ['', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y',
'z']
za2 = ['', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y',
'Z']
text = ''
for i in message:
sch = 0
if i in a:
sch = a[i]
for j in range(0, 13):
sch += 1
while sch > 26:
sch -= 26
text += a2[sch]
elif i in za:
sch = za[i]
for j in range(0, 13):
sch += 1
while sch > 26:
sch -= 26
text += za2[sch]
else:
text += i
return text