-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindromeMaker.py
More file actions
55 lines (34 loc) · 993 Bytes
/
PalindromeMaker.py
File metadata and controls
55 lines (34 loc) · 993 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import enchant
import random
d = enchant.Dict("en_US")
conlst = ["B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Z"]
vowlst = ["A", "E", "I", "O", "U", "Y"]
sollst = []
for fish in range(30000):
wlen = random.randrange(3, 6)
wdlt = []
for x in range(wlen):
ctr = random.randrange(10)
if ctr < 4:
vch = random.randrange(6)
letch = vowlst[vch]
if ctr > 5:
cch = random.randrange(20)
letch = conlst[cch]
wdlt.append(letch)
wordsam = ""
lettot = len(wdlt)
for x in range(lettot):
wordsam += wdlt[x]
for x2 in range((lettot - 1), -1, -1):
wordsam += wdlt[x2]
print(wordsam)
if d.check(wordsam):
if wordsam not in sollst:
sollst.append(wordsam)
print("Correct: ", wordsam)
print("")
print("Some palindromes are:")
print("")
print(sollst)
## THE GHOST OF THE SHADOW ##