Contest - Snake Numbers

This is a discussion on Contest - Snake Numbers within the Contests Board forums, part of the Community Boards category; Then why does your signature have all these names? Darryl Quantum1024 twomers Cactus_Hugger evoltix Edit: Oh, they say they have ...

  1. #31
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Then why does your signature have all these names?

    Darryl
    Quantum1024
    twomers
    Cactus_Hugger
    evoltix
    Edit: Oh, they say they have entered in a post.
    Last edited by Dante Shamest; 05-31-2006 at 09:42 PM.

  2. #32
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quantum1024
    I will get around to finnishing my entry soon, hopefully.

  3. #33
    Registered User
    Join Date
    Aug 2005
    Posts
    113
    I am also participating.

  4. #34
    Registered User evoltix's Avatar
    Join Date
    May 2006
    Posts
    6
    Just a quick question, how do you go about testing your function?

  5. #35
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    I test mine by generating a few random boards and running my function on each one.
    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

  6. #36
    Registered User evoltix's Avatar
    Join Date
    May 2006
    Posts
    6
    So, I'm assuming that we have to write the code to test it? Correct?

  7. #37
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    For what it's worth, here's my tester... you can change the grid as you see fit. I actually had an elaborate way of converting the boards from ebaum into my grid. From ebaum you can't just copy and paste, however, right clicking gave me an option to print and since I have adobe acrobat, I could print to pdf where then I could cut and paste the grid.

    (during coding, I also had output that gave me the running score as it solved, but I removed it before I submitted and didn't think to save it.)


    Code:
    #include "snake_cpp.h"
    #include <iostream>
    #include <string>
    
    std::string names[] = {	
        "North",
    	"NorthEast",
    	"East",
    	"SouthEast",
    	"South",
    	"SouthWest",
    	"West",
    	"NorthWest"
    };
    
    
    int c[18][18];
    int b[18][18]={
        {5,1,4,1,6,3,5,3,6,1,4,2,4,6,2,1,5,2},
        {2,2,4,1,1,4,3,2,4,2,3,4,1,1,2,1,5,2},
        {6,4,4,6,5,4,6,2,5,6,3,3,5,5,8,3,5,1},
        {4,4,8,2,1,1,3,5,1,5,1,6,6,1,2,2,6,4},
        {2,5,5,1,1,4,5,1,6,2,4,4,1,5,4,5,6,4},
        {5,1,2,5,4,3,1,2,1,4,6,4,6,2,3,3,3,6},
        {6,3,1,6,6,6,3,5,1,1,4,2,4,4,6,3,4,5},
        {4,4,3,4,6,6,8,9,6,4,3,5,5,4,3,4,5,2},
        {3,4,6,4,1,4,2,2,6,3,6,2,3,6,1,1,3,3},
        {2,6,4,3,2,1,2,2,5,5,3,3,4,5,3,5,1,6},
        {2,4,4,6,2,6,3,3,1,6,6,2,3,1,5,4,6,5},
        {5,6,3,1,3,6,4,3,1,4,5,4,3,6,3,3,1,1},
        {1,6,3,1,1,6,5,4,5,1,2,5,1,6,3,3,4,2},
        {1,3,1,1,4,2,5,1,2,3,6,4,1,4,2,2,5,2},
        {2,5,4,6,5,5,4,4,3,3,2,1,2,5,1,4,2,4},
        {6,6,2,1,2,2,3,5,1,4,3,2,1,8,1,5,3,4},
        {4,6,6,6,1,2,4,3,1,3,3,2,4,2,6,1,6,2},
        {6,3,4,2,5,6,5,1,4,2,2,4,2,3,8,3,5,2}};
    
    
     
        std::vector<Direction> ml;
    
    int main()
    {        
        
        for(size_t x = 0; x < 18; ++x)
                for(size_t y = 0; y < 18; ++y)
                    c[y][x] = b[x][y];
     
        
        SnakeNumbers(c,ml);
        for (size_t i = 0; i < ml.size();i++)
        {
            std::cout << names[ml[i]] << "\n";
        }
        
    
    
    
    }
    Last edited by Darryl; 06-05-2006 at 11:08 AM.

  8. #38
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Here's the code I've been using to generate random boards:
    Code:
    void GenerateBoard(int board[18][18])
    {
    	int x,y,i;
    	srand(time(NULL));
    	for(x = 0; x < 18; x++)
    		for(y = 0; y < 18; y++)
    			board[x][y] = rand() / ( RAND_MAX / 6 + 1 ) + 1;
    
    	for(i = 0; i < 5; i++)
    	{
    		do
    		{
    			x = rand() / ( RAND_MAX / 18 + 1 );
    			y = rand() / ( RAND_MAX / 18 + 1 );
    		} while(board[x][y] == BOMB);
    		board[x][y] = BOMB;
    	}
    
    	do
    	{
    		x = rand() / ( RAND_MAX / 18 + 1 );
    		y = rand() / ( RAND_MAX / 18 + 1 );
    	} while(board[x][y] == BOMB);
    	board[x][y] = SNAKE_HEAD;
    }
    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

  9. #39
    Registered User evoltix's Avatar
    Join Date
    May 2006
    Posts
    6
    Thanks guys for giving me input! I appreciate it.

  10. #40
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    A reminder: submissions are due in 1 week.
    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

  11. #41
    Registered User evoltix's Avatar
    Join Date
    May 2006
    Posts
    6
    Just a quick question, when programming C++ in Visual Studio do you guys use Visual Studio 2003 or 2005? When I have tried to use 2005 to develop in C++ I've noticed differences. Are programs that are developed in C++ using Visual Studio 2003 just as good or the same as if they were developed using Visual Studio 2005? Are the differences different since in 2005 the IDE uses .NET Framework 2.0? Also, at what point does Visual Studio 2003 become obsolete?

    P.S. Do we just add our code to the snake_cpp.h file and submit that?
    Last edited by evoltix; 06-10-2006 at 03:44 PM.

  12. #42
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Quote Originally Posted by evoltix
    P.S. Do we just add our code to the snake_cpp.h file and submit that?
    I'd prefer for your code to come in its own seperate source file.

    Two days left. So far, I've only received one entry.
    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

  13. #43
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    sent.

  14. #44
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Hehe... I know. It's summer, I'm lazy. But I'm almost done too.

    I'm rather pleased, hopefully I can give the other contestants a run for their money. Mine scores from about 165 - 185 in 3 - 4sec. (My PC is crap btw: 450MHz AMD w/ 192MB RAM.) Unfortunately, this being summer, I don't have a real PC to test this on, which is always nice.

    Going to tweak a bit more... and run under Linux, see how it performs there. (And how it badly it creams Windows! Everytime I put that MS-DOS prompt in the background, Windows forgets about it... "multitasking"...)

    Oh yeah, two things:
    1) I got gently reminded of how expensive Disk I/O was...
    2) Flowcharts. They help, a lot. Say what you want, but when you're having code block from trying to convert thought to code, try one.

    EDIT: Sent... so now I wait. :-) Good luck to the rest.
    Last edited by Cactus_Hugger; 06-14-2006 at 12:22 AM.
    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)

  15. #45
    Registered User evoltix's Avatar
    Join Date
    May 2006
    Posts
    6
    Sorry guys but I never got mine submitted since I've been really busy at work and school. Being a fulltime programmer and going to school for computer science really fills my schedule. I did start coding it but never was able to finish it. I'm curious to see how you all solved this type of problem in code. I hope to get into the next contest and actually get something turned in. Good luck to you all!

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  2. Contest Results - Snake Numbers
    By pianorain in forum Contests Board
    Replies: 4
    Last Post: 06-22-2006, 09:14 AM
  3. linked list problem
    By kzar in forum C Programming
    Replies: 8
    Last Post: 02-05-2005, 03:16 PM
  4. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 10:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21