Graal Forums Programming Exercise #3
 User Name Remember Me? Password
 FAQ Members List Calendar Search Today's Posts Mark Forums Read

 Thread Tools Search this Thread Display Modes
#16
03-26-2008, 09:43 PM
 DustyPorViva Will work for food. Maybe Join Date: Sep 2003 Location: Maryland, USA Posts: 9,589
 Dunno but it seems to show up in every single one of these exercises :/
#17
03-26-2008, 09:44 PM
 Chompy ¯\(º_o)/¯ Join Date: Sep 2006 Location: Norway Posts: 2,815
Quote:
 Originally Posted by DustyPorViva Dunno but it seems to show up in every single one of these exercises :/
*points at HR and pfa*

hehe
 __________________
#18
03-26-2008, 09:49 PM
 Tolnaftate2004 penguin. Join Date: Jul 2004 Location: Berkeley, CA Posts: 534
Quote:
 Originally Posted by Inverness 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..
#19
03-26-2008, 10:18 PM
 cbk1994 the fake one Join Date: Mar 2003 Location: San Francisco Posts: 10,718
Quote:
 Originally Posted by xXziroXx How about making Programming Exercise #4 something that we normal mortals stand a chance at?
This isn't really that hard, you could do this! Think about it

EDIT:

I fixed mine, it wins now. It goes something like this:

PHP Code:
``` function onCreated(){  echo( "time going in: 12412412412.1241023" );  findpatterns();  echo( "finished: 12412412412.124104" );  echo( "elapsed time: .000001" );}  ```
 __________________
#20
03-26-2008, 10:26 PM
 Inverness Incubator Join Date: Aug 2004 Location: Houston, Texas Posts: 3,613
 Well, after having this explained to me I'm kinda ticked that this wasn't even pointed out from the start. If I were to optimize my script I would have used Drakilor's method which for me to do now would just be copying.
 __________________
#21
03-27-2008, 12:02 AM
 Chompy ¯\(º_o)/¯ Join Date: Sep 2006 Location: Norway Posts: 2,815
 PHP Code: ``` function findpatterns(string) {  temp.time = timevar2;  temp.out = 0;  temp.check = 0;  for (temp.i = 2; i < string.length()/2; i ++) {    for (temp.j = 0; j < string.length()/2; j ++) {      if (i+j+2 > string.length()-2) continue;      temp.letters = temp.string.substring(j, i);            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({letters, pos.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"*/  ```
 __________________
#22
03-27-2008, 01:36 AM
 DrakilorP2P Registered User Join Date: Apr 2006 Posts: 755
Quote:
 Originally Posted by Chompy PHP Code: ```   for (temp.i = 2; i < string.length()/2; i ++) {  ```
Won't that miss the "AAAAAAAAA" pattern that occurs twice in "AAAAAAAAAA"?
#23
03-27-2008, 02:04 AM
 Tolnaftate2004 penguin. Join Date: Jul 2004 Location: Berkeley, CA Posts: 534
Quote:
 Originally Posted by Inverness Well, after having this explained to me I'm kinda ticked that this wasn't even pointed out from the start.
This has always been the point of the Programming Exercises. Perhaps you need to think differently to solve this problem by better methods, rather than the obvious...

@Chris, you started your algorithm 355 years into the future? Also you fail at subtracting.

e: Here are exact (well, kinda) loop count functions for the algorithms (n=str.length()):
Inverness:
Where epsilon (the E) is a number representative of the other loops that lead to 'continue;'. The script could be adjusted slightly to eliminate this term.
DrakilorP2P:
It should be pretty obvious where I get the O(n^2) from...
 __________________ ◕‿‿◕ · 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-27-2008 at 06:26 AM..
#24
03-27-2008, 03:39 AM
 cbk1994 the fake one Join Date: Mar 2003 Location: San Francisco Posts: 10,718
Quote:
 Originally Posted by Tolnaftate2004 Chris, you started your algorithm 355 years into the future? Also you fail at subtracting.
PSHAW
 __________________
#25
03-27-2008, 05:17 AM
 Inverness Incubator Join Date: Aug 2004 Location: Houston, Texas Posts: 3,613
Quote:
 Originally Posted by Tolnaftate2004 This has always been the point of the Programming Exercises.
Very nice of you GSTs to give programming exercises without explaining the point.

You also have yet to point out to others what functions they should be avoiding and why.
Quote:
 Originally Posted by Tolnaftate2004 Perhaps you need to think differently to solve this problem by better methods, rather than the obvious...
Like I've said, if your ranking system/method of measuring had been pointed out in the first place then maybe I would have made a script thats better on your ranking system instead of on Graal's.

You need to come down to the level of us mortals.
 __________________
#26
03-27-2008, 05:34 AM
 Tolnaftate2004 penguin. Join Date: Jul 2004 Location: Berkeley, CA Posts: 534
Quote:
 Originally Posted by Inverness Very nice of you GSTs to give programming exercises without explaining the point.
