!!! Small Programming Competition !!!

This is a discussion on !!! Small Programming Competition !!! within the C++ Programming forums, part of the General Programming Boards category; Hello all! I would like to propose an little programming competition, where honour and glory is the first price for ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    114

    !!! Small Programming Competition !!!

    Hello all!

    I would like to propose an little programming competition, where honour and glory is the first price for the winner(s)!

    This is the task for the competitors:
    Write a program that prints it's own source code to the screen, without performing any input. Write the program as small as possible. (smallest code wins). The text printed to the screen must be in such condition that if it where to be compiled without modification, the result would be the same again, (A copy-past into the compiler, and then compile).

    Conditions:
    *If you have solved this before, do not post the code to the forum the first thing you do. Let people think for them self for a while. I know all of you hotshot programmers out there have solved this before.

    *This is as much a competition with your self as other programmers. Do not cheat yourself by searching the web for an answer! The only loser would be you, that miss out on the experience.

    *This programming problem CAN be solved. So don't give up if you don't find the answer a once.

    *Anyone can compete!

    When you have found an answer that you think is the best, post it and hope to be the first one with that solution. Since the smallest code is the winner, any size optimation to that code will also be a valid entry, so don't post until you have your smallest code. And real programmers don't rip of other programmers, do they?? Size will be measured in number of characters in the source, space, enter and tab not counting. So writing the code on a single line won't make your code smaller, just ugly.


    Good luck all! Post any question here.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    381
    Ok ninebit, I've pm'd you my entry.
    It uses 4 lines of code inside main, 2 of them are variable declarations.
    Oh and do you have to include a return statment?

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    Ok code, but not valid as an solution I sorry. I might have been a little bit unclear, but "without performing any input", actually includes any file input.

    This is what I meant:
    - No user input.
    - No file input

    No return is needed for the main though, since the program runs correctly without it!

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    381
    isn't that just a slight modification of a hello world app then?

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    Yes... a "slightly" modified Hello world app that writes its own source code instead of "hello world".

  6. #6
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    PM'd to you.
    Visit entropysink.com - It's what your PC is made for!

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    381
    well then i don't see how you could possible make it longer than one line

  8. #8
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    Well I got a fully working solution here that got about 30 lines of code, a parser/char replacement solution. It is possible though to solve this on one line with less than 80 bytes of code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Spring 72 Hour Game Development Competition
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 02-08-2006, 12:19 AM
  2. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 01:05 AM
  3. 72 Hour Game Development Competition!
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 06-19-2005, 04:10 AM
  4. yhatzee, small straight
    By uglyjack in forum C++ Programming
    Replies: 2
    Last Post: 06-13-2002, 03:09 AM

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