3 ms·
Go (golang) - 157 characters/43 score package main import(o"fmt") func main(){s:=o.Print for i:=1;i<101;i++{f,b:=i%3==0,i%5==0 if!(f||b){s(i)}else{if
by georgemcbay 14y ago
Go (golang) - 157 characters/43 score
package main
import(o"fmt")
func main(){s:=o.Print
for i:=1;i<101;i++{f,b:=i%3==0,i%5==0
if!(f||b){s(i)}else{if f{s("Fizz")}
if b{s("Buzz")}}
s("\n")}}
Compiles and runs fine but obviously not go fmt compliant. I feel bad for even attempting it.
Seems like the score should vary by language, Go (thankfully) makes it hard to be too terse. And of course in Java you're doomed prior to writing a single line of real logic code
- tehzord 14y agoCouldn't resist: class Solution{public static void main(String[] a){for(int i=0;++i<101;)System.out.println(i%15==0?"FizzBuzz":i%3==0?"Fizz":i%5==0?"Buzz":i);}} 143 characters, 57 score
- deleted 14y ago[deleted]
- georgemcbay 14y agoNice. Lack of the ternary operator is the big sticking point I have with really compact Go solutions. OTOH, in real world code I'm glad to see it gone. Also just noticed the () on my import aren't needed, first one would have to be a space anyway but second one can be removed to get the character count down by one and a bit more jiggering of the if/else logic can shave another character: package main import o"fmt" func main(){s:=o.Print for i:=1;i<101;i++{if f,b:=i%3==0,i%5==0;(f||b){if f{s("Fizz")} if b{s("Buzz")}}else{s(i)} s("\n")}}