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
  #46  
Old 04-06-2008, 02:35 PM
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
Quote:
Originally Posted by Horrified View Post
Pffft!

PHP Code:
3/
Dumb noobs.
o.o hmm?


oh, and when is exercise 4 coming? And could 4 have two difficults? One simplier and one harder?
__________________
Reply With Quote
  #47  
Old 04-11-2008, 01:59 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by Tolnaftate2004 View Post
Give us pseudocode, then.
I got it working O(1) but forget sharing with you guys!

the previous is a lie but I'm tempted to make something ridiculous like O(n!) and declare it O(1) and laugh @ noobs who believe it
Reply With Quote
  #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
  #49  
Old 04-22-2008, 10:35 AM
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
Maybe try doing it in a language that doesn't allow you to dynamically create new variables.
__________________
Reply With Quote
  #50  
Old 04-22-2008, 06:35 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
Maybe try doing it in a language that doesn't allow you to dynamically create new variables.
So I would use a hash, and it would still run in quadratic time. Also, the instructions say we're making this as efficient as possible in graal script.
__________________
◕‿‿◕ · 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 :/
Reply With Quote
  #51  
Old 04-22-2008, 10:04 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Tolnaftate2004 View Post
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();
  
temp.pat.clear();
  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.
There are always improvements to be made, unless Stefan makes it, in which case it must be perfect.
__________________
Reply With Quote
  #52  
Old 04-22-2008, 10:28 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by cbkbud View Post
There are always improvements to be made, unless Stefan makes it, in which case it must be perfect.
Even Stefan makes mistakes. You should see Kingdoms Debug and Zone Debug xD
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #53  
Old 04-23-2008, 02:12 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
Quote:
Originally Posted by cbkbud View Post
There are always improvements to be made...
This can be disproved.
__________________
◕‿‿◕ · 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 :/
Reply With Quote
  #54  
Old 04-23-2008, 07:28 AM
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 cbkbud View Post
There are always improvements to be made
Maybe for you, considering your level of skill, but the same does not go for others.
__________________
Reply With Quote
  #55  
Old 04-23-2008, 01:08 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
Maybe for you, considering your level of skill, but the same does not go for others.
Yes, I have so much skill, it cannot be controlled.

THE POWER OF THE SUN IN THE CHRIS.
__________________
Reply With Quote
  #56  
Old 04-23-2008, 11:56 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
I think it is feasible to shrink time to ~ aN + O(N log N). How might we go about doing this? How do we get a logarithmic factor in our order? How can this help us speed up our algorithm?

This post points out a pitfall in computing the algorithm efficiency. The questions above and this problem are related. How can we minimize the effects of substring()?
__________________
◕‿‿◕ · 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-24-2008 at 12:16 AM..
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 11:00 AM.


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