Removal of random 'Words' in wordle. Removed solvers.

Signed-off-by: adithyagenie <adithyagenie@gmail.com>
This commit is contained in:
adithyagenie 2023-07-29 20:29:06 +05:30
parent 690abbd798
commit ee9134bfb5
4 changed files with 1 additions and 128 deletions

View file

@ -1 +1,2 @@
windows-curses
mysql-connector-python

View file

@ -1,54 +0,0 @@
words = open("words.txt").read().split("\n")
def partition(word, words):
# Get how many words will remain for each possible response
partitions = []
for a in "MCW":
for b in "MCW":
for c in "MCW":
for d in "MCW":
for e in "MCW":
partitions.append(len(reduce(word, a + b + c + d + e, words)))
return partitions
def reduce(word, result, words):
# word: 5-letter word (lowercase)
# result: 5-letter str consisting of M, C, W (misplaced, correct, wrong)
res = words[:]
for i, s in enumerate(result):
nres = []
for w in res:
if s == "M":
if w[i] != word[i] and word[i] in w:
nres.append(w)
if s == "C":
if w[i] == word[i]:
nres.append(w)
if s == "W":
if w[i] != word[i]:
if not (word[i] in w) or word.count(word[i]) > 1:
nres.append(w)
res = nres
return res
print("WORDLE SOLVER")
print("=============")
# First guess is precomputed
opt = "crate"
result = ""
while result != "CCCCC":
print(opt)
result = input("> ").upper()
words = reduce(opt, result, words)
opt = ""
opt_size = float("inf")
for word in words:
p = partition(word, words)
avg_partition_size = sum(p) / len(p)
if opt_size > avg_partition_size:
opt_size = avg_partition_size
opt = word
# print(p)

View file

@ -1,53 +0,0 @@
words = open("wordle\\words.txt").read().split()
guesslist = []
maxguesses = 6
wantedletters = []
uselessletters = []
correctletters = ["-"] * 5
while maxguesses:
try:
correctguess = input(
"\nEnter correct letter positions (use - for other letters): "
).lower()
uselessguess = input("Enter all incorrect letters without space: ").lower()
wantedguess = input("Enter all letters of incorrect postiions: ").lower()
correctletters = list(correctguess)
for i in uselessguess:
if i not in uselessletters:
uselessletters.append(i)
for i in wantedguess:
if i not in wantedletters:
wantedletters.append(i)
subsetwanted = []
for i in words:
if set(wantedletters).issubset(set(i)):
subsetwanted.append(i)
print("First filter", subsetwanted)
for i in uselessletters:
for j in subsetwanted:
if j.count(i):
subsetwanted.remove(j)
print("Second filter: ", subsetwanted)
print(correctletters)
temp = []
for i in range(len(correctletters)):
for j in range(len(subsetwanted)):
if correctletters[i] == "-":
continue
else:
print(i, j, correctletters[i], subsetwanted[j][i])
if correctletters[i] == subsetwanted[j][i]:
temp.append(subsetwanted[j])
subsetwanted = temp.copy()
print("Third filter: ", subsetwanted)
except KeyboardInterrupt:
print("\n\nThe word was found!")
break
maxguesses -= 1

View file

@ -138,7 +138,6 @@ axial
axiom
axion
azure
Words
bacon
badge
badly
@ -312,7 +311,6 @@ butte
buxom
buyer
bylaw
Words
cabal
cabby
cabin
@ -511,7 +509,6 @@ cutie
cyber
cycle
cynic
Words
daddy
daily
dairy
@ -623,7 +620,6 @@ dwarf
dwell
dwelt
dying
Words
eager
eagle
early
@ -696,7 +692,6 @@ extol
extra
exult
eying
Words
fable
facet
faint
@ -832,7 +827,6 @@ furor
furry
fussy
fuzzy
Words
gaffe
gaily
gamer
@ -948,7 +942,6 @@ guppy
gusto
gusty
gypsy
Words
habit
hairy
halve
@ -1018,7 +1011,6 @@ hydro
hyena
hymen
hyper
Words
icily
icing
ideal
@ -1053,7 +1045,6 @@ islet
issue
itchy
ivory
Words
jaunt
jazzy
jelly
@ -1074,7 +1065,6 @@ jumpy
junta
junto
juror
Words
kappa
karma
kayak
@ -1095,7 +1085,6 @@ knoll
known
koala
krill
Words
label
labor
laden
@ -1183,7 +1172,6 @@ lusty
lying
lymph
lyric
Words
macaw
macho
macro
@ -1291,7 +1279,6 @@ music
musky
musty
myrrh
Words
nadir
naive
nanny
@ -1329,7 +1316,6 @@ nurse
nutty
nylon
nymph
Words
oaken
obese
occur
@ -1371,7 +1357,6 @@ owing
owner
oxide
ozone
Words
paddy
pagan
paint
@ -1513,7 +1498,6 @@ purse
pushy
putty
pygmy
Words
quack
quail
quake
@ -1537,7 +1521,6 @@ quite
quota
quote
quoth
Words
rabbi
rabid
racer
@ -1643,7 +1626,6 @@ rumor
rupee
rural
rusty
Words
sadly
safer
saint
@ -2009,7 +1991,6 @@ sworn
swung
synod
syrup
Words
tabby
table
taboo
@ -2159,7 +2140,6 @@ twirl
twist
twixt
tying
Words
udder
ulcer
ultra
@ -2193,7 +2173,6 @@ usual
usurp
utile
utter
Words
vague
valet
valid