File size: 1,631 Bytes
743de20 |
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 |
import streamlit as st # this is for web app
import nltk # nltk for english words
from nltk.corpus import words # nltk words is to get five letter words
st.title("Wordle ResCLUEr") # this is the title of the app
# this is to display the image of wordle game
st.image("https://www.dexerto.com/wp-content/uploads/2022/01/08/wordle-tweets.jpg.webp")
# download the english words dictionary
@st.cache # cache the download process
def download():
nltk.download('words')
download()
# create a new list with only five letter words
five_letters = [word for word in words.words() if len(word)==5 ]
# create a five column grid
[a,b,c,d,e] = st.columns(5)
# get user input currently doesnt handle number of characters
with a:
first_letter = st.text_input(label="1st",value = 'a')
with b:
second_letter = st.text_input(label="2nd", value = 'b')
with c:
third_letter = st.text_input(label="3rd", value = 'e')
with d:
fourth_letter = st.text_input(label="4th", value = '')
with e:
fifth_letter = st.text_input(label="5th", value = 't')
# combine all the letters
clue = first_letter+second_letter+third_letter+fourth_letter+fifth_letter
st.markdown("### clue")
st.write(clue)
st.markdown("### Exclusion letters")
# exclusion letters where the grey grids are
exclusions = st.text_input(label="exclusions")
st.markdown("# Wordle Clues")
# this is an empty list to show all the clue words
clue_result = []
for word in five_letters:
if all(c in word for c in clue) and not any(c in word for c in exclusions):
clue_result.append(word)
# print the output list of clues
st.write(clue_result)
|