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.
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.
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).
for i in range(100):print ''.join([s*(i%m==0)for m,s in[(3,"Fizz"),(5,"Buzz")]])or i " ".join(i%3/2*"Fizz"+i%5/4*"Buzz"or str(i+1) for i in range(100)) 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:] # 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}(1..100).map{|i|(f=[["Fizz"][i%3],["Buzz"][i%5]].join).empty? ? i:f}
[1 to 100]map(->[s for s,n of{Fizz:3,Buzz:5}|it%n<1]*''||it)
i=0;while(i++<100)console.log(((i%3?'':'Fizz')+(i%5?'':'Buzz'))||i)
Pardon the global.