Discuss Scratch

PkmnQ
Scratcher
1000+ posts

The shortest FizzBuzz YOU can make!

ScratchCatHELLO wrote:

PkmnQ wrote:

ScratchCatHELLO wrote:

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'
You can shave off one byte by removing the space before the or. Also, Pyth.
Pyth, 34 chars/bytes
V100|+*"Fizz"/%N3 2*"Buzz"/%N5 4hN
It'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.

this is still the shortest :o
That one was in a golfing language, where everything is supposed to be short.

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!

gosoccerboy5 wrote:

ScratchCatHELLO wrote:

for i=1,100do print(i%15==0and"FizzBuzz"or (i%3==0and"Fizz"or(i%5==0and"Buzz"or i)))end
save 5 bytes by removing other unnecessary spaces (at least i’m pretty sure those are unnecessary, assuming syntax is like python’s)
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?
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!

ScratchCatHELLO wrote:

where did they say they would remove it
in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error."
*I think they mean “In”

ScratchCatHELLO
Scratcher
1000+ posts

The shortest FizzBuzz YOU can make!

gosoccerboy5 wrote:

ScratchCatHELLO wrote:

where did they say they would remove it
in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error."
*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!

ScratchCatHELLO wrote:

gosoccerboy5 wrote:

ScratchCatHELLO wrote:

where did they say they would remove it
in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error."
*I think they mean “In”
what’s “it”?
full quote:
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.

wvj
Scratcher
1000+ posts

The shortest FizzBuzz YOU can make!

Bump

Greg8128
Scratcher
500+ posts

The shortest FizzBuzz YOU can make!

I optimized my previous Haskell fizzbuzz:
module Main where
import Control.Monad
main=forM_[1..100]$putStrLn.q mod;q(%)n|n%15<1="fizzbuzz"|n%3<1="fizz"|n%5<1="buzz"|1>0=show n

My best projects:

ScratchCatHELLO
Scratcher
1000+ posts

The shortest FizzBuzz YOU can make!

gosoccerboy5 wrote:

ScratchCatHELLO wrote:

gosoccerboy5 wrote:

ScratchCatHELLO wrote:

where did they say they would remove it
in the link I provided: "If [sic]* future releases it will be changed to syntax warning, and finally to a syntax error."
*I think they mean “In”
what’s “it”?
full quote:
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
wvj
Scratcher
1000+ posts

The shortest FizzBuzz YOU can make!

Bump

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

this is my page

I'm not active on scratch anymore, I moved on.
Greg8128
Scratcher
500+ posts

The shortest FizzBuzz YOU can make!

SonicFanX123_321 wrote:

0
1
2
Fizz
4
Buzz
Fizz
7
8
9
Buzz
11
Fizz
13
14
FizzBuzz
“0” should be “FizzBuzz” because 0 is divisible by 15.

My best projects:

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
тGNDD´3Öi"Fizz"ˆ}5Öi"Buzz"ˆ}¯JDõQiˆ},}
not particularly golfed.

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:
# a.bat
type a.bat
Bourne-Again Shell:
# 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!

hello_smile wrote:

Windows:
# a.bat
type a.bat
Bourne-Again Shell:
# 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!

TheSecondGilbert wrote:

hello_smile wrote:

Windows:
# a.bat
type a.bat
Bourne-Again Shell:
# a.sh
cat a.sh

that is not fizzbuzz
What is?

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!

hello_smile wrote:

TheSecondGilbert wrote:

hello_smile wrote:

Windows:
# a.bat
type a.bat
Bourne-Again Shell:
# a.sh
cat a.sh

that is not fizzbuzz
What is?
https://en.wikipedia.org/wiki/Fizz_buzz

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
{⎕←↑⍵[((⍴↑⍵[1])=0)+1]}¨{↑(,/((3 5|¨⍵)=0)/'Fizz' 'Buzz')⍵}¨⍳100
Try it online!

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!

NanoRook wrote:

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.
quality. i love it

Powered by DjangoBB