8 ms·
71 characters (129 points) with JavaScript. I actually wrote this quite a while back (and have also posted it on HN before) - code golf is pretty fun every now
by Hupo 14y ago
71 characters (129 points) with JavaScript. I actually wrote this quite a while back (and have also posted it on HN before) - code golf is pretty fun every now and then!
for(var i=0;i++<100;console.log(((i%3?'':'Fizz')+(i%5?'':'Buzz'))||i));
For anyone else interested in doing code golf with JavaScript, here's a goldmine of byte-saving techniques:
https://github.com/jed/140bytes/wiki/Byte-saving-techniques https://github.com/jed/140bytes/wiki/Byte-saving-techniques
- ricardobeat 14y agoGood, now everyone can just copy & paste it and the competition is a tie ;)
- xymostech 14y agoI came up with for(i=0;i<100;)console.log((++i%3?"":"Fizz")+(i%5?"":"Buzz")||i) earlier. 64 characters, because I don't have "var ", an extra set of parens, and a semicolon. Worse syntax, but hey, it's code golf.
- Hupo 14y agoI knew I could also drop the "var ", but I like to operate within the 140bytes challenge rules that say you're not allowed to leak into the global scope. I'll give you the 3 chars from the parens and semicolon, though - I got caught up with the idea of "hey, you can do this whole thing inside the for statement itself!" back when I did this!
- deleted 14y ago[deleted]
- tobr 14y agoMine was almost identical, except with i++<100 instead of ++i%3? etc. Also 64 characters. But is there really no way to end the ternary operators without parenthesis?