Thread: Contest Results - Snake Numbers

  1. #1
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401

    Contest Results - Snake Numbers

    I had a bit more free time on my hands than I anticipated, so I was able to get all the results together a bit quicker than I thought.

    This is the first contest I've ever run, so this was a bit of a learning experience for me. The first thing I learned: be extremely specific in the requirements.

    Here's a few fun questions: Suppose you have a two-dimensional integer array, array.
    1. Do you index the array with indices x and y like array[x][y] or array[y][x]?
    2. From any particular (x,y), how do you move 'north' from that position?

    These are some rather important questions that I didn't answer, and every entry assumed something different. After smacking myself in the head a few times, I #ifdef'ed up the test program to account for these differences and went to testing.

    So...congratulations to Cactus_Hugger! Cactus_Hugger's entry ran fast and generated some good moves. If you want to see the full results and the entries, click here.

    One question: when do you want another?
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  2. #2
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    First thanks for running the contest and it was fun.
    One question: when do you want another?
    I'd like another as soon as possible

    Third, I could had had comparable times to Cactus, but I decided to try to get a higher score, which I did...but at a price.

    Finally regarding the use of statics
    Coding Style
    The code was organized and fairly simple to understand. I liked the two offset arrays. In SnakeNumbers(int[18][18], std::vector&, int), the use of static variables means that you can't call the function twice in the same program. There were also a few "magic numbers" that could have been constants.
    My function was actually called recursively, and the static was so that any call of the function could know, what the "best" values were so that it could decide to give up or allow the recursion to go deeper. However this wouldn't be safe in a multi-threaded environment. The only way around it was to make it a class, which seemed a bit overkill for such a simple problem.
    Last edited by Darryl; 06-20-2006 at 02:15 PM.

  3. #3
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    I have an idea for another one that would pit each entry against the others in an AI match. How does that sound?
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    I won...

    The time saved me. I have a 450Mhz PC, so I didn't like sitting around all day. And gains became minimal. And it seems we all had much the same solution: brute force. I seem to have the only non-recursive one. Will look more later... tis late now.

    Looking at the compilation part... interesting what happens when two compilers look over the same code. I'm a MinGW user. The first warning is totally deserved - Print doesn't do what it says. (Nor what I intended... it was supposed to use s... my bad. It was entirely a debug function though. Talk about some big text files...) Your comments are right, though I haven't figured out the last two warnings.

    Your next contest sounds interesting. Hopefully there'll be more entries. Thanks for this contest!
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    I'll enter the next contest too, this time I'll do more testing and turn compiler warnings on

    Thanx for the contest I'm looking foreward to the next one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Results - 4th contest, saturday, august 11
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 08-12-2002, 09:41 AM
  2. Results for *easy* contest:
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-27-2002, 11:35 AM
  3. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 08:04 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM