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
  #32  
Old 04-22-2008, 09:53 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Okay, well this thread has been dead for sufficiently long time. Here is what I came up with; it takes quadratic time.

PHP Code:
function onCreated() {
  
temp.getpatterns("THISISATESTSTRING");
  for (
temp.stemp.p) {
    if (
this.(@"h_"@temp.s) >= 2)
      echo(
temp.": "this.(@"h_"@temp.s));
    
this.(@"h_"@temp.s) = 0/* clean-up */
  
}
}

function 
getpatterns(s) {
  
temp.s.length();
  for (
temp.i=0temp.i<temp.l-1temp.i++) {
    
temp.s.charat(temp.i);
    for (
temp.j=temp.i+1;temp.j<temp.l;temp.j++) {
      
temp.@= s.charat(temp.j);
      
this.(@"h_"@temp.c) ++;
      
temp.pat.add(temp.c);
    }
  }
  return 
temp.pat;

Perhaps there are still improvements to be made.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/

Last edited by Tolnaftate2004; 04-23-2008 at 11:45 PM..
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 06:47 PM.


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