Re: $100 Contest Question
- Posted by David Cuny <dcuny at LANSET.COM> Mar 06, 2002
- 508 views
I hesitate to mention this, not only because it's the only optimization my pathetic code has, but because it's so obvious... People have been talking about a single dictionary, but you actually need two hash tables: one hashed based on the word, and the other based on the pattern the word generates. For example: SILLY would be placed in the "normal" dictionary under the key "SILLY" and under the "pattern" dictionary as "ABCCD". If you read your cryptogram before you read the dictionary, you don't have to create a hash table for the pattern dictionary - just those that match patterns found in the cryptogram. That is, if the cryptogram were: IG EES SWWM then your dictionary would only need to hold words that match the patterns: AB AAB ABBC And since crytogram words always create the same pattern, if you store the hash key to the pattern with the cryptogram words, you don't need to recalculate it. Yeah, all obvious stuff. -- David Cuny