/golf/

Write the shortest FizzBuzz in your favorite language.

Attached: 1527344555462.jpg (1600x1120, 160K)

Boobs

Her chest reminds me of the cores in Armored Core.

One, two, fizz, four, buzz, fizz, seven, eight, fizz, buzz, eleven, fizz, thirteen, fourteen, fizzbuzz, sixteen, seventeen, fizz, nineteen, buzz, fizz, twenty two, twenty three, fizz, buzz, twenty six, fizz, twenty eight, twenty nine, fizzbuzz...

I like English.

import fizzbuzz
fizzbuz.fizzbuzz()

Attached: 1527282301544.png (1000x1000, 988K)

numbers = range(1,16)
for number in numbers:
if number % 3 == 0:
print("fizz")
elif number % 5 == 0:
print("buzz")
elif number % 3 == 0 and number % 5 == 0:
print("fizzbuz")
else:
print(number)

>in your favorite language.
I like greek.
ΦιζζΜπαζζ

rules={'3':'fizz','5':'buzz'}

def main():
for n in range(100):
i=n
for key in rules:
if (n % int(key) == 0):
try:
i+=rules[key]
except TypeError:
i=rules[key]
print(i)

if __name__ == '__main__':
main()

Attached: 1488077765498s.jpg (250x164, 6K)

is that python?

holy shit that looks disgusting

Attached: Tulips.jpg (1024x768, 606K)

>Disgusting
Explain

I am disgusted when I look at it, user.

Ok, retard.

