3 ms·
>The hardest part about discussing FizzBuzz is avoiding derailing the discussion into FizzBuzz code golf. Well, since we're going there... have some JavaScript
by Hupo 14y ago
>The hardest part about discussing FizzBuzz is avoiding derailing the discussion into FizzBuzz code golf.
Well, since we're going there... have some JavaScript again!
for(var i=0;i++<100;console.log(((i%3?'':'Fizz')+(i%5?'':'Buzz'))||i));
In the spirit of http://140byt.es http://140byt.es I also condensed my pyramatrix function (though without the visualization) to 135 characters:
function(a){a=a|1;var b=[],c=a>>1,d=Math.abs,e=0,f;for(;e<a;e++)for(b[e]=[],f=0;f<a;f++)b[e][f]=1+c-d(d(c-e)>d(c-f)?c-e:c-f);;return b}
And to get the same visualization as in the original version, you can use this helper function:
function(a){var b=a.length,c='',d=0,e;for(;d<b;d++){for(e=0;e<b;)c+='['+a[d][e++]+']';c+='\n'}console.log(c)}
Assign those to say, pyramatrix and visualize and you can call visualize(pyramatrix(n)) and get the same pretty output!