--------------000708060601000400090905
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Here's my solution. It runs in 4 seconds on my
3932 bogomips machine, using /usr/share/dict/american-english (96,273 
words).

My major optimizations (and I didn't fiddle with minor ones) are 
limiting the "anagram space" with a standard "anagram" representation, 
and generating the stems by subtraction from bingos instead of 
generating all gazillion stems and checking them with all letters.

--------------000708060601000400090905
Content-Type: text/plain;
 nameingo_stems.rb"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filenameingo_stems.rb"

IyEgL3Vzci9iaW4vcnVieQoKIyBDb3B5cmlnaHQgKEMpIDIwMDQgSGFucyBGdWdhbAojIERp
c3RyaWJ1dGVkIHVuZGVyIHRoZSBHUEwKCnJlcXVpcmUgJ3NldCcKCiMgdGhpcyBmdW5jdGlv
biBzb3J0cyB0aGUgbGV0dGVycywgc28gZS5nLiAicnVieSIgYmVjb21lcyAiYnJ1eSIuIFRo
aXMgd2lsbAojIGdpdmUgdXMgYSBzdGFuZGFyZCByZXByZXNlbnRhdGlvbiBvZiBhbiAiYW5h
Z3JhbSIKZGVmIHBhcnNlX2FuYWdyYW0od29yZCkKICB3b3JkLnNwbGl0KCIiKS5zb3J0Lmpv
aW4KZW5kCgojIGdldCBuCm4gPSBBUkdWWzBdID8gQVJHVlswXS50b19pIDogMQoKIyBwdWxs
IGluIHRoZSB3b3JkbGlzdC4gV2UncmUgb25seSBpbnRlcmVzdGVkIGluIDctbGV0dGVyIHdv
cmRzIGFuZCB3ZSdsbAojIGFuYWdyYW0taXplIHRoZW0gc28gd2UgZW5kIHVwIHdpdGggdW5p
cXVlIDctbGV0dGVyIGFuYWdyYW1zLgokc3RkZXJyLnByaW50ICJQYXJzaW5nIHdvcmRsaXN0
IG9uIHN0ZGluLi4uIgokc3RkZXJyLmZsdXNoCmFuYWdyYW1zID0gU2V0Lm5ldwokc3RkaW4u
ZWFjaF9saW5lIGRvIHx3b3JkfAogIHdvcmQuZG93bmNhc2UhCiAgd29yZC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