|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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....
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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) |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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: There was some error to do with the backslash. When I made it: 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? |
|
#8
|
|||
|
|||
|
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 |
|
#9
|
|||
|
|||
|
RE: RE: Woohooo!
Quote:
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 |
|
#10
|
|||
|
|||
|
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. |
|
#11
|
|||
|
|||
|
RE: RE: Woohooo!
Quote:
...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. 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 |
|
#12
|
|||
|
|||
|
RE: Woohooo!
echo 'This prints a backslash: \';
output: This prints a backslash: |
|
#13
|
|||
|
|||
|
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. |
|
#14
|
|||
|
|||
|
RE: Woohooo!
It seems double quote are slower in some cases.. I did two tests. The first one looked like this: vs. 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: vs. |