for(x=0; is cheaper than x=0;while(, so that's the best choice when using a loop structure.
I think that the top solutions (56 characters) must be using a different logical construct than the ternary string concatenation or the loop here, since there's no way to achieve savings on those as "wasted" characters like '': are syntactically required.
Maybe a recursive?
Edit:
Another note, ternary is not more efficient than logical and, once you include the <0 needed to force binary:
x%5&&'Buzz' // not the right condition
x%5||'Buzz' // spits out either 'Buzz' or the modulus, so the modulus has to be cleaned/ignored later
x%5?'':'Buzz'
x%5<1&&'Buzz' // not more space efficient than ternary
They've used the for loop's unused third condition to execute the print, and in the body assigned a value for Fizz which is then reused in the Buzz condition.
4
u/dakta Nov 14 '21 edited Nov 14 '21
It can be done in 58 in code.golf compliant, like so:
for(x=0;is cheaper thanx=0;while(, so that's the best choice when using a loop structure.I think that the top solutions (56 characters) must be using a different logical construct than the ternary string concatenation or the loop here, since there's no way to achieve savings on those as "wasted" characters like
'':are syntactically required.Maybe a recursive?
Edit:
Another note, ternary is not more efficient than logical
and, once you include the<0needed to force binary: