Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » The shortest FizzBuzz YOU can make!
- PkmnQ
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
That one was in a golfing language, where everything is supposed to be short.You can shave off one byte by removing the space before the or. Also, Pyth. bump
Python 3.9.5, 65 chars, and 65 bytes??for a in range(100):print('Fizz'*(a%3//2)+'Buzz'*(a%5//4) or a+1)
breakdown:for a in range(1, 100): #numbers from 1 to 100
print() #duh
'Fizz'*(a%3//2) #weird hack that adds one "Fizz" if a is divisible by three
+'Buzz'*(a%5//4) #ditto
or a+1 #my new favourite trick. if the rest of the string is empty (which happens when the number is not divisible by 3 or 5), the string is interpreted as False, which causes the string to be equal to a+1, because a+1 is True (I think)
demo of that last trick:>>> a = 5 >>> 'abc'*(int(a==5))or'xyz' 'abc' >>> a += 1 >>> 'abc'*(int(a==5))or'xyz' 'xyz'
Pyth, 34 chars/bytesIt's basically the same as the Python solution, but in Pyth. Of course, it isn't very interesting, so I'm actually working on a more interesting one in a different programming language.V100|+*"Fizz"/%N3 2*"Buzz"/%N5 4hN
this is still the shortest :o
This is an account that exists.
Here, have a useful link:
The Official List of Rejected Suggestions by Za-Chary
- ScratchCatHELLO
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
I tested it at https://lua.org/demo.html and it didn't work. didn't know you could do that in python. I thought python's syntax was supposed to make your code look clearer, why would they let you do that?save 5 bytes by removing other unnecessary spaces (at least i’m pretty sure those are unnecessary, assuming syntax is like python’s)for i=1,100do print(i%15==0and"FizzBuzz"or (i%3==0and"Fizz"or(i%5==0and"Buzz"or i)))end
oh, looks like they will eventually remove that feature anyways [/offtopic]
I didn’t test it (I don’t have access to a computer right now) and for some reason I thought putting a number next to a keyword would work (because symbols next to numbers work)
where did they say they would remove it
ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust
Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
- gosoccerboy5
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error." where did they say they would remove it
*I think they mean “In”
- ScratchCatHELLO
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error." where did they say they would remove it
*I think they mean “In”
what’s “it”?
ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust
Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
- gosoccerboy5
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
full quote:what’s “it”?in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error." where did they say they would remove it
*I think they mean “In”
Deprecation warning is now emitted when compiling previously valid syntax if the numeric literal is immediately followed by a keyword (like in 0in x). If future releases it will be changed to syntax warning, and finally to a syntax error. To get rid of the warning and make the code compatible with future releases just add a space between the numeric literal and the following keyword.
- ScratchCatHELLO
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
full quote:what’s “it”?in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error." where did they say they would remove it
*I think they mean “In”Deprecation warning is now emitted when compiling previously valid syntax if the numeric literal is immediately followed by a keyword (like in 0in x). If future releases it will be changed to syntax warning, and finally to a syntax error. To get rid of the warning and make the code compatible with future releases just add a space between the numeric literal and the following keyword.
what why
my disappointment is immeasurable and my day is ruined
ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust
Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
- SonicFanX123_321
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
0
1
2
Fizz
4
Buzz
Fizz
7
8
9
Buzz
11
Fizz
13
14
FizzBuzz
1
2
Fizz
4
Buzz
Fizz
7
8
9
Buzz
11
Fizz
13
14
FizzBuzz
- Raihan142857
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
I golfed my NASM fizzbuzz a bit more, here it is (427 characters)
%define m mov %macro x 2 m rax,rbx xor rdx,rdx m r9,%1 div r9 test rdx,rdx jz %2 %endmacro %macro y 2 %1:m rsi,%2 m rdi,i jmp e %endmacro global main section.text extern printf main:m rbx,1 m r12,100 a:x 15,b x 3,c x 5,d m rsi,rbx m rdi,j jmp e y b,h y c,f y d,g e:sub rsp,8 call printf add rsp,8 inc rbx dec r12 jnz a m rbx,0 m rax,1 int 0x80 section.data f:db"Fizz",0 g:db"Buzz",0 h:db"FizzBuzz",0 i:db"%s",10,0 j:db"%d",10,0
I use scratch.
GF: I'll dump you. BF: hex dump or binary dump?
- TheSecondGilbert
- Scratcher
100+ posts
The shortest FizzBuzz YOU can make!
here's 05AB1E
not particularly golfed.
тGNDD´3Öi"Fizz"ˆ}5Öi"Buzz"ˆ}¯JDõQiˆ},}
Hi! This is an alt of my main account.
I'm “back” from a 10-month hiatus.
I forgot the ways of the forums, so I might be wrong.
My first post!
- hello_smile
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
Windows:
Bourne-Again Shell:
# a.bat
type a.bat
# a.sh
cat a.sh
Last edited by hello_smile (Aug. 16, 2021 06:14:34)
hello_smile
Achievement: Rickrolled ogadaki.
set [alternate account] to [hello-smile]
hello-smile Signature logo shop
v86
The key to 1000 messages is following hundreds of forum topics.
I am tired of everyone hating on me!
Windows 11 Release
- TheSecondGilbert
- Scratcher
100+ posts
The shortest FizzBuzz YOU can make!
Windows:Bourne-Again Shell:# a.bat
type a.bat# a.sh
cat a.sh
that is not fizzbuzz
Hi! This is an alt of my main account.
I'm “back” from a 10-month hiatus.
I forgot the ways of the forums, so I might be wrong.
My first post!
- hello_smile
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
What is?Windows:Bourne-Again Shell:# a.bat
type a.bat# a.sh
cat a.sh
that is not fizzbuzz
hello_smile
Achievement: Rickrolled ogadaki.
set [alternate account] to [hello-smile]
hello-smile Signature logo shop
v86
The key to 1000 messages is following hundreds of forum topics.
I am tired of everyone hating on me!
Windows 11 Release
- TheSecondGilbert
- Scratcher
100+ posts
The shortest FizzBuzz YOU can make!
https://en.wikipedia.org/wiki/Fizz_buzzWhat is?Windows:Bourne-Again Shell:# a.bat
type a.bat# a.sh
cat a.sh
that is not fizzbuzz
Last edited by TheSecondGilbert (Aug. 16, 2021 07:16:45)
Hi! This is an alt of my main account.
I'm “back” from a 10-month hiatus.
I forgot the ways of the forums, so I might be wrong.
My first post!
- TheSecondGilbert
- Scratcher
100+ posts
The shortest FizzBuzz YOU can make!
Another one, this time:
APL (Dyalog Classic), 62 bytes
Try it online!
Not the best, but whatever.
Explanation later?
APL (Dyalog Classic), 62 bytes
{⎕←↑⍵[((⍴↑⍵[1])=0)+1]}¨{↑(,/((3 5|¨⍵)=0)/'Fizz' 'Buzz')⍵}¨⍳100
Not the best, but whatever.
Explanation later?
Hi! This is an alt of my main account.
I'm “back” from a 10-month hiatus.
I forgot the ways of the forums, so I might be wrong.
My first post!
- NanoRook
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
Every post here is inherently flawed. None of these code snippets would ever fit into a professional production environment. I invite you all to browse FizzBuzz Enterprise Edition and improve your code forthwith.
I LOVE BEING PURPLE!!!! JOIN THE PURPLE COALITION TODAY IF YOU ALSO LOVE BEING PURPLE. PURPLE IS THE NEW BLUE! PURPLE IS THE SUPERIOR NAVBAR COLOR! YYYEAAHHHHH BABY!!!!
- gosoccerboy5
- Scratcher
1000+ posts
The shortest FizzBuzz YOU can make!
FizzBuzz Enterprise Edition and improve your code forthwith.quality. i love it Every post here is inherently flawed. None of these code snippets would ever fit into a professional production environment. I invite you all to browse
- Discussion Forums
- » Advanced Topics
- » The shortest FizzBuzz YOU can make!