빠른 단어 변환기 만들기: 아나그램 풀기 뒤에 숨겨진 알고리즘

작성자

카테고리:

← 피드로
DEV Community · Word Scrambler · 2026-08-21 개발(SW)

Word Scrambler

I recently built WordScrambler, a free tool for unscrambling letters and solving anagrams, mostly out of frustration with existing tools being cluttered with ads or requiring sign-up just to see a result. Here’s a quick look at the core technique behind how it works.

The problem

Given a jumbled set of letters (say, ucim), find every valid dictionary word that can be formed from some or all of those letters.

The naive approach, generating every permutation and checking each against a dictionary, gets slow fast. A 7-letter input has 5,040 permutations; a 12-letter input has nearly 480 million. That’s not viable for instant results.

The signature trick

The key insight: two words are anagrams of each other if and only if their letters, sorted alphabetically, produce the same string. For example:

“listen” -> sorted -> “eilnst”
“silent” -> sorted -> “eilnst”

Both hash to the same signature. So instead of generating permutations, you can:

Precompute a signature for every word in your dictionary and group words by signature.
For a given input, generate the signature of the input (and its relevant sub-combinations, for partial-length matches).
Look up matching signatures in a hash map, an O(1) lookup instead of a brute-force search.

This turns “find every valid word from these letters” into a fast lookup problem rather than a combinatorial one, which is what makes results feel instant even against a large dictionary (WordScrambler checks against roughly 246,000 words).

Handling partial-length matches

Most real unscrambling needs go beyond “use every letter”, people want every valid word of any length using a subset of the given letters. That means generating signatures for all relevant letter subsets (not full permutations, just subsets, which is a much smaller set) and checking each against the dictionary map.

Try it

You can play with the live version here: wordscrambler.online — it also shows word definitions and Scrabble/Words With Friends point values alongside each result.

Curious how others have approached anagram-solving performance, especially for very large dictionaries or fuzzy/wildcard matching. Would love to hear how you’d tackle it.

원문에서 계속 ↗