awacke1 commited on
Commit
743de20
β€’
1 Parent(s): 4f654cb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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("Wordle ResCLUEr") # this is the title of the app
6
+
7
+ # this is to display the image of wordle game
8
+ st.image("https://www.dexerto.com/wp-content/uploads/2022/01/08/wordle-tweets.jpg.webp")
9
+
10
+ # download the english words dictionary
11
+
12
+ @st.cache # cache the download process
13
+ def download():
14
+ nltk.download('words')
15
+ download()
16
+
17
+
18
+ # create a new list with only five letter words
19
+
20
+ five_letters = [word for word in words.words() if len(word)==5 ]
21
+
22
+ # create a five column grid
23
+
24
+ [a,b,c,d,e] = st.columns(5)
25
+
26
+ # get user input currently doesnt handle number of characters
27
+
28
+ with a:
29
+ first_letter = st.text_input(label="1st",value = 'a')
30
+ with b:
31
+ second_letter = st.text_input(label="2nd", value = 'b')
32
+ with c:
33
+ third_letter = st.text_input(label="3rd", value = 'e')
34
+ with d:
35
+ fourth_letter = st.text_input(label="4th", value = '')
36
+ with e:
37
+ fifth_letter = st.text_input(label="5th", value = 't')
38
+
39
+ # combine all the letters
40
+
41
+ clue = first_letter+second_letter+third_letter+fourth_letter+fifth_letter
42
+
43
+ st.markdown("### clue")
44
+
45
+ st.write(clue)
46
+
47
+ st.markdown("### Exclusion letters")
48
+
49
+ # exclusion letters where the grey grids are
50
+
51
+ exclusions = st.text_input(label="exclusions")
52
+
53
+ st.markdown("# Wordle Clues")
54
+
55
+
56
+ # this is an empty list to show all the clue words
57
+
58
+ clue_result = []
59
+
60
+
61
+ for word in five_letters:
62
+ if all(c in word for c in clue) and not any(c in word for c in exclusions):
63
+ clue_result.append(word)
64
+
65
+ # print the output list of clues
66
+
67
+ st.write(clue_result)
68
+