Monday, June 1, 2009

Anagram Generation

Heres a simple algorithm I developed to test if a word can be made out of the given letters.

  1. Fill a 255 sized array with zeroes
  2. Loop through the given letters, converting them to ascii and then incrementing that location in the array
  3. Get a word from the dictionary file
  4. Do steps 1 and 2 again with the word from the dictionary file.
  5. If any of the locations in the second array are bigger than the 1st, the word is not an anagram
  6. Else, add the word a list
  7. Go back to step 3 untill you are out of words in the dictionary file.

Edit:

Heres a proof of concept for that algorithm. I also made a little bot to type it for you. I'd suggest having a copy of notepad running when you use this.

source code and dictionary file included.
http://www.megaupload.com/?d=A1XVC576

No comments: