awacke1 commited on
Commit
c754616
β€’
1 Parent(s): 82cfe02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -14
app.py CHANGED
@@ -2,41 +2,86 @@ import streamlit as st # this is for web app
2
  import nltk # nltk for english words
3
  from nltk.corpus import words # nltk words is to get five letter words
4
 
5
- st.title("Word Solver")
6
 
7
  @st.cache # cache the download process
8
  def download():
9
  nltk.download('words')
10
  download()
11
 
12
- five_letters = [word for word in words.words() if len(word)==5 ]
13
 
14
  [a,b,c,d,e] = st.columns(5)
15
 
16
  with a:
17
  first_letter = st.text_input(label="1st",value = 'a')
18
  with b:
19
- second_letter = st.text_input(label="2nd", value = 'b')
20
  with c:
21
- third_letter = st.text_input(label="3rd", value = 'e')
22
  with d:
23
- fourth_letter = st.text_input(label="4th", value = '')
24
  with e:
25
- fifth_letter = st.text_input(label="5th", value = 't')
 
 
 
 
26
 
27
- clue = first_letter+second_letter+third_letter+fourth_letter+fifth_letter
 
 
 
 
 
28
 
29
  st.markdown("### clue")
30
- st.write(clue)
31
- st.markdown("### Exclusion letters")
 
 
 
 
 
32
  exclusions = st.text_input(label="exclusions")
33
- st.markdown("# Wordle Clues")
34
 
35
- clue_result = []
 
 
 
 
 
 
 
 
 
 
 
 
36
 
 
 
 
 
 
 
 
 
 
37
  for word in five_letters:
38
- if all(c in word for c in clue) and not any(c in word for c in exclusions):
39
- clue_result.append(word)
 
 
 
 
 
 
 
40
 
41
- st.write(clue_result)
 
 
 
 
 
42
 
 
2
  import nltk # nltk for english words
3
  from nltk.corpus import words # nltk words is to get five letter words
4
 
5
+ st.title("Word Game Solver")
6
 
7
  @st.cache # cache the download process
8
  def download():
9
  nltk.download('words')
10
  download()
11
 
 
12
 
13
  [a,b,c,d,e] = st.columns(5)
14
 
15
  with a:
16
  first_letter = st.text_input(label="1st",value = 'a')
17
  with b:
18
+ second_letter = st.text_input(label="2nd", value = 'e')
19
  with c:
20
+ third_letter = st.text_input(label="3rd", value = 'i')
21
  with d:
22
+ fourth_letter = st.text_input(label="4th", value = 'o')
23
  with e:
24
+ fifth_letter = st.text_input(label="5th", value = 'u')
25
+ with f:
26
+ sixth_letter = st.text_input(label="6th", value = '')
27
+ with g:
28
+ seventh_letter = st.text_input(label="7th", value = '')
29
 
30
+ clue2 = first_letter+second_letter
31
+ clue3 = first_letter+second_letter+third_letter
32
+ clue4 = first_letter+second_letter+third_letter+fourth_letter
33
+ clue5 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter
34
+ clue6 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter+sixth_letter
35
+ clue7 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter+sixth_letter+seventh_letter
36
 
37
  st.markdown("### clue")
38
+ st.write(clue2)
39
+ st.write(clue3)
40
+ st.write(clue4)
41
+ st.write(clue5)
42
+ st.write(clue6)
43
+ st.write(clue7)
44
+
45
  exclusions = st.text_input(label="exclusions")
 
46
 
47
+ clue_result2 = []
48
+ clue_result3 = []
49
+ clue_result4 = []
50
+ clue_result5 = []
51
+ clue_result6 = []
52
+ clue_result7 = []
53
+
54
+ two_letters = [word for word in words.words() if len(word)==2 ]
55
+ three_letters = [word for word in words.words() if len(word)==3 ]
56
+ four_letters = [word for word in words.words() if len(word)==4 ]
57
+ five_letters = [word for word in words.words() if len(word)==5 ]
58
+ six_letters = [word for word in words.words() if len(word)==6 ]
59
+ seven_letters = [word for word in words.words() if len(word)==7 ]
60
 
61
+ for word in two_letters:
62
+ if all(c in word for c in clue2) and not any(c in word for c in exclusions):
63
+ clue_result2.append(word)
64
+ for word in three_letters:
65
+ if all(c in word for c in clue3) and not any(c in word for c in exclusions):
66
+ clue_result3.append(word)
67
+ for word in four_letters:
68
+ if all(c in word for c in clue4) and not any(c in word for c in exclusions):
69
+ clue_result4.append(word)
70
  for word in five_letters:
71
+ if all(c in word for c in clue5) and not any(c in word for c in exclusions):
72
+ clue_result5.append(word)
73
+ for word in six_letters:
74
+ if all(c in word for c in clue6) and not any(c in word for c in exclusions):
75
+ clue_result6.append(word)
76
+ for word in seven_letters:
77
+ if all(c in word for c in clue7) and not any(c in word for c in exclusions):
78
+ clue_result7.append(word)
79
+
80
 
81
+ st.write(clue_result2)
82
+ st.write(clue_result3)
83
+ st.write(clue_result4)
84
+ st.write(clue_result5)
85
+ st.write(clue_result6)
86
+ st.write(clue_result7)
87