-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
77 lines (56 loc) · 1.73 KB
/
functions.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def reverse(text):
return text[::-1]
def un_reverse(text):
return text[::-1]
def if_function(text):
new_text = []
for c in text:
if int(c / 2 - 0.5) == int(c / 2):
new_text.append(c // 2)
else:
new_text.append(c * 2)
return new_text
def new_if_function(text):
new_text = []
for c in text:
x1 = c // 2
x2 = c * 2
if int(c / 2 - 0.5) == int(c / 2):
new_text.append(x1)
else:
new_text.append(x2)
return new_text
def check_if(text):
if if_function(text) == list(map(ord, "36ÂÎö:4bæ¾Òæ¾36\x1aÎú")):
print("Yay! Correct!")
else:
print("Sorry, that's not right. :(")
def plus(text):
return ''.join(
list(map(chr, list(map(lambda x: x + 1, list(map(ord, text)))))))
def un_plus(text):
return ''.join(
list(map(chr, list(map(lambda x: x - 1, list(map(ord, text)))))))
def shuffle(text): # odd number of characters only
new_text = []
for i in range(len(text)):
new_text.append(text[(283 * i + 3) % len(text)])
return new_text
def un_shuffle(text):
old_text = ['a'] * len(text)
for i in range(len(text)):
old_text[(283 * i + 3) % len(text)] = text[i]
return ''.join(old_text)
def rewrite(text):
new_text = []
for i in range(len(text)):
new_text.append(text[(283 * i + 3) % len(text)] + i)
return new_text
def un_rewrite(text):
old_text = ['a'] * len(text)
for i in range(len(text)):
old_text[(283 * i + 3) % len(text)] = chr(ord(text[i]) - i)
return ''.join(old_text)
if __name__ == "__main__":
list(map(ord, "flag{s0lv3d}"))
print(shuffle(rewrite(list(map(ord, "flag{s0lv3d}")))))