Quote:
 Originally Posted by Kristi in Programming Exercise #1 So, there is a lot of help around here dealing with syntax of scripting, but I don't see much discussion on best algorithms. Be this the case, I am going to every so often (when I feel like it) post some mathematically cool problem for you all to help each other solve and break some mental barriers. ... Remember, the goal is to make this as efficient as possible with graal script.
Quote:
 Originally Posted by Inverness You also have yet to point out to others what functions they should be avoiding and why.
Do you want me to rank them or tell you how efficient I think they are? x-x

Quote:
 Originally Posted by Inverness Like I've said, if your ranking system/method of measuring had been pointed out in the first place then maybe I would have made a script thats better on your ranking system instead of on Graal's.
The theory behind big-O notation is that it should be an accurate measure of code efficiency regardless of language or hardware. Different servers run the same code in different time. Additionally, though big-O is only an approximation, it is most accurate for LARGE n.

I don't see what you're so upset about, you made a good contribution.
 __________________ ◕‿‿◕ · 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-27-2008 at 05:54 AM..
#27
03-27-2008, 05:45 AM
 cbk1994 the fake one Join Date: Mar 2003 Location: San Francisco Posts: 10,718
 I bet I could beat my previous time of 12 seconds by triggering my web server which would use awesome fast PHP to find patterns, then return them to Graal. Slower than some, but surely faster than 12 seconds?
 __________________
#28
03-27-2008, 06:41 AM
 Inverness Incubator Join Date: Aug 2004 Location: Houston, Texas Posts: 3,613
 I'm upset because you're evaluating based on this big-O thing but didn't state that in the first place and explain it. Anyhow, if the goal is "to make this as efficient as possible with graal script" then you should be measuring based on time to complete instead of your big-O thing since the hard-coded functions do have a notable speed difference.
 __________________
#29
03-27-2008, 06:46 AM
 DustyPorViva Will work for food. Maybe Join Date: Sep 2003 Location: Maryland, USA Posts: 9,589
 If it's going to be based on time they would all have to be done on one computer instead of us each executing them as our computer speeds can change the time.
#30
03-27-2008, 06:59 AM
 Inverness Incubator Join Date: Aug 2004 Location: Houston, Texas Posts: 3,613
Quote:
 Originally Posted by DustyPorViva If it's going to be based on time they would all have to be done on one computer instead of us each executing them as our computer speeds can change the time.
I was assuming pfa would do that?

And could you "pfa" get yourself a new account or put the proper way to address you in your signature or something? I can't go calling you Tolnaftate2004 or a shortened version of it and I'm not sure if I should be calling you "pfa" either and didn't even know about that until the announcement that you became GST.
 __________________

 Tags pattern-matching, programming-exercise

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home General Forums     Graal Main Forum (English)         Hello and Goodbyes         Birthday Forum         Guild Life         Job Forum             Global Scripting Team             Playerworld Administration Team             Forum moderation Team             Graal Kingdoms Team             Graal Zone Team             Wiki Administration Team         Server Maintenance         Discussions en Francais (Français)         Diskussionsforum (Deutsch)     Forum Rules and documentation     Non-Graal-related threads Graal V6 forums     Announcements     Your opinion     Questions about V6     Feature request     Bug Report Gold Servers     Graal Kingdoms         Markets         Kingdoms             Dustari             Forest             Crescent Pirates             Samurai             Zormite Republic         Graal Kingdoms Events         Information             Gods         GK Suggestions         GK Bugs     Zone         Gfx submissions         Information         Zone Suggestions.         Zone Bugs         Zone News         Zone PC PlayerWorlds     PlayerWorlds Main Forum         Playerworld Related Information     Playerworld Staff Openings     Bomy Island Main Forum         Kingdoms Main Forum         Events and Activities         Bugs and Future Improvements             New Races     Classic Main Forum         Classic News         Classic Bugs and suggestions         Hiring for Classic     Delteria Main Forum         Delteria News         Delteria Bugs and suggestions         Hiring for Delteria     Era Main Forum         Era News         Era Bugs and improvements         Hiring for Era         Era Wiki     N-Pulse Main Forum         N-Pulse News         N-Pulse Bugs and suggestions         Hiring for N-Pulse     Unholy Nation Main Forum         Unholy Nation News         Unholy Nation Bugs and improvements         Hiring for Unholy Nation     Valikorlia Main Forum         Valikorlia News         Valikorlia Bugs and suggestions         Hiring for Valikorlia     Zodiac Main Forum         Zodiac News         Zodiac Bugs and suggestions         Hiring for Zodiac Development Forums     Level Design     Graphic Design     Sounds & Music     Gani Construction     Videos     NPC Scripting         New Scripting Engine (GS2)         Old Scripting Engine (GS1)         Code Gallery     Tech Support         Bug Reports (No posting)     Future Improvements Private forums

All times are GMT +2. The time now is 10:29 AM.

 -- Graal Forums - Author on top -- Mobile -- Graal Forums - Old Layout Contact Us - Graal - Archive - Privacy Statement - Top

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