The FizzBuzz Test

Interesting way of determining how good a programmer is on Imran’s blog, called the FizzBuzz. I took it to make sure I wasn’t a crappy comp-sci grad who couldn’t program and discovered happily I could. Took just under four minutes to complete, though part of the extra time was I forgot how the ‘%’ operator in Perl worked (returns 0 not 1).

(A) Solution after the read more….


#!/usr/bin/perl -w
foreach my $i ( 1..100) {
if( not $i % 3 ) {
print “Fizz\n;
} elsif( not $i % 5 ) {
print “Buzz\n;
} else {
if( not $i % 3 and not $i % 5 ) {
print “FizzBuzz\n;
} else {
print “$i\n;
}
}
}