Code-golfing FizzBuzz

Those two solutions are neat.

Searching around for tips for code golfing in Julia, on the Code Golf StackExchange came across discussion for this problem. From the discussion it appears there is a 60char/bye solution using repr and there is a 59char/byte solution using "$x".

another whacky one (65)

1:100 .|>x->println(max("$x",join(("Fizz","Buzz")[x.%[3,5].<1])))
2 Likes

Well for what its worth I freed up one char/byte on

f="Fizz";b="Buzz";1:100 .|>i->println([i i f f*b b][gcd(i,15)%11])
with
1:100 .|>x->println((x,"FizzBuzz","Fizz",x,"Buzz")[gcd(x,15)%13])

2 Likes

Does it have to be short, or just weird:

t=1:100;t.|>println∘x->["$x","Fizz","Buzz","FizzBuzz"][Dict([1 3 5 0].*t.=>[1 2 3 4])[x%15]]
1 Like

Weird examples are certainly welcome. I’m sure they could get pretty weird, I really want to crack that 59 char/byte solution though.

This one is cool

This one is both weird and breaks all barriers (but of dubious correctness):

t=1:100;@.println(t,"\r","Fizz"^(t%3<1)*"Buzz"^(t%5<1))
6 Likes

This is very cool

Replacing \r with \b gives something visually almost correct

another hint from the leaderboard is that the smallest solution is 59bytes/59chars, so no unicode trickeries.
But there’s a shorter solution with 61bytes/57chars which may imply the use of ∘ (3bytes/1char)

1 Like

It has me pretty stumped, I’ve been working on it in-between writing stuff for my thesis.

I feel you xD
I have so many solutions 1byte from best on that website…it drives me crazy

1 Like

The most frustrating is when an idea seems potentially it then realize you’re at 61+ char/bytes haha.

If the approach is different share it even though is not the shortest one. Someone else could find a way to make it work

The primary different approach I have tried is to use something like
"$x FizzBuzz"[start condition:end condition] or another variation because besides using max to compare strings "$x" and "Fizz^(x%x<1)*"Buzz"^(x%5<1) not sure how using "$x" would help–given that at least one of the 59char/byte solutions involves using that interpolation.

the problem is that “$x” length will change, so a unique start condition is tricky…

on that line I have a 64

/ =gcd;1:100 .|>n->println(max("FizzBuzz"[7-2(3/n):3+5/n],"$n"))
4 Likes

Yeah that’s why I abandoned that approach.

That is a neat solution

putting together various ideas that appeared in previous posts …

 1:100 .|>i->println("$i\r","fizz"^(i%3<1),"buzz"^(i%5<1))
2 Likes

oddly this type of solution works correctly in the Julia REPL but if plugging in here Fizz Buzz it doesn’t.

in fact, it seemed too within the reach of previous posts to be overlooked

this is printing both digits and “fizz”/“buzz” instead of skipping either

also, code.golf checks the solution verbatim, thus \r != \n

it would have been nice to beat the record by 2 tho! :smiley:

So I know there is a 60 char/byte solution that uses repr and I got a 61byte/char so maybe analyzing it can give a hint how they got the 60 byte/char.
x=1:100;@.println(max("Fizz"^(1>x%3)*"Buzz"^(1>x%5),repr(x)))