A tiny little helper utility for Wordle written in C.
make
Tested with clang-1300.0.29.3
but ought to work on anything remotely modern.
wordlesmith [--help] [--no-colors] [--answers-only] FILTERS
Wordlesmith starts with an 12,973-word worldlist taken directly from the Wordle source code. You then use filters, in the form of command line arguments, to whittle down the wordlist until you get the correct answer. The output is the top five matching words (based on Scoring, see below) and the total number of matches.
--help
: Show the program help.--no-colors
: By default Wordlesmith will show any candidates that can potentially be answers (common words only) in orange and words that will be accepted as guesses but cannot be answers in gray. Setting--no-colors
disables this, and switches to using as asterisk to indicated potential answers.--answers-only
: Only show common words that can potentially be answers. This has the upside of guaranteeing that all of your guesses could potentially be the correct answer, but may not be as effective, given that some non-answer words could filter the list more effectively.--scrabble-only
: Only show words that are in the Scrabble dictionary. This is useful for using this tool for solving some of the Wordle clones that use similar but slightly less permissive wordlists. You shouldn't use this option if you're playing the original Wordle.
There are three kinds of filters: exact match (using +
), negative matches (using -
), and partial matches (using %
).
Exact match filters are in the format +a1
, with the first character +
, the second character the matched character, and the third character the letter's index (between 1 and 5).
Negative match filters start with -
and contain one or more characters that don't exist in the target word. For example, -qwerty
would filter out all words that contain q
, w
, e
, r
, t
, or y
.
Partial matches are in the format %a1
, with the first character %
, the second character the matched characters, and the third character the index where the character isn't. That is, %z1
would filter all words that either don't have a z
in them or that have a z
in position 1.
wordlesmith -qwert
Filters out all words that contain any of the characters q
, w
, e
, r
, or t
.
wordlesmith %q1 -wer %t5
The order of the filters doesn't matter, and negative matches can be all combined into a single argument, or split into multiple arguments. The two partial matches in this example are saying:
- The word contains a
q
, but not in the first position. - The word contains a
t
, but not in the fifth position.
wordlesmith %q1 -we %t5 +r4
This is the same as the previous filter, but with an exact match on the r
in the fourth position.
The key to Wordle is to maximize the information you obtain from each guess. Wordlesmith tries to model this by calculating a score for each of the words that pass through the filters, and outputting up to five of the top scorers.
The score is calculated by looking at each of the unknown positions (that is, positions that don't have an exact match defined for them) in each candidate, and multiplying the fraction of the candidate words that contain that letter by the fraction of the candidate words that contain that letter in that position. This is to bias towards words that will provide either exact or negative matches for high frequency characters, which seems to pare down the candidate list the most quickly.
If you run wordlesmith
with no filters you get the algorithm's guess at the five best initial words:
- soare
- saine
- slane
- saice
- slate
I'm not 100% confident in this algorithm and would be happy to take pull requests.