Older Contests
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP ContestsOlder Contests

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 14th, 2002, 08:40 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: The time draws near

I agree, it was fun. I think my other-half is glad its over.

Reply With Quote
  #2  
Old May 14th, 2002, 11:06 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: The time draws near

I cannot quite agree. It was clasiccal problem, sometimes formulated as finding the shortest path between two towns. This problem also has good solution, described in many books on algorithms

Reply With Quote
  #3  
Old May 14th, 2002, 12:01 PM
Laxersaz Laxersaz is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Neuss, NRW, Germany
Posts: 21 Laxersaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Laxersaz Send a message via AIM to Laxersaz
RE: The time draws near

I'm not quite sure if my solution works in every maze possible. I had much fun coding anyway and I'm really looking forward to the next challenge!

Reply With Quote
  #4  
Old May 14th, 2002, 06:34 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: The time draws near

I agree, this was a lot of fun. My only complaint is that there isn't a clear list of judging criteria. Sure, if you read through the entire forum, Matt gives some tidbits here and there, but there needs to be a good clearly defined list of goals, for example:

1. Function
2. Speed
3. Resource Usage
4. Code Length

That way, we know what we need to concentrate on first.

My Solution:
http://www.digitalsickness.com/contest/

Let me know what you guys think...

Reply With Quote
  #5  
Old May 14th, 2002, 07:08 PM
zodiak zodiak is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Portugal
Posts: 4 zodiak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: The time draws near

yeah, very good.

Reply With Quote
  #6  
Old May 14th, 2002, 07:15 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: The time draws near

very good work

what cpu(s) does the server have?

my solution
http://www.s0nix.de/path.php
(running on a dual PIII 500MhZ)

Reply With Quote
  #7  
Old May 14th, 2002, 07:49 PM
diclophis diclophis is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Tampa. FL, USA
Posts: 35 diclophis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to diclophis Send a message via AIM to diclophis Send a message via Yahoo to diclophis
The time draws near

This proved to be a rather interesting challenge. I am allready looking forward to the next one. I know i learned alot about the upper limits of PHP and some techniques to optimize every cpu cycle in my scripts. who woulda thought a maze could be such a complex thing, both mathmaticly and in terms of code. I am looking forward to seeing the results on this one.

-Jon

p.s.

Here is mine: http://sig.mine.nu/maze/

Reply With Quote
  #8  
Old May 14th, 2002, 07:51 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: The time draws near

heartily agree, this was a pleasant distraction. nice puzzle, matt, look forward to the next one!

Reply With Quote
  #9  
Old May 14th, 2002, 08:27 PM
jameadows jameadows is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ashland, OR US
Posts: 7 jameadows User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: The time draws near

Me too, me too! This was a great fun diversion and a good challenge to push my fledgling PHP chops.

The only problem is I've been writing so much PHP lately that when I get back to my day job writing C++ code I keep putting the dang $ in front of my variables!

Thanks Matt. I'm looking forward to the next one

Reply With Quote
  #10  
Old May 14th, 2002, 10:54 PM
johndoe110479 johndoe110479 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Bucharest, Romania
Posts: 9 johndoe110479 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to johndoe110479 Send a message via AIM to johndoe110479 Send a message via Yahoo to johndoe110479
RE: The time draws near

Thumbs up for all the coders who solved the problem...

Most of all, thumbs up for Matt: the man who came up with the idea of this contest. I really hope this contest will not dissapear.

Best wishes for all PHP coders!

Reply With Quote
  #11  
Old May 15th, 2002, 08:43 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 25
RE: The time draws near

Now that the deadline's passed, I'd love to see some of your code -- especially those of you who managed to solve the 201x201 map in under 1 second...

I'll start:
http://www.0wn.org/contest/maze/maze.phps

Matt, if you'd rather us not share, just let me know and I'll edit my post.

Thanks,
Chris Lambert, chris.lambert@vbulletin.com

Reply With Quote
  #12  
Old May 15th, 2002, 09:19 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to EvilivE
RE: The time draws near

I ran this code against a 200x200 maze and it solved it in somewhere between .65 and .70 seconds. This is the "work horse" of the code. If you care to see the rest of it go here.