HTML is my language
p{counter-increment:f}p:not(:nth-of-type(5n)):before{content:counter(f)}p:nth-of-type(3n):before{content:"Fizz"}p:nth-of-type(5n):after{content:"Buzz"

What the fuck

She has since had breast reduction surgery

Nice

But that's CSS.

D: why

numbers = range(1,16)
for number in numbers:
if number % 3 == 0:
print("fizz")
elif number % 5 == 0:
print("buzz")
elif number % 3 == 0 and number % 5 == 0:
print("fizzbuz")
else:
print(number)

I made another one
rules={'3':'fizz','5':'buzz'}

def main():
for n in range(100):
i=n
for key in rules:
if (n % int(key) == 0):
try:
i+=rules[key]
except TypeError:
i=rules[key]
print(i)

if __name__ == '__main__':
main()


here's a third one I quickly made
p{counter-increment:f}p:not(:nth-of-type(5n)):before{content:counter(f)}p:nth-of-type(3n):before{content:"Fizz"}p:nth-of-type(5n):after{content:"Buzz"

kek

Saitan no FizzBuzz

Attached: tumblr_static_dzjflr3e65cg4cgw8oog400os.gif (250x250, 1.1M)

Javascript is superior
function fizzbuzz(number) {
return !!(number % 3) ? (!!(number % 5) ? number : 'buzz') : (!!(number % 5) ? 'fizz' : 'fizzbuzz')
}
fizzbuzz(15); // "fizzbuzz"

What do I win? Oh,code first:

for i in {1..100};{((i%3))&&x=||x=Fizz;((i%5))||x+=Buzz;echo ${x:-$i};}

die+map{(Fizz)[$_%3].(Buzz)[$_%5]||$_}1..100

Courtesy of perlmonks.org/?node_id=602901

>die

probably the indentation stack you got going on

int main()
{
char buf[100];
for (int i = 1; i

It won't execute properly without that

function fuzzbizz ( bool fizz ) {
if( fizz ) { return buzz; }
else { return fizz; }
}

(You)

thanks

(defun fb (fn i)
(dotimes (x i)
(cond ((and (mod x 3) (mod x 5)) (funcall fn "fizzbuzz")
(mod x 3) (funcall fn "fizz")
(mod x 5) (funcall fn "buzz")
t (funcall fn x)))))

(fb #'(lambda(str) (format t "~A~%" str)) 100)

for(var i = 1; i

i=0;exec"print i%3/2*'Fizz'+i%5/4*'Buzz'or-~i;i+=1;"*100

Anytime :3

const wtf = () => new Array(100).fill().forEach((_, i) => console.log(fb(i+1)))

const fb = num => {
if (!((num % 5) + (num % 3))) return 'fizzbuzz'
if (!(num % 5)) return 'buzz'
if (!(num % 3)) return 'fizz'
return num
}

wtf()

>golf
>actually tennis
I'll try C#:
string f(n){string r="";if(n%3==0)r+="fizz";if(n%5==0)r+="buzz";return r;}
for(int i=1;i

more javascript is shit edition

const wtf = () => new Array(100).fill().forEach((_, i) => console.log(fb(i+1)))

const fb = num => `${!(num % 3) ? `fizz` : ``}${!(num % 5) ? `buzz` : ``}` || num

wtf()

Attached: Selection_304.png (459x1337, 22K)

for(i=0;i++

new Array(100).fill().map((_,i)=>[i].reduce((a,j)=>(((j+a)%3?'':'Fizz')+((j+a)%5?'':'Buzz')||j+a),1)).forEach(i=>console.log(i))

6 shorter

for(i=0;i++

You is stoled my code u_u

>favorite language
Well then
泡腾嗡嗡

3:fizz
5:buzz
1,100

old simona best simona

rip
she spat in the face of god

Attached: 1527361574250.jpg (1138x1600, 272K)

FizzBuzz

russian is pretty nice too
физбyз

def fizzbuzz(n):
r = [(3, 'fizz'), (5, 'buzz')]
print("\n".join(["".join([s for i, s in r if not c % i]) or str(c) for c in range(1,n + 1)]))

what font?

>powershell

1..100|%{(($t="Fizz"*!($_%3)+"Buzz"*!($_%5)),$_)[!$t]}

tewi

Boobs were too large and were preventing her from playing high-level tennis.

She did get to rank 1 after that.

>can't even program a working fizzbuzz in python
Pretty sad desu.

def fizzbuzz(n):
for i in range(1, n+1): print("Fizz"*(i%3==0) + "Buzz"*(i%5==0) or i)

>/golf/
>picture is tennis
you had on fucking job

{-# LANGUAGE UndecidableInstances, TypeOperators, TypeFamilies, DataKinds, FlexibleInstances #-}
import GHC.TypeLits

data Fizz ; data Buzz ; data FizzBuzz ; data Number (i :: Nat)

class FzC (i :: Nat) where type FzPred i :: Nat ; type Fz i
instance FzC 0 where type FzPred 0 = 2 ; type Fz 0 = Fizz
instance FzC 1 where type FzPred 1 = 0 ; type Fz 1 = ()
instance FzC 2 where type FzPred 2 = 1 ; type Fz 2 = ()

class BzC (i :: Nat) where type BzPred i :: Nat ; type Bz i
instance BzC 0 where type BzPred 0 = 4 ; type Bz 0 = Buzz
instance BzC 1 where type BzPred 1 = 0 ; type Bz 1 = ()
instance BzC 2 where type BzPred 2 = 1 ; type Bz 2 = ()
instance BzC 3 where type BzPred 3 = 2 ; type Bz 3 = ()
instance BzC 4 where type BzPred 4 = 3 ; type Bz 4 = ()

type family FzBz1 (i :: Nat) f b where
FzBz1 i () () = Number i
FzBz1 i Fizz Buzz = FizzBuzz
FzBz1 i a () = a
FzBz1 i () b = b

type family FzBz (i :: Nat) (f :: Nat) (b :: Nat) where
FzBz 0 f b = ()
FzBz n f b = (FzBz (n - 1) (FzPred f) (BzPred b), FzBz1 n (Fz f) (Bz b))

type Main = FzBz 100 1 0
m :: Main
m = ""

Attached: gscreenshot_2018-05-26-183524.png (1229x1038, 45K)

2 WORDS
THE FORCED INDENTATION OF CODE!

Fizzbuzz has goten boring. Let's try a different approach:
var nums = [];
for(let i = 1; i

sugi pula IF

Never thought of using CSS. Clever.

for( int x = 3, x

oh wow

#include

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

(defun divisible? (dividend divisor)
(= (mod dividend divisor) 0))

;; `(string+ var s)` is equivalent to `var += s` in other languages
(defmacro string+ (varname toconcat)
`(setf ,varname (concatenate 'string ,varname ,toconcat)))

(defmacro fizzbuzz (max &body cases)
`(loop for i from 1 to ,max do
(let ((output ""))
,@(loop for case in cases collecting
`(if (divisible? i ,(first case))
(string+ output ,(second case))))
(if (string-equal output "") (setf output i))
(format t "~A~%" output))))

(fizzbuzz 100
(3 "Fizz")
(5 "Buzz")
;; add whatever the hell else you want mate
(7 "Fluzz"))


Not the shortest, but it's my favorite. One of the first code snippets I wrote while learning Common Lisp

Attached: jojo.png (165x256, 30K)

...

I was expecting "The Heart". 0/10

PROGRAMF
INTEGERn
DOn=1,100
IF(MOD(n,15).EQ.0)THEN
PRINT*,'FIZZBUZZ'
ELSEIF(MOD(n,5).EQ.0)THEN
PRINT*,'BUZZ'
ELSEIF(MOD(n,3).EQ.0)THEN
PRINT*,'FIZZ'
ELSE
PRINT*,n
ENDIF
ENDDO
END

import.fizzbuzz
print(fizzbuzz)

in C:
#include
int main() {
for (int i=0;++i

for(let i=0;i

mommy

Attached: DVDadDCV4AAV7Nt.jpg (693x480, 36K)

>all these unwashed plebians
Learn APL
{∊(3↑(0=3 5|⍵)∪1)/'Fizz' 'Buzz'⍵}¨⍳20

Very clever but what does the !! syntax do? Double negation?

learn ATS

Casts it into 1 or 0

>Very clever but what does the !! syntax do?
How come brainlets on Jow Forums don't understand how to cast a truthy/falsey value a boolean value?

!!(falseyValue) == !(true) == false
!!(truthyValue) == !(false) == true

>his language does not support slice assignment
nums = list(range(1,101))
nums[2::3] = ['fizz'] * int(100 / 3)
nums[4::5] = ['buzz'] * int(100 / 5)
nums[14::15] = ['fizzbuzz'] * int(100 / 15)
print("\n".join([str(c) for c in nums]))

...

Please explain

Figured it out, but how on earth do you come up with this?

I didn't come up with it. I found it in another thread.
I guess the idea was to start with "FizzBuzz%d".
Then you write a null byte to the right position to terminate the string after Fizz, FizzBuzz, or the number.
When printing the pointer is set to the right start index, that is, from Fizz, Buzz, or the number.
Setting it up in such a way that the null byte is written to the correct position and that printing starts at the right index needs some clever hacking.
Not sure how people come up with that.

lol you suck

void fizz_buzz_3(size_t out_len)
{
for(size_t i=1; i

I've never seen anyone initialize booleans using the {} syntax.