/fbg/ FizzBuzz General

let's see yours

That seems rather impractical, how did you do it?

>Font in OP's webm isn't fixed width

this physically hurts me to watch it..

>atom

>being this disgusting
why even live?

this was physically painful to watch.

>var
>not let

Non-strict equality sign used. Disqualified from teh job interview.

Is that fucking Comic Sans?

for (int i = 1; i

Let's see how many times it reaches i%15

> i % 15 at the end
nice desu

bruh...

for (int i = 1; i

kill yourself

maybe he only likes fizz

Damn I could hear the thumps on every keystroke

...

What a clusterfuck

Why does it have that faggy animation? Why is he using comic sans?

def fizzbuzz(n):
out = ""
for i in range(0, n):
if i % 3 == 0:
out += "Fizz"
if i % 5 == 0:
out += "Buzz"
if out =="":
print (i)
else:
print(out)
out = ""

fizzbuzz(100)


Meh I don't like checking equality with a string but I also don't want to use else-if

...

because op barely learned to program and is still fascinated by letters, parens, and braces

Dat indentation tho

>re
>tard
>ed
Just give up

for i in range(1, 101):
print "FizzBuzz"[i * i % 3 * 4:8 - -i ** 4 % 5] or i

>being this retarded

You know that if something is divisible by 3 and 5 it is divisible by 15 right?

print ' '.join(['fizzbuzz' if not i%15 else 'fizz' if not i%3 else 'buzz' if not i%3 else str(i) for i in range(1,101)])

Python wins again gents, game over you can go home.

DON'T STAB ME BIRD!
NUMBERS = 100

def getFizzBuzz(number):
if number % 15 == 0:
return "'fizzbuzz'"
elif number % 3 == 0:
return "'fizz'"
elif number % 5 == 0:
return "'buzz'"
else:
return "i"


print("for i in range(1,%i):" % NUMBERS)
for i in range(1,NUMBERS+1):
if i == 1:
print(" if i == %i:\n print(%s)" % (i,getFizzBuzz(i)))
else:
print(" elif i == %i:\n print(%s)" % (i,getFizzBuzz(i)))

First 3 is obvioulsy a 5, inb4 typo I'll fucking cut you niggers

why not i = 0; i < 100?
Also can you explain the bit manipulation? I'm about to collapse.

How can snakes even compete?
for(n=0;++n

...

>i cant read trinary operators

people like OP only have heard of fizzbuzz because of Sup Forums and never actually had an enriching childhood

the whole point of this children's game is to teach you that things that are divisible by 3 and 5 are exactly things that are divisible by 15

fucking dumb as fuck

>people like OP only have heard of fizzbuzz because of Sup Forums and never actually had an enriching childhood
Or maybe he lives in a country where we use different methods to teach division?

I wrote this a long time ago:
(defun fizzbuzz ()
(interactive)
(let ((fizz nil)
(buzz nil))
(dotimes (counter 101)
(when (not (= counter 0))
(insert (format "%s%s%s\n"
(if (setq fizz (= (mod counter 3) 0))
"Fizz" "")
(if (setq buzz (= (mod counter 5) 0))
"Buzz" "")
(if (not (or fizz buzz))
(number-to-string counter) "")))))))

You're an idiot. What is your reasoning? You don't understand it therefore it must be stupid, right? It's not even complicated, you are just retarded

>teach division
In any place that fucking matters, you don't get "taught" division until way later. Fizzbuzz is kindergarten shit.

Whta the fuck is that shit?

It's Emacs Lisp.

In any case atleast in my european country we never did fizzbuzz in kindergarten

i, i, fizz, i, buzz, fizz, i, i... can be written as:
00, 00, 01, 00, 10, 01, 00, 00...

Make it go from right to left and you get:
110000010010010000011000010000

which is the magic number 810092048


Each loop mods and shifts i to figure out the offset within the sequence m to extract, then shifts m right that far and masks it with 3 (0b11). The 00, 01, 10, or 11 then just pulls out the string from the array to print directly.

#include

int main(){
printf("1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n79\nBuzz\nFizz\n82\n83\nFizz\nBuzz\n86\nFizz\n88\n89\nFizzBuzz\n91\n92\nFizz\n94\nBuzz\nFizz\n97\n98\nFizz\nBuzz");
}

int main(void)
{
int i;
for(i=1;i

yes :)

#include "Display.h"

void setup() {
ht1632_setup();
}

void loop() {
for (int i = 1; i < 101; i++) {
if (floatdiv(i, 15) == (i / 15)) {
showText("FizzBuzz");
} else if (floatdiv(i, 3) == (i / 3)) {
showText("Fizz");
} else if (floatdiv(i, 5) == (i / 5)) {
showText("Buzz");
} else {
char c[4];
sprintf(c, "%d", i);
showText(c);
}

delay(500);
}
}

float floatdiv(int a, int b) {
return (float) a / (float) b;
}

void showText(const char str[]) {
char output[10];
memset(output, 0, 10);
strcpy(output, str);
for (int i=0; i < 10; i++) {
ht1632_putchar(0+6*i, 0, output[i], GREEN);
}
}
Mine doesn't use modulus for no apparent reason.

0x1241843 looks better imo
00 00 01 00 10 01 00 00 01 10 00 01 00 00 11

Stacking multiple ternary operators in one line is obvious bad practice. Code like that doesn't get merged into any serious project because it sacrifices readability for being concise while the entire purpose of concise code is readability.

don't mind me

That || operator is the most cringey thing in the whole fucking world.
>falsy values

That only works if you work with mentally-challenged people.

...

...

>if 3, if 5
>not if 15

okay

>sacrifices readability
No, it doesnt. it literally took me one second to see through, faggot

>his IDE doesn't have a Graduate button

for num in range(1,100):
fizz = num % 3 == 0;
buzz = num % 5 == 0;

if fizz && buzz:
print ('FizzBuzz')
elif fizz:
print ('Fizz')
elif buzz:
print ('Buzz')
else:
print num

there is probably easier ways to do it, but this is how i'd do it.

Fuck I just found out python does the same

for i in range(1,101):
print ('fizz' if not i%3 else '') + ('buzz' if not i%5 else '') or i

You'd just fail to comply to any code style guide for a reason. Stacking your logic extremely horizontally is pretentious bullshit.

Reasoning like
>i see it through in 0.3 because I'm great
is great for writing hacky code.

>only space before new line
>no tabs

kys 2bh familia

...

>he uses wubdiws 19

wtf is a %i

Since the loop only has one line, this is okay too:
for i in range(1,101): print ('fizz' if not i%3 else '') + ('buzz' if not i%5 else '') or i

equivalent of %d for use with printf.

i need it for audio stuff. don't like osx, next to no driver support on linux.

One of the many reasons why C should die, like %n.

class FizzBuzzCommandlet extends Commandlet;

event int Main(string Parms)
{
local int i;
local string S;

while(i++ < 100)
{
S = "";
if(i % 3 == 0)
S $= "Fizz";
if(i % 5 == 0)
S $= "Buzz";
Log(Eval(S=="",i,S));
}
return 0;
}

#include
int main() {
for (int i=1; i

What is the obsession with FizzBuzz?
Haven't we discussed this way too many times?

could someone explain me why the interpreter reports an error regarding the heredoc?

fizzbuzz = {5:"buzz",3:"fizz"}
z=0
for x in range(1,100):
print()
for num, fb in enumerate(fizzbuzz):
if x%fb==0:
z+=1
print(fizzbuzz[list(fizzbuzz.keys())[num]], end='')
continue
print()
if z == 0:print(x)
z=0

#include
int main(){for(int i=1;i

When you push the graduate button, it prints out pic related.

private static void FizzBuzz(string size)
{
int tam = int.Parse(size);
for (int i = 1; i

You!

same i actually feel like someone's drilling into my skull whenever atom webms are posted

You fucked up. Try again.

> void main
why not int main?

Explain

fucking wizardry in here

It is because it is the tool braindead HR people use to hire programmers since they know nothing about it themselves and thus is so common during job interviews.

Because there is no return statement.

How shitty is my code?

for n in range(1, 101):
if n % 15 == 0:
print "FizzBuzz"
elif n % 3 == 0:
print "Fizz"
elif n % 5 == 0:
print "Buzz"
else:
print n
raw_input()

...

body{counter-reset: item}
span{counter-increment: item; font-family: Helvetica; font-weight: 300}
span:before{content: counter(item) ", "}
span:not(:last-of-type):nth-of-type(3n):before{content: "Fizz, "}
span:not(:last-of-type):not(:nth-of-type(3n)):nth-of-type(5n):before{content: "Buzz, "}
span:not(:last-of-type):nth-of-type(15n):before{content: "FizzBuzz, "}
span:nth-of-type(5n):last-of-type:before{content: "Buzz."}
span:nth-of-type(3n):last-of-type:before{content: "Fizz."}
span:nth-of-type(15n):last-of-type:before{content: "FizzBuzz."}
span:last-of-type:before{content: counter(item) "."}
a=i='';for(;i

...

Read the doc

Which variant sucks less?
if(i%15==0) benis = "FizzBuzz";
else if(i%3==0) benis = "Fizz";
else if(i%5==0) benis = "Buzz";
else benis = i;
console.log(benis+"\n");

or
benis = "";
if(i%3==0) benis += "Fizz";
if(i%5==0) benis += "Buzz";
if(benis=="") benis = i;
console.log( benis=="" ? i : benis);

Also if i ever get a job interview with fizzbuzz, should i rather strive for performance or readability?

readability

once a retard from here wrote a 1 line fizzbuzz program in an interview, and they hired the guy who wrote pseudo code

would be better than
console.log(Array.apply(null, Array(100)).map((a,b) => {return (++b%3?'':'Fizz')+(b%5?'':'Buzz')||b;}).join(' '))

I changed up your code a bit and made it shorter:




span {
counter-increment: item;
}
span:before {
content: counter(item);
}
span:nth-of-type(3n):before {
content: "Fizz";
}
span:nth-of-type(5n):after {
content: "Buzz";
}
span:nth-of-type(5n):not(:nth-of-type(3n)):before {
content: "";
}


for (i = 1; i < 101; i++)
document.body.innerHTML+= "";

Yeah i thought so..
But i like this one-liner nontheless
for(i=0;++i

eh
you lost all punctuation
and numbers still show up with fizzbuzz part
and you can just write block elements instead of inline elements + br
this would be better

body{counter-reset: item}
div{counter-increment: item; font-family: Helvetica; font-weight: 300; font-size: 0}
div:not(:nth-of-type(3n)):not(:nth-of-type(5n)):before{content: counter(item) ""; font-size: initial}
div:nth-of-type(3n):before{content: "Fizz"; font-size: initial}
div:nth-of-type(5n):after{content: "Buzz"; font-size: initial}
document.write(Array.apply(null, Array(100)).map(() => '').join(''))

wait fuck i dont need fontsize with those too

body{counter-reset: item}
div{counter-increment: item; font-family: Helvetica; font-weight: 300}
div:not(:nth-of-type(3n)):not(:nth-of-type(5n)):before{content: counter(item) ""}
div:nth-of-type(3n):before{content: "Fizz"}
div:nth-of-type(5n):after{content: "Buzz"}
document.write(Array.apply(null, Array(100)).map(() => '').join(''))

Script kid who can't actually program detected

it's fine, could be a bit more efficient but it works

The punctuation was wrong, every number should be on a separate line.

How would you improve it? Despite the raw_input()