Letterpile

How Word Unscramblers Work

Last updated:

A word unscrambler doesn't shuffle your letters into every possible order. It does something simpler: it counts the letters you have, then keeps every word in its list that can be spelled with those counts. Blank tiles are spare counts that can stand for any letter. This guide walks through the idea with a small example, explains why the method is quick, and says what it can't do.

The obvious way, and why it's slow

The first idea most people have is to rearrange the letters every possible way and look each arrangement up. With three letters there are only six orders, so that works. With seven distinct letters there are 5,040 orders for the full-length words alone, and you also want all the shorter words hiding inside the rack, which multiplies the work again. At ten or more letters the number of orders runs into the millions. Most of those arrangements are gibberish, so the time is spent checking strings that could never be words.

The better way: count the letters

An unscrambler turns the problem around. Instead of generating arrangements, it starts from the word list, which is finite, and asks one question about each word: do I have enough of each letter to spell this?

To answer it, the tool counts your letters once. A rack of DGO becomes D×1, G×1, O×1. Then for each word in the list it walks through the word's letters and takes one from the matching count. If a count would go below zero, the word fails. If every letter is covered, the word goes into the results. The order of your letters never matters, because only the counts are used.

That is what Letterpile's Word Unscrambler does: it runs this check over the whole word list in your browser. It needs no list of arrangements and no server, just the word list and a few counters.

A worked example

Take the letters DGO. Checking every word in the list against the counts D×1, G×1, O×1 gives 5 words of two letters or more: DOG, GOD, DO, GO and OD. Each uses each letter at most once, and they come back grouped by length, longest first.

A word like GOOD fails, even though it uses only these letters, because it needs two O's and the rack has one. That is the counting rule doing its job.

Blank tiles

A blank, written as ?, adds one wildcard to the counts. When the tool runs out of a letter while checking a word, it uses a wildcard instead, if one is left. Adding a single blank to DGO raises the result count to 91, and 86 of those words need the blank, for example DOGE, DOGS, DOGY and DONG. In the results, the letter supplied by the blank is marked, so you can see which tile you'd have to spend.

Blanks make the search wider quickly, which is why Letterpile allows at most three. Each one also needs a small rule: when a word could use the blank for more than one letter, the tool spends your real tiles first and uses the blank only for what is missing. That keeps the point values honest, since blanks score nothing in most tile games.

Finding exact anagrams faster: sorted letters

For “use every letter” searches there is an even quicker trick. Sort the letters of a word alphabetically and you get its signature: LISTEN becomes EILNST. Every exact anagram has the same signature, so the words ELINTS, ENLIST, INLETS, LISTEN, SILENT and TINSEL all share EILNST.

If the tool builds a table that maps each signature to its words once, finding all anagrams of a set of letters is a single lookup: sort the letters, look up the signature. Letterpile's Anagram Solver works this way, and builds the table the first time you use it in a session.

WordSignature
ELINTSEILNST
ENLISTEILNST
INLETSEILNST
LISTENEILNST
SILENTEILNST
TINSELEILNST

Filters

Most unscramblers let you narrow results with filters such as “starts with”, “ends with”, “contains” or a fixed length. These are cheap extra checks applied to each candidate word before the letter counting, and they are useful when a word has to join letters already on a board. For example, there are 3,864 four-letter words in the list, but only a small fraction of them can be spelled from any particular rack, and a starts-with filter cuts that further.

Why it can run in your browser

The word list Letterpile uses is a plain text file of about 172,823 words. Compressed for download, it is small enough for a browser to fetch once and keep in its cache, and checking each word with a handful of counters is light work for a modern phone or computer. Running everything on your device has two benefits: results appear without a round trip to a server, and the letters you type are never sent anywhere.

What an unscrambler can't tell you

  • Whether your game accepts a word. The tool only knows its own list. Words come from the open ENABLE word list. Different games use different dictionaries, so always check the rules of your game.
  • Which word is best on a board. Bonus squares, crossing words and what you keep on your rack matter as much as the word itself. The tile game word finder adds letter scores and board letters, but not bonus squares.
  • Meanings. A list of words is not a dictionary. Letterpile can look up a definition when you ask, from a separate service.

Summary

An unscrambler counts your letters and keeps the words those counts can pay for. Blanks are spare counts. Exact anagrams can be found even faster by sorting letters into a signature. The method is simple, quick and private, and its answers are only as good as the word list behind it.

In the ENABLE word list. Definitions come from the Free Dictionary API; looking one up sends the word and your IP address to that service.