php Code:
Original - php Code
  1.  
  2.   // fill the 2d array
  3.  
  4.   while (!feof($fp)){
  5.     $ch = fgetc($fp);
  6.     if (!feof($fp)){
  7.       if ($ch == "W"){
  8.         $maze[$row][$col] = $ch;
  9.         $col++;
  10.       } else if ($ch == " "){
  11.         $maze[$row][$col] = -1;
  12.         $col++;
  13.       } else if ($ch == "n"){
  14.         $row++;
  15.         $col = 0;
  16.       } else if ($ch == "S" || $ch == "E"){
  17.         $maze[$row][$col] = $ch;
  18.         if ($ch == "S"){
  19.           $s_row = $row;
  20.           $s_col = $col;
  21.         } else {
  22.           $e_row = $row;
  23.           $e_col = $col;
  24.         }
  25.         $col++;
  26.       }
  27.     }
  28.   }
  29.   fclose($fp);
  30.  
  31.   // define boundries
  32.   $b_right  = sizeof($maze[0]);
  33.   $b_bottom = sizeof($maze);
  34.  
  35.   // start algorithm from 'E'. this will mark only one 'space' and record
  36.   // its coordinates, which 'space' is determined by which side 'E' is
  37.   // located. No need to check for 'E' in a corner.
  38.  
  39.   if ($e_col == sizeof($maze[0]) - 1){
  40.     $maze[$e_row][$e_col - 1] = $c_count;
  41.     $c_count++;
  42.     $tmp_row = array($e_row);
  43.     $tmp_col = array($e_col - 1);
  44.   } else if ($e_col == 0){
  45.     $maze[$e_row][$e_col + 1] = $c_count;
  46.     $c_count++;
  47.     $tmp_row = array($e_row);
  48.     $tmp_col = array($e_col + 1);
  49.   } else if ($e_row == sizeof($maze) - 1){
  50.     $maze[$e_row - 1][$e_col] = $c_count;
  51.     $c_count++;
  52.     $tmp_row = array($e_row - 1);
  53.     $tmp_col = array($e_col);
  54.   } else {
  55.     $maze[$e_row + 1][$e_col] = $c_count;
  56.     $c_count++;
  57.     $tmp_row = array($e_row + 1);
  58.     $tmp_col = array($e_col);
  59.   }
  60.  
  61.   // goto the coordinate(s) that have been marked and mark its adjacent
  62.   // 'spaces' if applicable (check for -1).
  63.  
  64.   while (sizeof($tmp_row) != 0){
  65.     $orig_size = sizeof($tmp_row);
  66.     for ($i = 0; $i < $orig_size; $i++){
  67.       // ckeck up
  68.       if ($tmp_row[0] - 1 > 0){
  69.         if ($maze[$tmp_row[0] - 1][$tmp_col[0]] == -1){
  70.           $maze[$tmp_row[0] - 1][$tmp_col[0]] = $c_count;
  71.           array_push($tmp_row, $tmp_row[0] - 1);
  72.           array_push($tmp_col, $tmp_col[0]);
  73.         } else if ($maze[$tmp_row[0] - 1][$tmp_col[0]] == "S"){
  74.           break 2;
  75.         }
  76.       }
  77.       // check down
  78.       if ($tmp_row[0] + 1 < $b_bottom - 1){
  79.         if ($maze[$tmp_row[0] + 1][$tmp_col[0]] == -1){
  80.           $maze[$tmp_row[0] + 1][$tmp_col[0]] = $c_count;
  81.           array_push($tmp_row, $tmp_row[0] + 1);
  82.           array_push($tmp_col, $tmp_col[0]);
  83.         } else if ($maze[$tmp_row[0] + 1][$tmp_col[0]] == "S"){
  84.           break 2;
  85.         }
  86.       }
  87.       // check left
  88.       if ($tmp_col[0] - 1 > 0){
  89.         if ($maze[$tmp_row[0]][$tmp_col[0] - 1] == -1){
  90.           $maze[$tmp_row[0]][$tmp_col[0] - 1] = $c_count;
  91.           array_push($tmp_row, $tmp_row[0]);
  92.           array_push($tmp_col, $tmp_col[0] - 1);
  93.         } else if ($maze[$tmp_row[0]][$tmp_col[0] - 1] == "S"){
  94.           break 2;
  95.         }
  96.       }
  97.       // check right
  98.       if ($tmp_col[0] + 1 < $b_right - 1){
  99.         if ($maze[$tmp_row[0]][$tmp_col[0] + 1] == -1){
  100.           $maze[$tmp_row[0]][$tmp_col[0] + 1] = $c_count;
  101.           array_push($tmp_row, $tmp_row[0]);
  102.           array_push($tmp_col, $tmp_col[0] + 1);
  103.         } else if ($maze[$tmp_row[0]][$tmp_col[0] + 1] == "S"){
  104.           break 2;
  105.         }
  106.       }
  107.       array_shift($tmp_row);
  108.       array_shift($tmp_col);
  109.     }
  110.     $c_count++;
  111.   }

