Shortest FizzBuzz

AndyArmstrong on 2007-03-23T16:15:40

I wish I'd never started this FizzBuzz thing now. Anyway, FizzBuzz/Perl in 60 bytes:

print$_%3*$_%5?$_:($_%3?Bu:$_%5?Fi:FizzBu).zz,"\n"for 1..100

Can it be bettered?


Better

AndyArmstrong on 2007-03-23T16:31:43

55 bytes:

print(($_%3?'':Fizz).($_%5?'':Buzz)||$_,"\n")for 1..100

D'oh. Don't need those parentheses

AndyArmstrong on 2007-03-23T17:46:51

54 bytes:

print+($_%3?'':Fizz).($_%5?'':Buzz)||$_,"\n"for 1..100

hq9f+

educated_foo on 2007-03-23T20:10:51

Is it time to extend hq9+ yet? Maybe we can go straight to hq9fg+ and give it a Godwin's Law operator...

This was discussed on perlmonks

btilly on 2007-03-24T05:05:37

See here.



The shortest solution there (from a quick skim) was 48 characters:

print+(Fizz)[$_%3].(Buzz)[$_%5]||$_,$/for 1..100