Follow Slashdot blog updates by subscribing to our blog RSS feed


Forgot your password?
User Journal

Journal Spy Hunter's Journal: new new .sig

Yeah, so I finally found a new sig I think is cool. First person to figure out what it does gets a free lollipop!

for(int r=-1,c=0;r!=38;c++){if(c>r){r++;printf("\n"); for(c=38;c!=r;c--)printf(" ");c=0;}printf(~r&c?" `":" #");}

So of course it needs to be in a file to be compiled. You have to include stdio.h and make a main function, so the whole file is like so:

#include <stdio.h>
int main()
for(int r=-1,c=0;r!=38;c++){if(c>r){r++;printf("\n"); for(c=38;c!=r;c--)printf(" ");c=0;}printf(~r&c?" `":" #");}

Then simply compile with "g++ -o foo foo.cpp" and run. (It is actually C++ code, not C, due to the variable declaration inside the for statement, which is illegal in C.) I think it's a pretty neat example of compressed code. I actually have an even shorter version but due to Slashdot .sig limits it wouldn't fit in the sig box (when converted to HTML it has more than 120 chars due to all the <> signs).

for(int r=-1,c=0;r<65;c++){if(c>r){r++; cout<<endl;for(c=65;c>r;c--)cout<<' ';c=0;}cout<<(~r&c?" `":" #");}

That's 106 characters of C++ code (without the space in between r++; and cout<<endl required by Slashcode). If anyone can figure out how to make it smaller, I want to know about it.

Update (2/15/04): The input of several slashdotters has led to the following new extremely short (82 characters) pure C version, which as a bonus can be compiled as-is, no extra wrapping required:

main(r,c){for(r=-1,c=0;r<39;c++)printf(c<0?" ":c>r?c=r++-38,"\n":~r&c?" `":" #");}

Thanks to joe_bruin and another slashdotter whose post I have lost. I'm still not convinced this is the absolute smallest it can be, so we'll see if anyone else can improve it.

This discussion has been archived. No new comments can be posted.

new new .sig

Comments Filter:

"Oh my! An `inflammatory attitude' in alt.flame? Never heard of such a thing..." -- Allen Gwinn, allen@sulaco.Sigma.COM