Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

90% of /prog/ can't write FizzBuzz

Name: The antagonist 2008-04-25 12:38

Prove me wrong

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Name: Anonymous 2008-05-05 20:03

Must admit, I am impressed by the Perl and Python one liners. Can't us Haskellers make a short one liner?

Name: Anonymous 2008-05-05 20:16

After closer inspection it seems that they exploit that boolean operators return numbers instead of true or false typed values. Haskell can't do this of course. Otherwise something similar like this might work:

mapM_ putStrLn$map(\x->[x,"Fizz","Buzz","FizzBuzz"]!!(x`mod`3==0)+(x`mod`5==0)*2)[1..101]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List