FizzBuzz One-Liner

Challenged myself to see if it was possible to do FizzBuzz in one line. The answer: yep!

1
2
# FizzBuzz in one line (minus this comment)
print n.join([%d%s%s % (i, ‘Fizz’*(i%3==0), ‘Buzz’*(i%5==0)) for i in xrange(101)])
Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s