-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject2.py
More file actions
37 lines (30 loc) · 833 Bytes
/
Copy pathproject2.py
File metadata and controls
37 lines (30 loc) · 833 Bytes
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
import cmd
import random
def main():
with open('words.txt') as f:
all_words = f.readlines()
all_words = [x.strip('\n') for x in all_words]
s = og_array(5,all_words)
print(s)
print(create_rev_array(s))
print(create_smoosh_array(s))
print(create_decoded_array(create_smoosh_array(s)))
def og_array(n, words):
s = ''
for x in range(n): #og
theword = random.choice(words)
print(theword)
s+= theword
return s
def create_rev_array(s):
revarr = [s[x] for x in range(len(s)-1, -1, -1)] #reverse
return "".join(revarr)
def create_smoosh_array(s):
revarr = create_rev_array(s)
finalarr = "".join([s[x]+ revarr[x] for x in range(len(s))]) #smoosh
return finalarr
def create_decoded_array(s):
decodedarr = [s[x] for x in range(0, len(s), 2)] #decode
return "".join(decodedarr)
if __name__ == '__main__':
main()