Skip to main content

Helper functions, word lists, and analysis tools for Wordle and other Wordle variants.

Project description

Wordle Utils

Helper functions, word lists, and analysis tools for Wordle and other Wordle variants.

Installation

pip install wordle-utils

Basic Usage

To run a bot that solves wordle for you, just run the following from your terminal after installing the package:

solve_wordle

The bot will output guesses, input what the "result" of those guesses is. _ is a miss/blank, ! is a correct/green, and ? is a wrong spot/yellow letter.

Advanced Usage

This library can be used for more than just solving wordle automatically.

Analysis

To see how many words were possible after a series of guesses use the what_do_i_know function. This takes the actual answer as well as some guesses that were made and returns the possible words after those guesses. This can be useful after completing the Wordle puzzle to see how well you narrowed down the possible word list.

In this example, the actual answer word was ROBOT. The two guesses made were LATER and TROUT. You can see that after these two guesses the only possible words remaining were ROBOT and WORST.

from wordle.analysis import what_do_i_know

what_do_i_know('robot', 'later', 'trout')
# ['robot', 'worst']

Library Functions

This library has some helper functions you can use in your own scripts. These will work for most Wordle variants.

Result

This library includes a Result enum (wordle.core.result.Result) for possible results of a guess. A result can be a miss, wrong spot, or correct. In most functions you can replace the enum with the shorthand string version of a result

  • Result.correct / '!' - the letter appears in this exact spot in the answer
  • Result.wrong_spot / '?' - the letter appears somewhere else in the answer
  • Result.miss / '_' - the letter does not appear in the word

There is some interesting behavior when guesses or answers contain duplicate letters. The test cases should give you a better idea of these. The behavior is meant to mimic the behavior of the actual Wordle game.

get_result

Given a guess and a known answer, return the "result" of the guess. This will be an array of Result objects.

For example, if the answer was ROBOT and the guess was TROUT:

from wordle.core.gameplay import get_result

get_result('trout', 'robot')
# [Result.miss, Result.wrong_spot, Result.wrong_spot, Result.miss, Result.correct]

filter_word_list

Given a starting list of words, return a new filtered down word list based on a guess and its result. You can use this function to whiddle down a word list as more guesses and results are learned.

For example, assume the remaining words were CLAIM, EMAIL, IMAGE, and SIGMA. The player guessed STAIN and got a result of __!!_.

from wordle.core.gameplay import filter_word_list

words = ['claim', 'email', 'image', 'sigma']
new_words = filter_word_list(words, 'stain', '__!!_')
# ['claim', 'email']

Variants

This library supports Wordle variants as well, since many of the gameplay strategies and functions are the same.

Mathler/Nerdle

These are both math based variants of Wordle where rather than guessing words you are guessing equations or expressions

  • Mathler - the target answer is given to you, find an expression that equals it. Comes in easy and hard variants as well.
  • Nerdle - you provide a full 8-digit equation, expression on one side, an equals sign, and then the result on the other side.

To have the solving bot play either of these games, call their solve methods

# Play Mathler (normal mode) with a target number of 314
from wordle.play.mathler import play_mathler
play_mathler(314)
# Play Nerdle
from wordle.play.mathler import play_nerdle
play_nerdle()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wordle-utils-0.3.0.tar.gz (4.5 MB view details)

Uploaded Source

Built Distribution

wordle_utils-0.3.0-py3-none-any.whl (4.5 MB view details)

Uploaded Python 3

File details

Details for the file wordle-utils-0.3.0.tar.gz.

File metadata

  • Download URL: wordle-utils-0.3.0.tar.gz
  • Upload date:
  • Size: 4.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for wordle-utils-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6e2cf318f3c1621016d0d6fdd8e7d83953d0127efca389c51709293341f041c4
MD5 baa29a3a1de66fdcabf8bc32488a3b2d
BLAKE2b-256 fbe345bd0655d7216714e718b084007a29d5cc82f3877ccaedfe11596c40f076

See more details on using hashes here.

File details

Details for the file wordle_utils-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: wordle_utils-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for wordle_utils-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a6a19edb69f1ee87077b875d182872ea3be4e5fc87bb82d1fad4fa2ad51e28f
MD5 663457dc4e060260bb61152ce826f761
BLAKE2b-256 72c93a87cbe2a31bd7079c335a7f9cba05b1249dccebd41cf8441523a9729368

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page