Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

Tags
anagrams, programming-exercise


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.