The lameness of FizzBuzz
Tuesday 16 March 2010 - Filed under Uncategorized
I got sufficiently bored today that I decided to try out FizzBuzz. This is a common monkey-filter used to determine whether people can code at all. It’s stupidly trivial, and yet many supposed “programmers” can’t hack it. Here’s a quick (30 seconds) implementation in C:
#include <stdio.h>
char const * fmts[] = { "%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n" };
int main( void )
{
int i;
for( i = 1; i <= 100; i++ )
printf( fmts[ !(i%3) | (!(i%5)<<1) ], i );
}
2010-03-16 » admin
16 March 2010 @ 10:23 am
Amazing.
The day I read about the fizzbuzz thing, I had to try it too; but I used python, or javascript, don’t remember.
Of course, using if-else (or switch, don’t remember either).
But reading your code, I’ve realized I’m forgetting lil by lil the beauty (simple and easy) of C programming.
Cheers