npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@binar256/wordle-solver

v1.0.2

Published

A JavaScript library for solving Wordle-like games.

Readme

GitHub NPM version licence

Wordle Solver

A Wordle solver is designed for solving The New York Times Wordle game, or any games based on the same mechanics. Solver comes up with a simulation of the Wordle game for testing purposes or simply to be played, and with a list of allowed guesses and possible solutions.

Getting Started

All you need is the Wordle solver with a list of allowed guesses. To increase solving performance you can also use a list of possible solutions.

Where to Get the Word Lists

If you want to use the solver for the official Wordle game, this repository includes both the list of allowed guesses and possible solutions.

Note that those lists are outdated due to the expansion of possible solutions in the official game. Using only the list of allowed guesses is generally safer, because the list of possible solutions might not include the secret word, so the solver may fail to guess it.

Installation

npm install @binar256/wordle-solver

Import Options

ESM

import WordleSolver from "@binar256/wordle-solver";
import Wordle from "@binar256/wordle-solver/wordle";
import { WordleSolver, Wordle } from "@binar256/wordle-solver";

CJS

const WordleSolver = require("@binar256/wordle-solver");
const Wordle = require("@binar256/wordle-solver/wordle");

Basic Examples

import WordleSolver from "@binar256/wordle-solver";

const solver = new WordleSolver(allowedGuesses, possibleSolutions);

// e.g. you have guessed a word CRANE and letters have turned: 🟩🟨⬛🟨⬛,
solver.updateStatus([
  ["C", "green"],
  ["R", "yellow"],
  ["A", "grey"],
  ["N", "yellow"],
  ["E", "grey"]
]);

console.log(solver.getBestWord())
// output: e.g. "hover"

If you want the solver to directly play the game, you can use a static solve method (async mode available).

// imports Wordle for simulating the game
import { Wordle, WordleSolver } from "@binar256/wordle-solver";

const wordle = new Wordle(possibleSolutions, allowedGuesses)

// creates an instance of WordleGame
const game = wordle.createGame()
/* game can be any object, which fulfills the conditions written in JSDoc,
   which allows you to pass your own interface for Wordle game */

WordleSolver.solve(game, allowedGuesses, {
	// options
	possibleSolutions,
	startingWord, // word used as the first guess,
	async // whether is the game async
});
// output: object containing results of the game

Documentation

Code is documented by JSDoc, available directly in src files.

Algorithm Used by the Wordle Solver

Solver is based on special algorithm that uses occurrence of letters on each position and an expected value formula to calculate the word that could reduce the possible solutions as much as possible.
The main steps:

  1. Iterate through all possible solutions and count occurrence of each letter on each position.
  2. Iterate through all allowed guesses.
    1. Calculate the expected value for each letter $l$ using this formula:
      $$E(letter) = p_p ^2 + (p_t - p_p)^2 + (1 - p_t)^2$$
      $p_t$ - probability of letter turning yellow
      $p_p$ - probability of word turning green

      Terms in formula represent a probability of letter being green, yellow or grey.
      Each element is squared because its value is same as its probability.

    2. Multiply the expected values of letters in word to approximate the reducing power of each word.

    3. Pick the word with the lowest value (e.g. value $0.3$ means the total amount of possible guesses is expected to be reduced by $\times0.3$).

  3. Filter the possible guesses based on a result of the guess.
  4. Repeat if necessary.

Some steps may be slightly simplified, for more details see the code.

Testing

If you want to test different word lists or conditions, download the tests folder. Use test_config.json to set different parameters.

Running tests

node test.js

You can use Wordle solver directly in the terminal by running:

node test.js --play --number

number - optional, specifies how many words should the solver suggest.

It will prompt you to enter an input in the form [word] [color on each position]
Example:

node test.js -p 2
Enter a status: crane ryrgr
[
	[ 'tours', 0.13969838619232178 ],
	[ 'hours', 0.13969838619232178 ]
]
Enter a status:

Color codes:

  • g - green
  • y - yellow
  • r - grey

License

This project is licensed under GNU General Public License v3.0 or later