Solves the Wordle game interactively or optionally non-interactively.
Wordle is a word puzzle in which the player has to guess a five-letter word within six attempts. After each guess, the player is given feedback on the letters that are correct and in the correct position, correct but in the wrong position, or incorrect.
NYTimes Wordle game: https://www.nytimes.com/games/wordle/index.html
pip install -r requirements.txt
src/wordle.py [-h] -d DICT [DICT ...] [-l LEN] [-t TRIES] [-n] [-w WORD] [-c] [-q]
-h, --help Show this help message and exit
-d DICT [DICT ...], --dict DICT [DICT ...] Dictionary files
-l LEN, --len LEN Word length (default: 5)
-t TRIES, --tries TRIES Maximum tries (default: 6)
-n, --non-interactive Turn on non-interactive mode by providing the word to guess
-w WORD, --word WORD The word to solve in non-interactive mode
-c, --continuous Continuous mode; uses all words in the dictionary
-s, --solver Solver to use (default: position)
-q, --quiet Quiet mode
-p, --profile Profile the code (for debugging)
❯ src/wordle.py -d words/word-unscrambler-words.txt -n -w sorry -s entropy
Round: 1
Current possible answers: 2309
Best guesses:
- slate: (0.62)
- sauce: (0.61)
- slice: (0.61)
- shale: (0.61)
- saute: (0.60)
Guess: slate
Response: █████
Round: 2
Current possible answers: 56
Best guesses:
- sorry: (0.57)
- shiny: (0.57)
- spiny: (0.54)
- sunny: (0.53)
- spicy: (0.52)
Guess: sorry
Response: █████
Wordle solved in 2 tries
This solver uses the probability of letters in each position to determine the best possible guess.
Word List | Words | Success Rate | Average Tries | Average Time Per Word (ms) |
---|---|---|---|---|
Wordle (original) | 2315 | 99.0% | 3.78 | 3 |
NYTimes Extended | 14855 | 83.2% | 4.57 | 21 |
This solver uses the probability of words in well known NLTK corpuses to determine the best possible guess.
Word List | Words | Success Rate | Average Tries | Average Time Per Word (ms) |
---|---|---|---|---|
Wordle (original) | 2315 | 98.1% | 4.19 | 4 |
NYTimes Extended | 14855 | 83.2% | 4.81 | 25 |
This solver uses the entropy of the words to determine the best guess. The entropy score is calculated based on the probability of resulting in greater number of exact or partial matches from a given guess. Computation of this score is more time-consuming than the position probability solver.
Word List | Words | Success Rate | Average Tries | Average Time Per Word (ms) |
---|---|---|---|---|
Wordle (original) | 2315 | 99.6% | 3.57 | 14 |
NYTimes Extended | 14855 | 90.5% | 4.29 | 252 |
Timing from 2020 M1 MacBook Pro (8 cores)
Apache License 2.0