Live data from Hacker News

Interesting C code

a1k0n.net

21–30 of 31 posts

Re: Interesting C code

#21
post #15

Earlier quoted context omitted.

It's called "code golf", and from what I can tell, perl is the undisputed king of golfing languages. Someone ought to make a quiz page - "is this perl golf, or a cat walking on a keyboard".

,[.,] is /bin/cat in brainfuck. Though, brainfuck fails miserably at most golfing challenges.

,[.,] doesn't actually concatenate files, though.

Personally, I think that using golf handicapped languages is the only way to keep it interesting. If you can choose the language, it gets too easy. One could even implement 'cat' as a single character, provided his language of choice.

Re: Interesting C code

#22
post #17
post #3

"in six lines of C" I'm not impressed. It could be done in 1 line of C when he left out the line-breaks. I don't think obfuscated code is interesting. It's unreadable. And therefore it's hard to learn something from it. But it's nice he is explaining the code. Now that is interesting!

I could have said "in 454 characters of C" but that wouldn't have been as linkbaity. Thanks for clicking! Yes, the aim was compression (golfing), not obfuscation. Compression of silly ASCII things has been sort of a hobby of mine for a while and I intend to blog about that in particular. Another little compressed snippet is my "email signature" at the bottom of my site root. Try clicking on it.

Both of these (the signature, and the post) are amazing!

....jealous

Re: Interesting C code

#23
post #13
post #2

Interesting indeed. But weird that he uses obfuscated code when doing a piece of explaining how it's done. Or do people actually write for loops like those? :P

This is basically the a C equivalent of a JAPH. A JAPH is a usually short bit of perl code that prints "Just Another Perl Hacker", but it isn't obvious that that's what it does. Trying to figure out how it works without cheating is part of the fun.

a.{~(/:a+c=:_29 14 _60 12 8 0 _2 5 3 2 11 6 14 _1 8 13){+/\a=:(#.1,5$0),1,(#.1,6$0),0,(2$2),(#:20),~(3*1 1r3,|.i.3)

Re: Interesting C code

#27
post #17

Earlier quoted context omitted.

I could have said "in 454 characters of C" but that wouldn't have been as linkbaity. Thanks for clicking! Yes, the aim was compression (golfing), not obfuscation. Compression of silly ASCII things has been sort of a hobby of mine for a while and I intend to blog about that in particular. Another little compressed snippet is my "email signature" at the bottom of my site root. Try clicking on it.

Both of these (the signature, and the post) are amazing! .... jealous

http://a1k0n.net/2006/09/15/obfuscated-c-donut.html

Jesus Christ. I love you, dude. Your site must have the highest awesomeness-per-bit ratio on the Internet :)

Re: Interesting C code

#28

Earlier quoted context omitted.

Both of these (the signature, and the post) are amazing! .... jealous

http://a1k0n.net/2006/09/15/obfuscated-c-donut.html Jesus Christ. I love you, dude. Your site must have the highest awesomeness-per-bit ratio on the Internet :)

Thanks. :) I'm most proud of my IOCCC 2006 winner (the IOCCC organizers announced the winners, but not the actual entries, then disappeared from the planet): http://a1k0n.net/2006/09/20/obfuscated-c-donut-2.html

Re: Interesting C code

#29
My favorite is world map code by Brian Westley http://www.ioccc.org/1992/westley.hint

             main(l
        ,a,n,d)char**a;{
    for(d=atoi(a[1])/10*80-
   atoi(a[2])/5-596;n="@NKA\
  CLCCGZAAQBEAADAFaISADJABBA^\
  SNLGAQABDAXIMBAACTBATAHDBAN\
  ZcEMMCCCCAAhEIJFAEAAABAfHJE\
  TBdFLDAANEfDNBPHdBcBBBEA_AL\
   H E L L O,    W O R L D! "
     [l++-3];)for(;n-->64;)
        putchar(!d+++33^
             l&1);}
BTW, how to convert C to JavaScript?
Post reply on HN