The phrase the eyes has seven letters. If a puzzle tells you the answer starts with they, you can cross out those four letters on paper. What’s left? Two e’s and an s. They spell see.
That pencil-and-paper trick works nicely in JavaScript. Anagram Machine uses two different searches depending on whether you want a single word or a whole phrase.
One word takes one lookup
Sort the letters in listen and you get eilnst. Sort silent or tinsel and you get the same key. The browser builds a map from each key to the dictionary words that share it. Here’s a small version you can run in the console:
const key = word => [...word].sort().join(''); const index = new Map(); for (const word of ['listen', 'silent', 'tinsel', 'stone']) { const letters = key(word); if (!index.has(letters)) index.set(letters, []); index.get(letters).push(word); } console.log(index.get(key('netsil'))); // ['listen', 'silent', 'tinsel'] The sort preserves repeated letters. That detail matters: letter and teller contain exactly the same distinct letters, but one has two t’s and the other has two l’s. A set would lose that difference.
A phrase needs a remaining-letter count
For a phrase, the solver keeps 26 counters, one per English letter. To try a word, it spends one count per letter. If any count would go below zero, it restores everything it spent on that attempt. It also restores the counts after exploring a successful choice, so the next candidate starts with the same letters.
Try this with the eyes. Choose Phrases, enter 4 3 for the word lengths, and set the first word to they. Leave Match input group lengths off: the original groups are 3 and 4, while the answer needs 4 and 3. Once the solver spends the letters in they, the last three slots can hold see. The counts establish that an answer fits; the puzzle clue tells you whether it makes sense.
The browser downloads the dictionary, then does the matching locally. You can try the example or bring your own clue to Anagram Machine.
Disclosure: This article was AI-generated using the project’s solver implementation as its technical source.
