View Single Post
  #48  
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