-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path23.py
44 lines (34 loc) · 1014 Bytes
/
23.py
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
import this
def main():
hint = "va gur snpr bs jung?"
first_step(hint)
hint2 = "in the face of what?"
second_step("va gur snpr bs")
def first_step(hint):
rot13(hint)
def rot13(s):
result = ""
for c in s:
if c.isalpha():
ord_c = ord(c)
ord_c_plus_13 = ord(c) + 13
if ord_c >= ord("a") and ord_c <= ord("z"):
if ord_c_plus_13 > ord("z"):
c = chr(ord_c_plus_13 - 26)
else:
c = chr(ord_c_plus_13)
elif ord_c >= ord("A") and ord_c <= ord("Z"):
if ord_c_plus_13 > ord("Z"):
c = chr(ord_c_plus_13 - 26)
else:
c = chr(ord_c_plus_13)
result += c
return result
def second_step(hint2):
this_content = this.s
lines = this_content.split("\n")
for line in lines:
if hint2 in line.lower():
print(rot13(line))
if __name__ == "__main__":
main()