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
  #11  
Old 03-26-2008, 05:13 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Not much to comment. The code and output dump should speak for themselves.
PHP Code:
function findPatterns(theString)
{
  
sendrpgmessage("String: \"" theString "\"");
  
sendrpgmessage("Init at approximately " timevar2);
  
temp.oldTime timevar2;
  
  
temp.patterns = {};
  for (
temp.length=2temp.length<temp.theString.length(); temp.length++) {
    for (
temp.position=0temp.position<temp.theString.length() - temp.length 1temp.position++) {
      
temp.pattern temp.theString.substring(temp.positiontemp.length);
      
temp.("pattern_" temp.pattern)++;
      
      
//Makes iteration through the variables much easier.
      
if (temp.("pattern_" temp.pattern) == 1temp.patterns.add(temp.pattern);
    }
  }
  
  
//Output
  
temp.output = {};
  for (
temp.patterntemp.patterns) {
    if (
temp.("pattern_" temp.pattern) > 1) {
      
temp.output.add({temp.patterntemp.("pattern_" temp.pattern)});
      
sendrpgmessage(temp.pattern ": " temp.("pattern_" temp.pattern));
    }
  }
  
  
temp.deltaTime timevar2 temp.oldTime;
  
sendrpgmessage("Finished at " timevar2 "\nDelta time is " temp.deltaTime);
  
  return 
temp.output;

PHP Code:
String"AUGCCCGTAUACGTA"
Init at approximately 1206544145.230022907
AU
2
CC
2
CG
2
GT
2
TA
2
CGT
2
GTA
2
CGTA
2
Finished at 1206544145.231662034
Delta time is 0.001600027 
Reply With Quote
 

Tags
pattern-matching, 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 04:33 AM.


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