-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpellingBeeCreateBulk.py
186 lines (109 loc) · 3.39 KB
/
SpellingBeeCreateBulk.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import enchant
from itertools import permutations
import datetime
import random
print("")
quan = input("How many puzzles shall the code create try for you? Only puzzles with more than 20 possible answers will be saved: ")
quant = int(quan)
print("One moment, please.")
print("")
for bulk in range(quant):
right_now = datetime.datetime.now().isoformat()
tlist = []
for i in right_now:
if i.isnumeric():
tlist.append(i)
tim = ("".join(tlist))
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"]
sublst = []
for x in range(26):
ctr = random.randrange(10)
if ctr < 5:
vch = random.randrange(6)
letch = vowlst[vch]
if ctr > 4:
cch = random.randrange(20)
letch = conlst[cch]
if letch not in sublst:
sublst.append(letch)
oplst = []
for x1 in range(7):
astr = sublst[x1]
oplst.append(astr)
x2 = random.randrange(7)
keyletr = oplst[x2]
biglst = []
for elem in oplst:
for x in range(2):
biglst.append(elem)
print("")
print(oplst)
print(keyletr)
print("")
print("This may take a moment.")
print("")
print("Here are the solutions, if there are any:")
print("")
print("Check for modern parlance. Some may not appear in NY Times word list:")
print("")
wdlst = []
worm = list(permutations(biglst, 4))
for elem in worm:
astr = ""
for wor in elem:
astr += wor
if d.check(astr) and astr not in wdlst and keyletr in astr:
print(astr)
wdlst.append(astr)
worm = []
worn = list(permutations(biglst, 5))
for elem in worn:
astr = ""
for wor in elem:
astr += wor
if d.check(astr) and astr not in wdlst and keyletr in astr:
print(astr)
wdlst.append(astr)
worn = []
woro = list(permutations(biglst, 6))
for elem in woro:
astr = ""
for wor in elem:
astr += wor
if d.check(astr) and astr not in wdlst and keyletr in astr:
print(astr)
wdlst.append(astr)
woro = []
#worp = list(permutations(biglst, 7))
#for elem in worp:
#astr = ""
#for wor in elem:
#astr += wor
#if d.check(astr) and astr not in wdlst and keyletr in astr:
#print(astr)
#wdlst.append(astr)
#worp = []
print("")
print(wdlst)
print("")
if len(wdlst) > 20:
titstr = "SpellingBeeCreation." + tim + ".txt"
outfile = open(titstr, "w")
outfile.write ("A Tenable Spelling Bee Creation." + '\n' )
outfile.write ("" + '\n' )
outfile.write ("Time: " + tim + '\n')
outfile.write ("" + '\n' )
for elem in oplst:
outfile.write(elem + ",")
outfile.write('\n')
outfile.write (keyletr + '\n' )
outfile.write ("" + '\n' )
for elem in wdlst:
outfile.write(elem + '\n')
outfile.close()
print("")
print("See the output document in the same folder as your code.")
print("")
## THE GHOST OF THE SHADOW ##