Friday, January 3, 2014

fizzbuzz.pl

A (sort of) branchless solution to the FizzBuzz test:

#!/usr/bin/env perl @out = (0, "Fizz", "Buzz", "FizzBuzz"); for ($i = \$out[0], $$i = 1; $$i <= 100; $$i++) { print $out[(!($$i % 3)) | ((!($$i % 5)) << 1)] . "\n"; }