View Single Post
  #16  
Old 01-15-2008, 07:25 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
PHP Code:

/* Loops through a given wordlist
    
    First checks if the current word in the wordlist
    contains the letters the checking word does

    then checks the length of the current
    word and the checking word
*/
function findanagram(word) {
  
temp.wordlist getwordlist();
  
temp.matches "";
  for(
temp.currentword wordlist) {
    
temp."";
    
temp.cword uppercase(currentword);
    
temp.word2 uppercase(word);
    
// Checking 
    
for(temp.0cword.length(); i++) {
      if (
word2.pos(cword.charat(i)) > -1@= "y";
      else 
@= "n";
    }
    if (
y.pos("n") == -1) { // Checking purposes
      
temp.locw cword.trim().length(); // length of currentword (for loop)
      
temp.low word2.trim().length(); // length of word (params)
      
if (locw == low) {// if length of both comparing words are the same
        
if (currentword != wordmatches @= currentword @", ";
      }
    }
  }
  if (
matches.length() > 0) { 
    return 
matches;
  }
}
// Edit this to return the wordlist used
function getwordlist() {
  
temp.list.loadlines("temp/wordlist.txt");
  return list;

And you need to set maxlooplimit if your wordlist count is higher then the loop limit :o

Edit getwordlist() at the bottom to return the wordlist used. I used a wordlist which I uploaded to temp (if anyone wants to try with that I can rar it and attach, but you might need to edit it (graal doesn't like to loop through 317k words )) :O

And.. don't hurt me if this isn't a good anagram finder
__________________
Reply With Quote