News for hackers. Stuff that matters.
Re:Fizzbuzz, Interviews, And Overthinking by Swizec on Thursday October 04, 2012 @05:00PM (#4614373)
I recently challenged people to codegolf fizzbuzz (http://swizec.com/blog/fizzbuzz-without-ifs-in-90-char-i-wil...)

The Haskell solution was really cool:

[max(show x)(concat[n|(f,n)<-[(3,"Fizz"),(5,"Buzz")],mod x f==0])|x<-[1..100]]

This is much simpler and it looks easier to extend as well.

Re:Fizzbuzz, Interviews, And Overthinking by buu700 on Thursday October 04, 2012 @09:02PM (#4615222)
I wrote a JS one-liner solution the other day, though JS isn't quite as concise as Haskell:

function fizzbuzz (n) { return new Array(n + 1).join().split(',').map(function (j, i) { return (i % 3 ? '' : ' fizz') + (i % 5 ? '' : ' buzz') || ' ' + i; }).slice(1).join().slice(1); }

185 characters

Edit: If I move from a general solution to only 1-100 and remove spaces and semicolons:

new Array(101).join().split(',').map(function(j, i){return (i%3?'':' fizz')+(i%5?'':' buzz')||' '+i}).slice(1).join().slice(1)

Down to 126, but a lot of that is related to precision with the whitespace and handling a JS quirk with map on undefined values; without the extra joins/split/slices, it goes down to 83 characters (but also doesn't work).

Re:Fizzbuzz, Interviews, And Overthinking by nandemo on Friday October 05, 2012 @12:29AM (#4615676)
That max looks suspicious. It (ab)uses the fact that the strings "Fizz", "Buzz" compare higher than any printed integer. If you try to extend it to (7, " Bazz") it fails, because " " comes before digits.
Re:Fizzbuzz, Interviews, And Overthinking by koblas on Thursday October 04, 2012 @11:26PM (#4615546)
Python: under 90 characters and no explicits if statements

    for i in range(100):print ''.join([s*(i%m==0)for m,s in[(3,"Fizz"),(5,"Buzz")]])or i
Re:Fizzbuzz, Interviews, And Overthinking by osener on Friday October 05, 2012 @04:01AM (#4616039)
66 characters:

    " ".join(i%3/2*"Fizz"+i%5/4*"Buzz"or str(i+1) for i in range(100))
Re:Fizzbuzz, Interviews, And Overthinking by andreasvc on Thursday October 04, 2012 @08:25PM (#4615132)
Unfortunately not below 90 characters, but without loops or ifs:

    l=range(101)
    l[3::3]=100/3*['Fizz']
    l[5::5]=100/5*['Buzz']
    l[15::15]=100/15*['FizzBuzz']
    print l[1:]
This one is 86 characters by using constants:

    l=range(101)
    l[::3]=34*['Fizz']
    l[::5]=21*['Buzz']
    l[::15]=7*['FizzBuzz']
    print l[1:]
Re:Fizzbuzz, Interviews, And Overthinking by prakashk on Friday October 05, 2012 @12:05AM (#4615638)
Perl:

    # 97 characters
    for my $i (1..100) { say join("", map { {3=>'fizz',5=>'buzz'}->{$_} unless $i % $_ } 3,5) || $i }

    # 81, if those pesky spaces are removed
    for my$i(1..100){say join("",map{{3=>'fizz',5=>'buzz'}->{$_}unless$i%$_}3,5)||$i}
Re:Fizzbuzz, Interviews, And Overthinking by Gazler on Thursday October 04, 2012 @05:14PM (#4614431)
My goto ruby solution looks something like:

(1..100).map{|i|(f=[["Fizz"][i%3],["Buzz"][i%5]].join).empty? ? i:f}

Re:Fizzbuzz, Interviews, And Overthinking by GeZe on Thursday October 04, 2012 @06:25PM (#4614721)
60 character solution in LiveScript[0], without using 'if's, also easily extensible!

[1 to 100]map(->[s for s,n of{Fizz:3,Buzz:5}|it%n<1]*''||it)

[0]http://gkz.github.com/LiveScript/

Re:Fizzbuzz, Interviews, And Overthinking by kevincennis on Thursday October 04, 2012 @10:09PM (#4615366)
In JS:

i=0;while(i++<100)console.log(((i%3?'':'Fizz')+(i%5?'':'Buzz'))||i)

Pardon the global.