DEV Community

zprostudio
zprostudio

Posted on • Originally published at zprostudio.com

I Built a Blossom Word Game Solver and Learned How Search Engines Actually Work

`You open the Blossom word game. Seven letters, one mandatory center letter, twelve submissions, and a scoring system that rewards longer words and pangrams. Your instinct as a developer is to write a solver. Your first instinct after that is usually wrong.
Most beginners reach for brute force: generate every letter combination up to length N, check each one against a dictionary, keep the hits. This works. It's also painfully slow, because 99% of the strings you generate will be nonsense like aabcde or tttttt.
The candidate space is enormous. The valid space is tiny. Brute force pays the cost of the former to find the latter.
The Solution
Flip the direction of the search.
Instead of generating letters and checking if they're words, start from a word list and filter out anything that breaks the puzzle's rules. Four cheap checks do almost all the work:
const solve = (words, letters, center) => {
const allowed = new Set(letters);
return words.filter(w =>
w.length >= 4 &&
w.includes(center) &&
[...w].every(ch => allowed.has(ch))
);
};

That's it. One Set lookup per character, one linear pass over the dictionary. You've replaced a combinatorial explosion with an O(n·k) scan.
From there, the pipeline becomes four stages:
Filter — drop words that break letter/length/center rules
Validate — drop proper nouns, hyphenated forms, and puzzle-specific rejects
Score — assign points by length, with bonuses for pangrams and the active bonus petal
Optimize — pick the best 12-word subset, not just the 12 highest-scoring individual words
Stage 4 is the one most solvers skip, and it's the most interesting. You're not maximizing single-word score — you're maximizing portfolio score under a submission cap. That's a constraint problem, not a search problem.
Why It Matters
This same filter-then-rank pattern shows up everywhere: autocomplete, search engine ranking, recommendation systems, even compiler optimization passes. A word puzzle is just a friendly place to practice it without drowning in abstractions.
If you want the full breakdown — scoring tables, solver architecture, and how heuristic solvers compare to greedy and brute-force approaches — I wrote the longer version here: Blossom Word Game Algorithm Explained
What's your favorite "looks simple, teaches a lot" coding project? Drop it in the comments.
`

Top comments (0)