Talk:Signature program
From Wikipedia, the free encyclopedia
Started Article. Much of this information is thanks to User:Gennaro Prota for much of this articles information, particually the very useful expanded code. See http://en.wikipedia.org/wiki/Wikipedia:Reference_desk/Science#One_Line_C_Program_Signatures (not archived yet) for information :) -Benbread 16:37, 18 April 2006 (UTC)
- Note added on June 7, 2006
- The reference desk thread is now archived at:
- Wikipedia:Reference desk archive/Science/April 2006#One Line C Program Signatures
[edit] Original example
Hi guys,
as I said in the reference desk page, we should have an original example for this article, which I volunteered to write. Of course the set of possibilities is infinite, so I thought to ask what would be your favourites. Typical "themes" for these kinds of programs are ascii-approximated fractals (Mandelbrot, Sierpinski, etc.), tic-tac-toe, Master Mind games, calculations (e, π, etc.) and many others. So, that's the first choice to make: what should the program be about? The example we have here is nice because a) it's simple enough to be explained to everyone with a basic understanding of any programming language b) produces a pleasant drawing (though incorrect for missing the last row) c) doesn't employ very "hard" obfuscation tricks.
So one choice would be to simply "rewrite" it to be correct.
- One such correction was already provided on the reference desk page:
void print_it (unsigned h) { const unsigned n=-1; unsigned c = n; signed r = h-1; while (r>=0) printf(++c>=h?c=n,--r,"\n":c<r?" ":~c&r?"` ":"# "); }
- Its defect is that it prints an additional, spurious, space at the end of each row. But it's as simple to understand as the one we have, and employes the same tecniques, in particular the chain of ?: operators (conversely, though the original is probably in the public domain, this is a blatant copy, which doesn't uphold the honour of Wikipedia)
- a slightly more advanced version (though in some respects less elegant) is:
void print_it (unsigned h) { unsigned c = 0; signed r = h-1; int t = 0; while(r>=0){if(c>=r)(putchar)(42-3*!!(~c&r));t=++c<h;(putchar)(t?0:(c=!r--,10+22*t));} }
- from which, with some macro trick, a bunch of obscure names for the variables, and comments one could obtain for instance:
void print_it (unsigned h) { #define h(o) /*/ John Smith /*/ (putchar)(o) unsigned l=0;int /*/ john_smith at aol dot com /*/ O,o=h-1;while(o >=0){if(l>=o)h( /*/ wikipedian: (en) (de) /*/ 42-3*!!(~l&o));O =++l<h;h(O?0: /*/ perl programmer /*/ (l=!o--,10+22*O));} }
Now, the question is: what do you think is an appropriate example for the article? A snippet about Sierpinski triangles (and, if so, something along the lines above?) or a completely different one?
--Gennaro Prota 04:13, 20 April 2006 (UTC)
- Well, we could always have many examples for the many many different types of programs. I think the example that will appeal most to the majority of people is a "Cool Pattern" example similar to the one we have at the minute. Glad to see my Reference Desk Question has produced what seems will turn out to be quite an interesting and informative article :) -Benbread 19:15, 20 April 2006 (UTC)
-
- Hmm, I don't know. In fact, most of the material we have here would belong to obfuscated code (an article which is in pretty bad shape, by the way :-( ). There's nothing in a program in itself that makes it a "signature program". It is a signature program if it is used as signature :) However it is a fact that program signatures (N.B.: not "signature programs") are common on programming newsgroups and forums. While I'm still thinking about the issue, my current inclination is to have an article about "program signing", i.e. the use of (often obfuscated) programs as signatures. And that could be just a redirect to a section of obfuscated code, or maybe a short article which mainly points there for more info. In any case, let's first put the material in place, then decide :) BTW, your example strongly pokes me to write something about Sierpinski fractals, which are *really* interesting mathematics creatures. But that would require much more spare time than I have, unfortunately. BTW, may I ask where did you find the code? --Gennaro Prota 00:47, 21 April 2006 (UTC)
-
-
- I think this article should definately remain, though a rename may be needed, or to merge this information with obfuscated code. In regards to that example, i've seen it in many places on the internet, but the place i found it most recently was a website (sorry, don't know the URL anymore) listing funny Slashdot comment signatures, i also believe it's listed in the signature website this article links to. -Benbread 15:48, 21 April 2006 (UTC)
-
-
-
-
- Hey guys, I am the originator of this little program (actually it started as an assignment for my discrete math class); it's been my signature on Slashdot (username Spy Hunter) for years now. I was curious to see where this code had ended up and found this page through Google. I think it's neat that it's on Wikipedia, and of course I'll give permission for Wikipedia to use it, don't worry about any license issues (I'd worry more about the notability guidelines ;). Also, I can't really take full credit for it, as I got a lot of help from several other Slashdotters, without whom it would never have gotten as small as it is. Incidentally, all of the "tricks" used (no #include, no types defined for the main function) are legal under K&R C, AFAIK, which is why it tends to compile despite looking quite suspicious. I don't think it's necessary to "correct" it to print out the bottom line; it was written that way to minimize the number of characters in the source code, which is what makes it such a cool program to start with. Modeless 14:38, 11 November 2007 (UTC)
-
-