View Single Post
  #21  
Old 03-27-2008, 12:02 AM
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:
function findpatterns(string) {
  
temp.time timevar2;
  
temp.out 0;
  
temp.check 0;

  for (
temp.2string.length()/2++) {
    for (
temp.0string.length()/2++) {
      if (
i+j+string.length()-2) continue;
      
temp.letters temp.string.substring(ji);
      
      if (
check.index(letters) > -1) continue;
      if (
letters.length() < 2) continue;
      
      
temp.pos string.positions(letters);
      if (
pos.size() < 2) continue;
      
      
check.add(letters);
      
out.add({letterspos.size()});
    }
  }
  echo(
"Delta Time: "timevar2-time);
  return 
out;


Example1:
PHP Code:
function onCreated() {
  echo(
findpatterns("TAPEREDATAPER"));
}
/*
  output:
  
  Weapon/GUI-script ChompyT added/updated by Chompy
  Delta Time: 0.000427007
  "TA,2","AP,2","PE,2","ER,2","TAP,2","APE,2","PER,2","TAPE,2","APER,2","TAPER,2"
*/ 
Example2:
PHP Code:
function onCreated() {
  echo(
findpatterns("AUGCCCGTAUACGTA"));
}
/*
  output:

  Weapon/GUI-script ChompyT added/updated by Chompy
  Delta Time: 0.000540971
  "AU,2","CC,2","CG,2","GT,2","TA,2","CGT,2","GTA,2","CGTA,2"
*/ 
__________________
Reply With Quote