Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-26-2008, 07:26 PM
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
Quote:
Originally Posted by Inverness View Post
No comment on what I posted?

You've irritated me.
Yours is still O(n³).

e: The new standard set by DrakilorP2P, O(n²)
@Ziro: Will keep that in mind.
__________________
◕‿‿◕ · 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; 03-26-2008 at 07:57 PM..
Reply With Quote
  #2  
Old 03-26-2008, 09:40 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Tolnaftate2004 View Post
Yours is still O(n³).

e: The new standard set by DrakilorP2P, O(n²)
What the hell are you talking about?

Increased speed of script:
PHP Code:
function findpatterns(str) {
  
temp.time timevar2;
  
temp.outc = {};
  
temp.out = {};
  for (
temp.2temp.temp.str.length(); temp.++) {
    for (
temp.0temp.temp.str.length(); temp.++) {
      if (
temp.temp.temp.str.length() - 1) {
        continue;
      }
      
temp.sub temp.str.substring(temp.etemp.i);
      
temp.temp.str.positions(temp.sub);
      if (
temp.p.size() > 1) {
        if (
temp.outc.index(temp.sub) < 0) {
          
temp.outc.add(temp.sub);
          
temp.out.add(temp.sub ":" temp.p.size());
        }
      }
    }
  }
  echo(
"Time: " timevar2 temp.time);
  return 
temp.out;

__________________
Reply With Quote
  #3  
Old 03-26-2008, 09:49 PM
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
Quote:
Originally Posted by Inverness View Post
What the hell are you talking about?
This is big O notation, it is how we measure the efficiency of algorithms, without being hardware-specific. The O stands for order, which can take 2 meanings:
  1. In mathematics, O(f) is for all terms order f and above. f is usually a function where the parameter is much less than 1 (error terms).
  2. In computer science O(f) is the major factor in determining algorithm efficiency. f is a function of n, which is a whole number.

For example, the quicksort algorithm is O(n log n) [for every item to sort, it takes log base 2 of n loops to find its place].
__________________
◕‿‿◕ · 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; 03-26-2008 at 10:04 PM..
Reply With Quote
  #4  
Old 03-27-2008, 10:25 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
PHP Code:
function findpatterns(str) {
  
temp.loc 0;
  
temp.temp.str.length();
  
temp.results = new[0];
  
  while (
temp.loc temp.l) {
    
temp.len 2;
    while (
temp.len <= (temp.temp.loc)) {
      
temp.seq temp.str.substring(temp.loctemp.len);
      
temp.("count_" temp.seq)++;
      if (
temp.("count_" temp.seq) == 2) {
        
temp.results.add(temp.seq);
      }
      
temp.len++;
    }
    
temp.loc++;
  }

  for (
temp.rtemp.results) {
    echo(
temp.": " temp.("count_" temp.r));
  }

__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.

Last edited by napo_p2p; 03-27-2008 at 10:27 PM.. Reason: .
Reply With Quote
Reply

Tags
pattern-matching, programming-exercise

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:13 PM.


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