Thread: Programming Exercise #2 View Single Post
#16
 Chompy ¯\(º_o)/¯ Join Date: Sep 2006 Location: Norway Posts: 2,815   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.y = "";    temp.cword = uppercase(currentword);    temp.word2 = uppercase(word);    // Checking     for(temp.i = 0; i < cword.length(); i++) {      if (word2.pos(cword.charat(i)) > -1) y @= "y";      else y @= "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 != word) matches @= currentword @", ";      }    }  }  if (matches.length() > 0) {     return matches;  }}// Edit this to return the wordlist usedfunction 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 __________________  