Package: wordlesolve
wordlesolvewordlesolve solves Wordle!wordlesolvewill solve almost any Wordle puzzle within six guesses. Just follow the suggestions and type in the results.InstallationpipinstallwordlesolveUsageSolve modepython3-mwordlesolveor>>>fromwordlesolveimportSolver
>>>solver=Solver()>>>solver.solve()wordlesolvegives you up to five suggestions for each guess.
Type in the guess you use and the outcome Wordle gives for each letter: 0 for grey, 1 for yellow, 2 for green.For example if you guess RATES and getenter:Yourguess:RATES
Outcome:02100wordlesolvewill use that information to suggest some more guesses, getting you closer to the solution each time!Play modewordlesolvealso includes a play mode - a console-based Wordle clone. Not nearly as good asthe real thingbut fun to practise!python3-mwordlesolve-por>>>fromwordlesolveimportSolver
>>>solver=Solver()>>>solver.play()Test modeAlso included is a test mode - this was originally intended to test the algorithm during development. Test mode runs the solve algorithm against any number of solutions, either provided or randomly selected from the built-in database, and provides information on how quickly each was solved.python3-mwordlesolve-t-c10-vor>>>fromwordlesolveimportSolver
>>>solver=Solver()>>>solver.test(count=10,verbosity=1)OptionsEachwordlesolvemode takes a number of options, either as command line switches or keyword arguments.Command lineKeywordTypeDescriptionSolve modePlay modeTest mode‑‑hardhardboolUse hard modeyesyesyes-g ‑‑guessfreqguess_freqfloatMinimum word frequency allowed for guessesyesyesyes‑‑solutionfreqsolution_freqfloatMinimum word frequency allowed for solutionsnoyesyes-v ‑‑verbosityverbositycount (cl) int (kw)Verbosity level for test resultsnonoyes‑‑solutionssolutionslist[str]Solutions to testnonoyes-f ‑‑filefilenamestrPath to a text file containing solutions to test (one word per line)nonoyesHow it workswordlesolvetakes the result of each guess and builds a set of rules, for example:Yourguess:RATES
Outcome:02100will generate five rules:There is no R in the solutionThere is at least one A, including one in second positionThere is at least one T but not in third positionThere is no EThere is no Swordlesolvewill then filter its database of five-letter words to keep only those that match the rules. In this case there are 113 matching words, including FAITH, FAULT, PAINT, HABIT and VAULT.wordlesolveanalyses all matching words and counts letter frequency, i.e. in how many words each letter appears once, twice, etc. So of the 113 matching words, 44 have at least one letter N, but only 2 contain the letter X. A similar analysis is run for the position of each letter, so for example 52 of the 113 words begin with the letter T, and 39 end with the letter T.wordlesolveapplies a mask to these counts, to remove any letters or positions that are already known e.g. as there is no E in the solution, all E scores will be set to zero; because we know there is an A in position 2, no score will be given for an A in position 2.wordlesolvethen returns to the full list of words and scores each word according to these frequency and position scores. If a word contains at least one letter N, it will gain 44 points; if it begins with a T it will gain 52, etc. (In hard mode only the list of matching words is analysed rather than the full word list)These scores are added together to give each word a total, indicating how useful the word will be in confirming or eliminating the remaining matches. Based on this list,wordlesolvemakes up to five suggestions for the next guess.Word frequencywordlesolvehas a database of almost 13,000 five-letter words (the same list used in the original Wordle game). Many of these words are quite obscure and will not be known to most users. For that reason wordlesolve usesthe wordfreq libraryto use only more frequently encountered words wherever appropriate.wordfreq is used in 2 ways:To set minimum word frequency limits for guesses or solutions via keyword arguments guess_freq / solution_freq or their command line equivalentsTo tie-break between words with equal scores (the more frequent word will be preferred)Thewordfreq.zipf_frequency()function is used throughout - for the words in thewordlesolvedatabase this gives a frequency of between 0.0 (very rare) and 6.4 (very common).But why?Wordle is fun to play - that's why it's been so successful. The idea of writing a Wordle solver was not to spoil anyone's fun, it was just an interesting challenge.Inspired bythis blog postflagged byPycoder's WeeklyI thought this would be fun to try - and it was.Feel free to play around and let me know what you think.Release History0.1.1Fixed bug when passing a testcount number from the command line0.1.0Initial releaseMetaNeil Martin –neilmartin12@me.comDistributed under the MIT license. SeeLICENSEfor more information.https://github.com/neilmartin12/wordlesolve