Skip to content

Commit 92ef10a

Browse files
my rot13
1 parent 05bb303 commit 92ef10a

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

Diff for: 23.py

+35-24
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,42 @@
22

33

44
def main():
5-
this_this = first_step()
65
hint = "va gur snpr bs jung?"
7-
second_step(hint, this_this)
8-
9-
10-
def first_step():
11-
return this.s
12-
13-
14-
def second_step(hint, this_this):
15-
hint_ary = hint.split(" ")
16-
len_hint_ary = []
17-
for element in hint_ary:
18-
len_hint_ary.append(len(element))
19-
print(len_hint_ary)
20-
21-
lines_of_this = str(this_this).split("\n")
22-
print(lines_of_this)
23-
len_str_in_line = []
24-
for line in lines_of_this:
25-
str_in_line = line.split(" ")
26-
for str_ele in str_in_line:
27-
len_str_in_line.append(len(str_ele))
28-
print(len_str_in_line)
29-
len_str_in_line = []
6+
first_step(hint)
7+
hint2 = "in the face of what?"
8+
second_step("va gur snpr bs")
9+
10+
11+
def first_step(hint):
12+
rot13(hint)
13+
14+
15+
def rot13(s):
16+
result = ""
17+
for c in s:
18+
if c.isalpha():
19+
ord_c = ord(c)
20+
ord_c_plus_13 = ord(c) + 13
21+
if ord_c >= ord("a") and ord_c <= ord("z"):
22+
if ord_c_plus_13 > ord("z"):
23+
c = chr(ord_c_plus_13 - 26)
24+
else:
25+
c = chr(ord_c_plus_13)
26+
elif ord_c >= ord("A") and ord_c <= ord("Z"):
27+
if ord_c_plus_13 > ord("Z"):
28+
c = chr(ord_c_plus_13 - 26)
29+
else:
30+
c = chr(ord_c_plus_13)
31+
result += c
32+
return result
33+
34+
35+
def second_step(hint2):
36+
this_content = this.s
37+
lines = this_content.split("\n")
38+
for line in lines:
39+
if hint2 in line.lower():
40+
print(rot13(line))
3041

3142

3243
if __name__ == "__main__":

0 commit comments

Comments
 (0)