Reply With Quote
  #13  
Old May 15th, 2002, 09:27 AM
diclophis diclophis is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Tampa. FL, USA
Posts: 35 diclophis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to diclophis Send a message via AIM to diclophis Send a message via Yahoo to diclophis
RE: The time draws near

http://sig.mine.nu/maze/libZork.phps

Is the main file for my script... the major relization came when i figured out that maze routing ISNT a recursive algorithm. While fidning a path out of a maze at all costs can be recursive (e.g. wall walkers etc etc). In the cases we were set to solve it was a known fact where the start, and the end was, and also that a route from start to end did infact exist.. we just had to measure it. I just imagined a scenrio where i could split, or 'make new threads' for each path. Imagine this, you start at the end/beginging of the maze and you have a ball of string in your hand you start walking in the only direction you can go (or use the upcoming fork in the road scenario) letting the string out as you walk. whenever you come to an intersection, the universe splits into as many forks it needs to, say we came to a 4 wayt intersection + 2 new universes would be created with you and your ball of string, in each different universe you went a different path through the maze. And when the first person to arrive at the exit blows a horn all the other universes cease to exist, leaving you alone in your one universe with a ball of string that maps out the shortest route through the maze. cut the string and measure it and badda boom, you have how long it is. Also, if you might have guess several of yous can arrive at the exit at the same time.. in which case its a trivial matter of of deciding which route to take, as they are all the same length.. but some may have more turns or maybe one route had booby traps or something. It would be upto you to decide which one to keep. My guess is that maze routing would be a task that lends itself to quantum computing quite easily. And dont think that maze routing is trivial either... anyone ever view a cpu under a microscope... looks alot like a maze. Makes my mind spin, how about you?

-Jon

Reply With Quote
  #14  
Old May 15th, 2002, 10:25 AM
jameadows jameadows is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ashland, OR US
Posts: 7 jameadows User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: The time draws near

Well, you showed me yours so I'll show you mine:eek:

There's a working example at:
http://65.18.150.149/mazer/

and the code is at:
http://65.18.150.149/mazer/mazer.php.txt

There are also some links to mazes on the first URL. It did manage to solve the 200x201 maze and on my new host it was finally able to solve the 372x278 maze that someone posted here a while ago. I think the script might have been running out of memory on the other host.

I think my reasoning was pretty similar to diclophis, an object cloning itself at intersections. It's funny that you'd mention string because my objects kept track of the path by appending a string with U,D,L,R for the various ups, downs, lefts and rights. When it was done it measured the length of its string using, what else, strlen().

Reply With Quote
  #15  
Old May 15th, 2002, 10:36 AM
pswitek pswitek is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Warsaw, Poland
Posts: 6 pswitek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: The time draws near

I have not analysed your code in detail, but only took a fast look. It looks to me, that you used Dijkstra algorithm. This is a known algorithm and you can find it described in many books on algorithms. This is probably the only algorithm, that solved the maze without recursion.

Now, when many people implemented this same algorithm, I wonder how Mat is going to select a winner. Especially, that the only published criteria is functionality.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP ContestsOlder Contests > The time draws near


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek