Hurry up, what's a five-letter word with 'i', 'c', 'e' as second, third and fourth letters!
The question brought me back from my YouTube video spree. It was my wife with her phone in hand, again on wordle
I, ummm, not sure, what can it be.... may be Ricer, Dicer.
No, it cannot contain an 'r.
well i honestly don't know.
You always say that. You don't care about me.
Me: I .... WHAT ???
These exchanges were becoming daily routine and something need to be done to fix it. Initially i thought to use some LLM like ChatGPT or Google Gemini to solve this issue. However, after few hit and try efforts, it was clear that those things run on prompts and for problems like these, accurate prompts are very important.
Thinking about it, i had that light bulb moment. Why cannot i make a space on hugging face. use some available text generation model and see how it goes.
Ok, keep thinking.
Yeah, to avoid typing prompt, i will do it in background. So, on frontend user can input the word and the characters state (it can be either
Grey-This character is not in the chosen word.
Yellow-This character is part of chosen word but right now it is at wrong position.
Green-This character is part of chosen word and is at right position).
Then, i can form a prompt using the user provided data and pass it to text generation model. May be add a system prompt to ensure that output is just the required words keeping the output short and simple.
Well, it didn't worked. like sometimes even for same prompt, i was getting different output.
What to do now??? Another light bulb moment! Why can't this be a word list problem. Have a list of words, based on user input, keep removing words until we are left with the final answer.
May be it will work. Where to get the word list. Spending some time on google landed me on this amazing github word repo
dwyl / english-words
I quickly extracted all the five letter words form the list and started thinking about the solution. So like before, we will get a word from user and its characters status. Based on that we can reduce the list.
pretty straight forward logic....
- Grey - Remove all words from the list that contains any grey character because anyway the chosen word will not contain these characters at any position.
- Green - Only keep those words in list which has same character at same position. Remove all other words. for example if we get a green 'e' at fifth position, we can remove all those words from list which do not contain 'e' at fifth position.
- Yellow - Hmm, these are tricky. But let's keep on reducing list. so, if first character is 'r' and is yellow, it means we can safely remove all words from list that has 'r' as first character. Because yellow means this character is part of chosen word but not at the current position. Ok, that was quick. lets build it in Streamlit as anyways i was using Python for my hobby projects and had tried little bit of Flask but Streamlit output looks so cool. I have watched some demos and was impressed with its widgets and responsiveness.
Well, after sending a lot of time going through the Streamlit documentation, I was able to put together some sort of working web page. Too bad it looks different on mobile screen. I thought it was looking good on desktop. Anyways, it is kind of working, you can try the app here
Wordle Helper on Streamlit Community cloud
For source code and a basic help document, you can refer to the GitHub repo.
GitHub Repo
If you are here, then Thanks for reading the complete blog :-). Please try the app and let me know your comments.
Happy coding!
Top comments (0)