wordl-solver
A Ruby gem that solves Wordle puzzles by ranking each candidate guess by expected information gain — the same technique behind strong public Wordle solvers. Ships with the real Wordle answer and allowed-guess lists and a single-line CLI.
How it ranks guesses
For each candidate guess, the solver simulates what feedback every still-possible answer would produce and computes the Shannon entropy of that distribution. A high-entropy guess splits the remaining answer set into many small buckets, telling you the most you can learn in one move. Higher score = better guess.
Install
gem install wordl-solverUse
wordl-solverYou enter one line per turn: the word you guessed and the color pattern you got. The pattern is 5 characters from g (green), y (yellow), s (grey). b and . are also accepted for grey.
> crane sygss
Turn 2 — 41 possible answers.
Possible answers:
poilu 3.92 bits
plumb 3.71 bits
High-info guesses:
pluot 4.21 bits (not a possible answer)
Commands
-
:undo— remove the last turn. -
:restart— start over. -
:quit— exit. -
:help— print help.
Flags
-
--top N— show the top N suggestions (default 10).
Going deeper
Two long-form docs explain how the gem works and why it's built the way it is. They're written to be readable on their own, not just as developer notes:
- docs/ALGORITHM.md — the math. Walks through the Wordle scoring rule, the duplicate-letter filter algorithm, and the Shannon-entropy ranking from first principles, with worked examples. Useful if you want to understand why this approach works.
- docs/DESIGN.md — the software design. Covers value objects, immutability, pure functions, separation of concerns, dependency injection in the CLI, and the test design philosophy. Useful if you want to learn Ruby design patterns from a small worked example.
Development
bundle install
bundle exec rake testTo regenerate the precomputed opening scores (only needed if word lists change):
bundle exec rake compute_opening_scoresLicense
MIT. See LICENSE.txt.