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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old December 3rd, 2002, 04:09 AM
webhappy webhappy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Silicon Valley, CA, USA
Posts: 203 webhappy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Woohooo!

Make the deadline today!~

I only need to handle the input file and the proper output format...

My main algorithm appears to work fine Ah, finally, a problem that I see how to do! Also, my output is in ASCII right now, so...

Reply With Quote
  #2  
Old December 3rd, 2002, 04:14 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: 24
RE: Woohooo!

Now, if you got it that fast you can be sure that others will also. You have two weeks to make sure yours is the most efficient code around and will run the fastest....check all those "little" things...using single quotes instead of double quotes where possible, etc....

Reply With Quote
  #3  
Old December 3rd, 2002, 04:25 AM
webhappy webhappy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Silicon Valley, CA, USA
Posts: 203 webhappy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Woohooo!

Hm... crap... yup..

I set up to handle some random input and I really do run up the clock and I'm using a 2-ghz P4 at home, so... yup, it will probably end up really close.

Reply With Quote
  #4  
Old December 3rd, 2002, 04:50 AM
webhappy webhappy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Silicon Valley, CA, USA
Posts: 203 webhappy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Woohooo!

From my question, you might be able to tell that I was trying some randomization, but I just realized a better thing...

Actually, there are a few things that can be fine-tuned, but still, I'm glad I actually came up with somethign thsi time! (Last contest was the first one I didn't enter since crossingwords)

Reply With Quote
  #5  
Old December 3rd, 2002, 07:31 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Woohooo!

This contest is easier to get going than the last one.

I'm doing things in reverse this time. I'm am sorting out all the 'ugly' code, eg. display, interface, etc. I am determined to enter this time. By end of tonight, I will have a working prototype, but with basically no logic in the sort algorithm at all.

This way I can concentrate on writing the algorithm within the processing time constraints.

I am learning more as I go on.

From now, things will get easier. The code I have in place now can be easily reused in any similar future contest, eg. read from a single data file, display move by move, etc.

We will see what I can come up with.

I'm not as fast as webhappy, but I'm getting faster. By the way, to be coding at 16 is pretty darn good.

Reply With Quote
  #6  
Old December 3rd, 2002, 09:53 PM
webhappy webhappy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Silicon Valley, CA, USA
Posts: 203 webhappy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Woohooo!

Oh yeah, if you all want to see some *impossible* questions for high-schools, take a look at www.usaco.org
Some of the questions are insane-level... but that's a contest to get students ready for a worldwide competition... I completely screwed up on the last contest with only about 5 inputs correct out of 30 total

I got good at speed with topcoder.com about 6 months ago: there, the SRMs are 1 hour long with 3 questions

Reply With Quote
  #7  
Old December 4th, 2002, 06:44 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Woohooo!

OK, I am now at a place where I could send my entry in right now, but it wouldn't win, of course.

On most densely populated grids, it removes all but 1 or 2 most of the time.

The most difficult ones seem to be ones with only a few holes, near the centre.

I am trying to work good ways of determining which of multiple moves have more chance of producing better results. Most easy methods, like checking how many new move possibilities are made when a move is made, don't work well in all cases. Obviously, trying lots of multiple paths wastes a lot of time. Some arrangements take 0.05 seconds, some take as much as 10 seconds.

There should be other ways of pruning possible move lists, such as whether a move is toward the centre or outside, whether it is going toward a more densely populated part of the grid, whether it is in a corner, etc. This seems reminiscent of a statistics type problem. Unfortunately, I failed stats in my first year after school, so it won't be too easy to figure out.

If I can prune more dead branches, I can spend more time finding good paths.

PHP has no pointers, but it has references instead. Without them, sorting these pegs would take quite a bit longer.

It would help me if I could have static references. But perhaps I can have a static array of references. I doubt it though.

A funny thing, this line gave me problems:

php Code:
Original - php Code
  1.  
  2. print str_repeat(' / ', $temp);

There was some error to do with the backslash. When I made it:

php Code:
Original - php Code
  1.  
  2. print str_repeat(" / \", $temp);

it was fine. I don't know what the problem was.

Can you tell from the code above my totally awesome way of displaying the grid?

Reply With Quote
  #8  
Old December 4th, 2002, 11:34 PM
webhappy webhappy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Silicon Valley, CA, USA
Posts: 203 webhappy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Woohooo!

Oooohhh... I think I'm going to keep mine running for 29 seconds unless I've already found one that leaves only 1 (the best case)

So, I'm basically at where you are (but I don't really feel like coding right now... so I'm probably going to procrastinate for a while...)

This problem reminds me of teh freecell one :O

Reply With Quote
  #9  
Old December 6th, 2002, 02:47 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: 24
RE: RE: Woohooo!


Quote:
php Code:
Original - php Code
  1.  
  2. print str_repeat(' / ', $temp);

There was some error to do with the backslash. When I made it:

php Code:
Original - php Code
  1.  
  2. print str_repeat(" / \", $temp);

it was fine. I don't know what the problem was.


The problem was that you used the "" escape character. Since it was directly adjacent to the closing quote it actually wouldn't end the string until the next opening quote, why the error.

Maybe I'll enter this time, as the contest is more to my taste than that series of cardgame-playing scripts from a while ago. I know I won't win though, since the algo I've got in my head to solve the problem is very brute force like (and since I'm horrible with output design I certainly won't win that prize :-D).

KAH
php Code:
Original - php Code
  1. KAH::status = "Too lazy to register";

Reply With Quote
  #10  
Old December 7th, 2002, 07:37 AM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Woohooo!

Anon:
PHP doesn't parse single quoted strings for tokens, etc. In any other context, this string representation works fine. It seems that because I am passing it into a function, internally in the str_repeat function it has a problem with the backslash being at the end.

You didn't need to explain that a backslash escapes a character, by the way.

Reply With Quote
  #11  
Old January 6th, 2003, 05:02 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: 24
RE: RE: Woohooo!


Quote:
PHP doesn't parse single quoted strings for tokens, etc.


...sorry i had to dreg this up.

there is only one escaped char that php parses inside of a single-quote string, and that is a single quote.
php Code:
Original - php Code
  1. echo ('it's a wonderful day for a lollipop');

produces it's a wonderful day for a lollipop. not it's a wonderful...

i've seen that misconception before, thought i'd clear it up.

enjoy yourself
-taepet

Reply With Quote
  #12  
Old January 6th, 2003, 02:11 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: 24
RE: Woohooo!

echo 'This prints a backslash: \';

output:

This prints a backslash:

Reply With Quote
  #13  
Old January 6th, 2003, 05:37 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 2
RE: Woohooo!

My question now is if there is any benefit to using single quoted strings. In most code snippets I've seen, single quotes are used wherever possible, and double quotes only where a token must be parsed in the string. Is this simply being pedantic for no reason?

I'm interested to know now, because it seems PHP parses a single quoted string anyway.

Reply With Quote
  #14  
Old January 7th, 2003, 09:30 AM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Woohooo!

It seems double quote are slower in some cases..

I did two tests. The first one looked like this:
php Code:
Original - php Code
  1.  
  2. for ($a=0; $a<1000000; $a++)
  3.    echo 'qweqwe';

vs.
php Code:
Original - php Code
  1.  
  2. for ($a=0; $a<1000000; $a++)
  3.    echo "qweqwe";

And the results were within 0.1 second of each other. So it seems that if there is no variable, it doesn't matter.

Then I tried outputting a variable:
php Code:
Original - php Code
  1.  
  2. for ($a=0; $a<1000000; $a++)
  3.         echo 'qweqwe '.$a.' qweqwe';

vs.
php Code: