by georgemcbay · 13y ago · 0 comments
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
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 scoreOTOH, 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")}}