-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfun.py
More file actions
83 lines (79 loc) · 1.96 KB
/
fun.py
File metadata and controls
83 lines (79 loc) · 1.96 KB
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
#%%
import pandas as pd
import numpy as np
df = np.array(pd.read_csv("wordle.csv"), dtype=str)
#%%
dict1 = {}
for i in df:
for j in i[0]:
if j in dict1:
dict1[j] += 1
else:
dict1[j] = 1
#%%
def nextword(y,yellow,g,green,ignore):
ig = 'T'
while(ig !='F'):
ig = input("Enter letter to ignore: ")
if ig =="F":
break
ignore.append(ig)
temp = []
for i in df:
yel = yellow.copy()
gre = green.copy()
c = 0
b = 0
remo = 0
for z in gre:
if i[0][int(z[1])] == z[0]:
b+=1
for z in yel:
if i[0][int(z[1])] == z[0]:
remo=1
for j in i[0]:
for u in ignore:
if j==u:
remo=1
for k in yel:
if j==k[0]:
c+=1
yel.remove(k)
if c==y and g==b and remo==0:
temp.append(i[0])
print(temp)
max = 0
word = ''
for i in temp:
tmp=0
for j in i:
tmp+=dict1[j]
if tmp>max:
max = tmp
word = i
print(max,word)
print("Best Word: " + word)
y = int(input("Enter number of yellows: "))
yellow = []
for i in range(y):
tmp = input()
yellow.append(tmp)
g = int(input("Enter number of greens: "))
green = []
for i in range(g):
tmp = input()
green.append(tmp)
nextword(y,yellow , g, green,ignore)
def start():
y = int(input("Enter number of yellows: "))
yellow = []
for i in range(y):
tmp = input()
yellow.append(tmp)
g = int(input("Enter number of greens: "))
green = []
for i in range(g):
tmp = input()
green.append(tmp)
nextword(y,yellow , g, green,[])
start()