A C++ command-line tool that helps solve Wordle puzzles by filtering a dictionary of 5-letter words based on known letter patterns, exclusions, and required letters.
- Pattern Matching: Input known letters in specific positions (green letters in Wordle)
- Must-Have Letters: Specify letters that must be in the word but location is unknown (yellow letters in Wordle)
- Letter Exclusion: Remove words containing certain letters (gray letters in Wordle)
- Interactive Board: Step-by-step input for letter positions
- Smart Filtering: Continuously refines word suggestions based on new information
- Results Limiting: Shows only top 10 suggestions to avoid information overload
- C++ compiler with C++11 or later
- Standard Library support
- Place your word list in a file named words.txt in the same directory as the executable
- The word list should contain one 5-letter word per line (5757 words provided)
Compile the program:
g++ -std=c++11 -o wordle_solver main.cpp./wordle_solver- When prompted, you'll enter known letters position by position:
- Enter a letter to place it in that position
- Press Space or Enter to skip the current position
- Press 1 to go back to the previous position
- Press 0 to finish board setup early
- Example board input: [=, =, =, =, =] where = represents empty positions
- When asked "Type in the letters to ignore (if any):"
- Enter letters that are confirmed NOT in the word (gray letters in Wordle)
- Separate multiple letters with spaces
- Example: a b c to exclude words containing a, b, or c
- When asked "Type in the letters to include but not sure of location:"
- Enter letters that are in the word but position is unknown (yellow letters)
- Don't separate with spaces
- Example: ae for words that must contain both 'a' and 'e'
- After seeing results: c → Continue with new board setup (keep current filters) r → Reset everything and start over e → Exit the program
[=, =, =, =, =]
Type letter for position 0 (Space to skip, 1 to go back, 0 to finish): s
[s, =, =, =, =]
Type letter for position 1 (Space to skip, 1 to go back, 0 to finish):
[s, =, =, =, =]
Type letter for position 2 (Space to skip, 1 to go back, 0 to finish): a
[s, a, =, =, =]
Type letter for position 3 (Space to skip, 1 to go back, 0 to finish):
[s, a, =, =, =]
Type letter for position 4 (Space to skip, 1 to go back, 0 to finish): e
[s, a, =, =, e]
[s, a, _, _, e]
Type in the letters to ignore (if any): r t l n
Type in the letters to include but not sure of location: i
Here are the results of the matches:
[saice, saide, saige, saize, sajee, sakie, sapie, sasse, saute, savie]- wordle_solver.cpp → Main program file
- words.txt → Dictionary file (5757 five-letter words, one per line)
- The words.txt file must:
- Have one word per line
- Use lowercase letters only
- Not contain any empty lines or extra spaces
- Start Broad: Don't enter too many constraints initially
- Use Exclusion Wisely: Add gray letters from Wordle to the ignore list
- Refine Gradually: After each guess, update the board with new information
- Check All Results: If fewer than 10 words appear, consider all options
- Only works with 5-letter words
- Requires exact match for known positions
- Case-sensitive (use lowercase only)
- No wildcard support for partial matches