I like to keep my brain sharp by working on programming puzzlers. On off weeks I'm going to start posting programming puzzlers I've collected over the years. Hopefully you'll find them as entertaining as I do.
The Problem
Given a file of all valid words in the English language, write an algorithm that would be suitable for a web page that will list all valid English words that are complete anagrams of the word entered by the user on the page.
That is, if the user visits the page and types in POST, the web page should quickly process the word and display that the valid anagrams are STOP and POTS.
Note that we are only looking for single-word anagrams, not anagram phrases.
Hints
Remember the use case, the algorithm proposed should be suitable for a web application and thus should be performant and not hog the CPU.
The longest word in the English language (at least that I’ve found so far) is pneumonoultramicroscopicsilicovolcanoconiosis, which is 44 characters long.
You need only consider words in the dictionary, any word not in the dictionary can be considered “not a valid word” for this exercise.
Spoiler Alert!
Fair Warning: there may be discussion of the problem and potential solutions posted in the comments below. Read at your own risk.