![]() |
| | #1 |
| Registered User Join Date: Dec 2005
Posts: 25
| New Contest (Possibly Too Easy for Experts) ***** Problem: Write a programme that prints out its own source file. |
| Reisswolf is offline | |
| | #2 |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| Mind if I do my entry in Perl? Here it is: |
| Rashakil Fol is offline | |
| | #3 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,439
| I can do it in two statements of active code
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #4 |
| Administrator Join Date: Aug 2001
Posts: 699
| Scheme: () |
| webmaster is offline | |
| | #5 |
| Just Lurking Join Date: Oct 2002
Posts: 4,990
|
__________________ 7. It is easier to write an incorrect program than understand a correct one. 40. There are two ways to write error-free programs; only the third one works.* Last edited by Dave_Sinkula; 01-10-2006 at 11:40 PM. |
| Dave_Sinkula is offline | |
| | #6 |
| Registered User Join Date: Dec 2005
Posts: 25
| Ha ha ha! I should have stated the question as follows: "Write a non-trivial programme that prints out its source code." ***** Anyway, the solution I have is: Code: #include <stdio.h>
#include <stdlib.h>
int main() {
system("cat <insert_filename_here>");
return 0;
}
***** By the way, is the Scheme function given above correct? I mean, the output of that empty list is nothing--right? The output is not a pair of matching parentheses with nothing in between, is it? |
| Reisswolf is offline | |
| | #7 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,439
| Well, outputting an empty list would output a formatted empty list - which is an empty pair of parentheses. Reisswolf, point one, how isn't that trivial? Point two, have you tried running that on Windows?
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #8 |
| Registered User Join Date: Dec 2005
Posts: 25
| CornedBee, I am perfectly aware that my programme is specifically for *NIX systems. Well, I only meant trivial in the sense that it contained a non-zero number of lines of code. Conceptually, it is pretty trivial. (Hence my caveat that the problem might be too easy for experts.) |
| Reisswolf is offline | |
| | #9 | |
| Budding Synth Programmer Join Date: Feb 2002 Location: Trefforest
Posts: 368
| Quote:
__________________ MSVC++ 6.0 | |
| samGwilliam is offline | |
| | #10 | |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| Quote:
| |
| Rashakil Fol is offline | |
| | #11 |
| Dump Truck Internet Join Date: Jul 2005
Posts: 357
| how is that not valid scheme (or even lisp), it looks valid to me, a nil list in lisp and nothing in scheme. |
| valis is offline | |
| | #12 | |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| () may be accepted by some (or many) Scheme implementations, but it is not a valid Scheme expression at least as defined by R5RS. Quote:
| |
| Rashakil Fol is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| WANTED: Contest Master | kermi3 | A Brief History of Cprogramming.com | 15 | 01-23-2003 10:15 PM |
| Text Compression Contest -- Sept. 28, 2002 | ygfperson | C Programming | 3 | 10-01-2002 06:25 PM |
| Results for *easy* contest: | ygfperson | A Brief History of Cprogramming.com | 15 | 07-27-2002 11:35 AM |
| Ann: New easy contest | ygfperson | A Brief History of Cprogramming.com | 0 | 07-01-2002 04:00 PM |