-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordle.py
62 lines (52 loc) · 1.43 KB
/
wordle.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
import enchant
import string
import random
string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
wordguess = ""
knownlet = ""
d = enchant.Dict("en_US")
print("Try Donut and Raise as the first two words, then respond with any green letters, substitute any unkown letters with ?. For example: '?E??R'")
input1 = input()
print("what are the out of place letters?")
input2 = input()
letternum = 0
for v in input1:
if v != "?":
knownlet += str(v)
for x in input2:
if x != "?":
knownlet += str(x)
print("known letters:")
print(knownlet)
e = 1
guesses = []
print("-- SOLVING --")
while e in range(1,13000):
hasallknownlet = True
for i, w in enumerate(input1):
if w == "?":
randomlet = random.choice(string.ascii_lowercase)
# print(randomlet)
wordguess += randomlet
else:
# print(str(w))
wordguess += str(w)
# print(e)
# print(wordguess)
for f in knownlet:
if (f in wordguess) == False:
hasallknownlet = False
if hasallknownlet:
if (wordguess in guesses) == False:
if d.check(wordguess):
# print(wordguess)
# print("hi")
guesses.append(wordguess)
e += 1
print(wordguess)
wordguess = ""
# e += 1
print("-- FINISHED --")
print(guesses)
# print(wordguess)