There's a huge lack of nerdy threads here right now!
So I just bought this book of puzzles for hackers and one of the challenges was to write a bilingual program. It has to work in both C and Perl, assuming that the file extension is correct. The program is supposed to add up and print out all of the numbers supplied in the command line. This was just so beautiful I had to share. (Not my code)
So I just bought this book of puzzles for hackers and one of the challenges was to write a bilingual program. It has to work in both C and Perl, assuming that the file extension is correct. The program is supposed to add up and print out all of the numbers supplied in the command line. This was just so beautiful I had to share. (Not my code)
Code:
#include <stdio.h> #include <stdlib.h> #define $ /* */ #define ARGV argv #define if($x) int main (int argc, char *argv[]) #define $start 1 #if PERL sub atoi { $_[0] } $ argc = @ARGV; $ start = 0; $ x=1; #endif if($x) { int $ sum; int $ i; $ sum = 0; for ( $ i = $start; $ i < $ argc ; $ i++) { $ sum += atoi ($ ARGV [$ i]); } printf("%d\n", $ sum); exit (0); }
Ban Jin!
Nobody really needs work when you have awesome. - xhuxus
Nobody really needs work when you have awesome. - xhuxus