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

FizzBuzz

Name: Anonymous 2012-10-05 7:23

for i in range(110):
    pr = ""
    pr += "Fizz" * (i%3 == 0)
    pr += "Buzz" * (i%5 == 0)
    pr += "Bazz" * (i%7 == 0)
    print (pr if pr else i)


Beat this, faghets.

Name: Anonymous 2012-10-06 2:05

>>22
better solution:

function range(n) { return n > 0 ? [].concat.call(range(n-1), n) : [] }
function fizzbuzz(n,factors) { return range(n).map(match.bind(factors)) }
function match(n) { return Object.keys(this).reduce(red.bind(this, n), '') || n }
function red(n, a, b) { return n % b ? a : a + this[b] }

>>24
is this not elegant?

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