or in words: since for any n multiple of 3 n % 3 == 0 I just make a list which has Fizz at index 0 and nothing else in it, and pull the (n%3)th element out of that list. Same for 5. Then I concatenate them together, print the result of that if it's true (not empty string), otherwise just n; then the default input record separator. Repeat for 1 to 100.print+(Fizz)[$_%3].(Buzz)[$_%5]||$_,$/for 1..100
Straight forward and (almost) readable code (just add whitespace :-)
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Golf Challenge: FizzBuzz
by shmem
in thread Golf Challenge: FizzBuzz
by Ovid
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |