Almost Daily Contest Details

This is a discussion on Almost Daily Contest Details within the Contests Board forums, part of the Community Boards category; let's see some almost daily contests people... I am ready to code!!!...

  1. #16
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    let's see some almost daily contests people... I am ready to code!!!
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  2. #17
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Heres one write a program that outputs Your name in the most amount of lines
    Woop?

  3. #18
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Exclamation kids: do not compile/run this program

    Code:
    #include<iostream>
    #include<string>
    using namespace std;
    
    string repeat_forever(const string& name)
    {
         cout << name << endl;
    
         return repeat_forever(name);
    }   
    
    
    int main()
    {     
         string name;
    
         cout <<"\n\nEnter your name: ";
         cin >> name;
    
         repeat_forever(name);
    
    return 0;  //like this will ever happen 
    }


    t'is done.
    Last edited by The Brain; 09-17-2004 at 05:35 AM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #19
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    That won't work. You'll get a stack overflow, and the program will crash before eternity arrives

    And I think the point was to make a program that does nothing except print your name once, and to do it in the maximum amount of code lines. I'll have to think about this for some time...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #20
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Yes that is what I meant hunter good luck
    Woop?

  6. #21
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    You do realize, it's possible to create such a program with the number of lines limited only by the space on your harddrive, if you do:
    if(0)
    else
    if(0)
    else
    if(0)
    else
    ...
    cout << "Hunter2";

    or even
    ;
    ;
    ;
    ;
    ...
    cout << "hunter2"

    **EDIT**
    Perhaps the rules should include "lines must be required for program to function properly". Also include, "lines may not be broken unnaturally unless their length exceeds (x) non-whitespace characters; and identifiers may not exceed (x) characters in length". And, for good measure, "Exploits of any miswording in the rules will be punished by a warning and then immediate disqualification"
    Last edited by Hunter2; 09-17-2004 at 04:48 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #22
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This is too easy. Here is my "short" version:
    Code:
    #include <stdio.h>
    int main( void )
    {
        putchar(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
        1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1);putchar(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
        1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1);putchar(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
        1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1);putchar(1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
        1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1);putchar(1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+
        1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
        +1+1+1+1+1+1+1+1+1+1+1+1);
        return 0;
    }
    Now, I'm making an assumption on the character set, but I suspect I could do it without the assumption in pretty much the same way.

    Like I said, this is the "short" version. With simple math, you could have an infinitely long file, just printing the first character.

    [edit]
    You'll notice a bug I've mentioned before, that this editor/vboard has. The whitespace column does not exist in my actual code or post. And there is no way to get rid of it.
    [/edit]

    [edit2]
    I also used the full 80 column width, just to make sure I wasn't "cheating" by making my lines too short. Also, people with longer names have an advantage...
    [/edit2]

    Quzah.
    Last edited by quzah; 09-18-2004 at 01:26 AM.
    Hope is the first step on the road to disappointment.

  8. #23
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>With simple math, you could have an infinitely long file, just printing the first character.
    Well, perhaps a 'no backtracking' rule could be introduced, although the proper wording of such a rule eludes my consciousness at the moment

    **EDIT
    Hmm... you could do an extremely long one without backtracking by using floating-point numbers. Any ideas on a better rule?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  9. #24
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Define backtracking. You could start at a large number, and subtract one. Or, if that's backtracking, you could start at a very small negative number, and add one. All I did is start at one and increment. I'm not sure how that would be backtracking.

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #25
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>All I did is start at one and increment. I'm not sure how that would be backtracking.
    It wasn't, I'm referring to +1-1+1-1+1-1+1-1 forever.

    >>Define backtracking.
    As I said, I can't think of any solid rule that would work. Unless you just say "Backtracking isn't allowed, and if we consider your code to be backtracking then you're out" Or you could maybe just say that "Infinity exploits are disallowed".
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  11. #26
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It wasn't, I'm referring to +1-1+1-1+1-1+1-1 forever.
    Yeah, that was my first idea. I was also going to post a modification of the above:
    Code:
    int q=0, u=0, z=0, a=0, h = 0;
    q=q+1;q=q+1;q=q+1; ... putchar( q );
    u=u+1; ...
    ...
    There are all sorts of little things you can do. The above should take up 3x the space of my previous.

    Quzah.
    Hope is the first step on the road to disappointment.

  12. #27
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Well, isn't that the point of the 'contest'? Come on quzah, let's see your ultimate
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  13. #28
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Here, I tried not to use any excesive spacing. And I could have done the 1 + 1 + 1 + 1 thing in here but I didnt want to steal quzahs idea

    Code:
    #include <iostream>
    
    int main ( void )
    {
    
    	char name_char_1;
    	char name_char_2;
    	char name_char_3;
    	char name_char_4;
    	char name_char_5;
    	char name_char_6;
    	char name_char_7;
    
    	int name_var_1;
    	int name_var_2;
    	int name_var_3;
    	int name_var_4;
    	int name_var_5;
    	int name_var_6;
    	int name_var_7;
    	
    	name_char_1 = 'V';
    	name_char_2 = 'i';
    	name_char_3 = 'c';
    	name_char_4 = 'i';
    	name_char_5 = 'o';
    	name_char_6 = 'u';
    	name_char_7 = 's';
    
    	name_var_1 = 0;
    	name_var_2 = 0;
    	name_var_3 = 0;
    	name_var_4 = 0;
    	name_var_5 = 0;
    	name_var_6 = 0;
    	name_var_7 = 0;
    
    	do {
    
    		name_var_1 ++;
    
    	} 
    	
    	while ( name_var_1 < name_char_1 );
    
    
    	do {
    
    		name_var_2 ++;
    
    	} 
    	
    	while ( name_var_2 < name_char_2 );
    
    
    	do {
    
    		name_var_3 ++;
    
    	} 
    	
    	while ( name_var_3 < name_char_3 );
    
    
    	do {
    
    		name_var_4 ++;
    
    	} 
    	
    	while ( name_var_4 < name_char_4 );
    
    
    	do {
    
    		name_var_5 ++;
    
    	} 
    	
    	while ( name_var_5 < name_char_5 );
    
    
    	do {
    
    		name_var_6 ++;
    
    	} 
    	
    	while ( name_var_6 < name_char_6 );
    
    
    	do {
    
    		name_var_7 ++;
    
    	} 
    	
    	while ( name_var_7 < name_char_7 );
    
    
    	std::cout << 
    		static_cast <char> ( name_var_1 );
    
    	std::cout <<
    		static_cast <char> ( name_var_2 );
    
    	std::cout << 
    		static_cast <char> ( name_var_3 );
    
    	std::cout <<
    		static_cast <char> ( name_var_4 );
    
    	std::cout << 
    		static_cast <char> ( name_var_5 );
    
    	std::cout << 
    		static_cast <char> ( name_var_6 );
    
    	std::cout << 
    		static_cast <char> ( name_var_7 );
    
    	std::cout << std::endl;
    
    	std::cin.get();
    	return 0;
    
    }
    What is C++?

  14. #29
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I've imposed some limits for myself:
    1) Lines that are not variable declarations, #includes, function prototypes,
    or definitions, will be if possible, 80 characters in width.
    2) To make this the same for everyone trying it, I will output what is suggested:
    Quote Originally Posted by prog-bman
    Heres one write a program that outputs Your name in the most amount of lines

    This way, everyone outputting Your name will all be using the same length item. Otherwise I could create an account with the longest name allowable, consisting of the character with the highest ascii value...
    3) I'll restrict () my variable names to the length allowed for externally linked variables in C99. That is to say, 31 characters.
    4) I will use only four spaces for indenting.
    5) I'll use no unnecessary whitespace-only lines.
    6) I'll assume the ascii character set.

    Rather than just post the code itself, I wrote a program to make the program for me. Here is its source code:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    void fpvar( FILE *fp, int c )
    {
        char prefix[] = "ThisIsTheVariableForThe";
        char *suffix[] = { "Letter_", "OneSpace" };
        fprintf( fp, "%s%s", prefix, suffix[c==' '?1:0] );
        if( c != ' ' )
        {
            fprintf( fp, "%c", c );
        }
    }
    
    int main( void )
    {
        int x,y,z;
        char letters[] = "Your name";
        char *lines[] =
        {
            "#include <stdio.h>\n",
            "int main( void )\n",
            "{\n",
            "    char ",
            "         ",
            "    ",
            "    return 0;\n",
            "}\n",
            0,
        };
        FILE *fp = fopen("yourn.c", "w" );
    
        if( !fp )
            return 0;
    
        for( x = 0; lines[x]; x++ )
        {
            fprintf( fp, "%s", lines[x] );
            if( x == 3 )
            {
                fpvar( fp, letters[0] );
                fputs( "=0,", fp );
                fpvar( fp, letters[1] );
                fputs( "=0,\n", fp );
            }
            if( x == 4 )
            {
                for( y = 0; y < 5; y+=2 )
                {
                    fpvar( fp, letters[y+2] );
                    fputs( "=0,", fp );
                    fpvar( fp, letters[y+3] );
                    fputs( "=0,\n", fp );
                    fputs( lines[x], fp );
                }
                fpvar( fp, letters[y+2] );
                fputs( "=0;\n", fp );
            }
            if( x == 5 )
            {
                for( y = 0; letters[y]; y++ )
                {
                    for( z = 0; z < letters[y]; z++ )
                    {
                        fpvar( fp, letters[y] );
                        fputc( '=', fp );
                        fpvar( fp, letters[y] );
                        fputs( "+1;\n", fp );
                        fputs( lines[x], fp );
                    }
                    fputs( "putchar( ", fp );
                    fpvar( fp, letters[y] );
                    fputs( " );\n    ", fp );
                }
            }
        }
    
        fclose( fp );
    
        return 0;
    }
    Because it's the shorter of the two. Compile and run this, and you'll get my answer, which weighs in at 899 lines, none of which are whitespace.

    Once I had the idea of what to do, it was funner to write a program to write it for me, than it was to actually write the output myself.

    [edit] Minor pedantic editing. [/edit]

    Quzah.
    Last edited by quzah; 09-19-2004 at 10:39 PM.
    Hope is the first step on the road to disappointment.

  15. #30
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Un-freaking-believeable....

    Good job.
    What is C++?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Almost Daily Contest Details
    By dagdarian in forum Contests Board
    Replies: 4
    Last Post: 01-25-2005, 04:03 AM
  2. Almost Daily Contest #4
    By Prelude in forum Contests Board
    Replies: 35
    Last Post: 08-25-2003, 08:54 AM
  3. Almost Daily Contest #3
    By Prelude in forum Contests Board
    Replies: 29
    Last Post: 08-16-2003, 08:48 PM
  4. Almost Daily Contest #2
    By Prelude in forum Contests Board
    Replies: 37
    Last Post: 08-09-2003, 10:51 PM
  5. Almost Daily Contest #1
    By Prelude in forum Contests Board
    Replies: 32
    Last Post: 08-05-2003, 08:34 AM

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