GIVE ME A FIZZ BUZZ

GIVE ME A FIZZ BUZZ

WITH
NO
IF
STATEMENT

Other urls found in this thread:

gist.github.com/reader1000/2551078
en.wikipedia.org/wiki/Precomputation
pastebin.com/a6UevGxC
raw.githubusercontent.com/Keith-S-Thompson/fizzbuzz-c/master/expected-output.txt').text)
twitter.com/SFWRedditImages

python
wordmap = dict()
for i in range(3,101, 3):
wordmap[i] = "Fizz"

for i in range(5,101, 5):
wordmap[i] = "Buzz"

for i in range(15,101, 15):
wordmap[i] = "FizzBuzz"

# some assertion to ensure that things are correct
assert wordmap.get(1, 1) == 1
assert wordmap.get(3, 3) == "Fizz"
assert wordmap.get(4, 4) == 4
assert wordmap.get(5, 5) == "Buzz"
assert wordmap.get(15, 15) == "FizzBuzz"
assert wordmap.get(27, 27) == "Fizz"
assert wordmap.get(55, 55) == "Buzz"
assert wordmap.get(90, 90) == "FizzBuzz"
assert wordmap.get(98, 98) == 98


for i in range(1,101):
print(wordmap.get(i,i))

Literally google
gist.github.com/reader1000/2551078

Think I give a fuck nigger?

Wow, someone is mad.

Haskell - a favorite
[max(show x)(concat[n|(f,n)

angry little shitstain

My own:
fizzbuzz = zipWith max nums (fizz /++ buzz)
where
nums = map show [1..]
(/++) = zipWith (++)
fizz = 2 !? "fizz"
buzz = 4 !? "buzz"
n !? w = cycle (replicate n "" ++ [w])

wow, rude.

for i=0-100
switch i
case i % 15 == 0
Etc etc

In what kind of degenerate language can you do this?

(define (fizzybuzzy limit)
(for ([i (in-range 1 limit)])
(cond [(= 0 (modulo i 3)) (printf "Fizz\n")]
[(= 0 (modulo i 5)) (printf "Buzz\n")]
[(= 0 (modulo i 15)) (printf "FizzBuzz\n")]
[else (printf "~a~n" i)])))

#include
#include
int main() {
char key[2][2][10] ={{"0","buzz"},{"fizz","fizzbuzz"}};
for (int i = 0; i

#include
#include

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

>"with no if statement"
>yfw haskell has no statements, just expressions
Merely answering in Haskell ensures victory

for x in range(100):print(x%3//2*'Fizz'+x%5//4*'Buzz' or x+1)

i=0
touch Maki #inappropriately
ln Maki 'a cute'
while [[ Maki -ef 'a cute' ]]; do
echo "$((i+1))\n$((i+2))\nFizz\n$((i+4))\nBuzz\nFizz\n$((i+7))\n$((i+8))\nFizz\nBuzz\n$((i+11))\nFizz\n$((i+13))\n$((i+14))\nFizzBuzz"
i=$((i+15))
done

(Print["Fizz"];Print["Buzz"];Print["FizzBuzz"];#0[])&[]

Just try running it ;^)

I'm crap at this. C.

void FizzBuzz(int x) {
while (x % 3 == 0) {
while (x % 5 == 0) {
printf("FizzBuzz\n");
return;
}
printf("Fizz\n");
return;
}
while (x % 5 == 0) {
printf("Buzzz\n");
return;
}
printf("%d\n", x);
}

int main() {
int x;
char string[9];
for (x = 1; x < 101; x++) {
FizzBuzz(x);
}
}

@echo off
:1
color 0a
echo Fizz Buzz
color 1b
echo Fizz Buzz
color 2c
echo Fizz Buzz
goto 1

count = 0
while (count < 101):
if (count % 5) == 0 and (count % 3) == 0:
print "FizzBuzz"
count = count +1
elif (count % 3) == 0:
print "Fizz"
count = count + 1
elif (count % 5) == 0:
print "Buzz"
count = count +1
else:
print count
count = count + 1

>i don't know how to read

isit (n%15 == 0) printf("FizzBuzz");
else isit (n%3 == 0) printf("Fizz");
else isit (n%5 == 0) printf("Buzz");

// en.wikipedia.org/wiki/Precomputation
var vals = [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14, "FizzBuzz", 16, 17, "Fizz", 19, "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26, "Fizz", 28, 29, "FizzBuzz", 31, 32, "Fizz", 34, "Buzz", "Fizz", 37, 38, "Fizz", "Buzz", 41, "Fizz", 43, 44, "FizzBuzz", 46, 47, "Fizz", 49, "Buzz", "Fizz", 52, 53, "Fizz", "Buzz", 56, "Fizz", 58, 59, "FizzBuzz", 61, 62, "Fizz", 64, "Buzz", "Fizz", 67, 68, "Fizz", "Buzz", 71, "Fizz", 73, 74, "FizzBuzz", 76, 77, "Fizz", 79, "Buzz", "Fizz", 82, 83, "Fizz", "Buzz", 86, "Fizz", 88, 89, "FizzBuzz", 91, 92, "Fizz", 94, "Buzz", "Fizz", 97, 98, "Fizz", "Buzz"];
for(var i=1, len=res.length; i

Maki Maki gimme that faki

Good one.

Kek

who this cute

Perl
for (1..100) {
while ($_ % 3 == 0) {
print "fizz";
last;
}
while ($_ % 5 == 0) {
print "buzz\n";
last;
}
print "\n";
}

ah bugger, buzz\n was just meant to be buzz

kek

>>> fuck = ['']*101
>>> for i in range(3,101,3):
... fuck[i] += 'fizz'
...
>>> for i in range(5,101,5):
... fuck[i] += 'buzz'
...
>>> for i in range(1,101):
... print fuck[i] or i
...

fn main() {
for i in 1..101 {
match (i % 3, i % 5) {
(0,0) => println!("FizzBuzz"),
(0,_) => println!("Fizz"),
(_,0) => println!("Buzz"),
_ => println!("{}", i),
}
}
}

use std::io::stdio::flush;
use std::io::timer::sleep;
use std::thread::Thread;
use std::time::duration::Duration;

fn main() {
let counter = Thread::spawn(|| -> () {
let mut i = 0u;
loop {
i = i + 1;
print!("\n{}", i);
flush();
sleep(Duration::seconds(1));
}
});

let fizzbuzz = Thread::spawn(|| -> () {
loop {
print!("\rfizzbuzz");
flush();
sleep(Duration::seconds(15));
}
});

let buzz = Thread::spawn(|| -> () {
loop {
print!("\rbuzz");
flush();
sleep(Duration::seconds(5));
}
});

let fizz = Thread::spawn(|| -> () {
loop {
print!("\rfizz");
flush();
sleep(Duration::seconds(3));
}
});

let _ = counter.join();
let _ = fizzbuzz.join();
let _ = buzz.join();
let _ = fizz.join();
}

import numpy as np
import tensorflow as tf

NUM_DIGITS = 10


def binary_encode(i, num_digits):
return np.array([i >> d & 1 for d in range(num_digits)])


def fizz_buzz_encode(i):
if i % 15 == 0: return np.array([0, 0, 0, 1])
elif i % 5 == 0: return np.array([0, 0, 1, 0])
elif i % 3 == 0: return np.array([0, 1, 0, 0])
else: return np.array([1, 0, 0, 0])

trX = np.array([binary_encode(i, NUM_DIGITS) for i in range(101, 2 ** NUM_DIGITS)])
trY = np.array([fizz_buzz_encode(i) for i in range(101, 2 ** NUM_DIGITS)])


def init_weights(shape):
return tf.Variable(tf.random_normal(shape, stddev=0.01))

def model(X, w_h, w_o):
h = tf.nn.relu(tf.matmul(X, w_h))
return tf.matmul(h, w_o)

X = tf.placeholder("float", [None, NUM_DIGITS])
Y = tf.placeholder("float", [None, 4])

NUM_HIDDEN = 100
w_h = init_weights([NUM_DIGITS, NUM_HIDDEN])
w_o = init_weights([NUM_HIDDEN, 4])
py_x = model(X, w_h, w_o)
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(py_x, Y))
train_op = tf.train.GradientDescentOptimizer(0.05).minimize(cost)
predict_op = tf.argmax(py_x, 1)

def fizz_buzz(i, prediction):
return [str(i), "fizz", "buzz", "fizzbuzz"][prediction]

BATCH_SIZE = 128

with tf.Session() as sess:
tf.initialize_all_variables().run()

for epoch in range(10000):
p = np.random.permutation(range(len(trX)))
trX, trY = trX[p], trY[p]

for start in range(0, len(trX), BATCH_SIZE):
end = start + BATCH_SIZE
sess.run(train_op, feed_dict={X: trX[start:end], Y: trY[start:end]})


print(epoch, np.mean(np.argmax(trY, axis=1) ==
sess.run(predict_op, feed_dict={X: trX, Y: trY})))

numbers = np.arange(1, 101)
teX = np.transpose(binary_encode(numbers, NUM_DIGITS))
teY = sess.run(predict_op, feed_dict={X: teX})
output = np.vectorize(fizz_buzz)(numbers, teY)

print(output)

It does...

#include
#include

#define FIZZBUZZ_CASE(term) case term: printf("FizzBuzz"); break
#define FIZZ_CASE(term) case term: printf("Fizz"); break
#define BUZZ_CASE(term) case term: printf("Buzz"); break
#define EMPTY_CASE(term) case term:
#define NORMAL_CASE(term) case term: printf("%d", i); break

int main(void)
{
int i;
for (i = 1; i = 0) j = j - 15;

switch (j)
{
FIZZBUZZ_CASE(0);
EMPTY_CASE(1);
NORMAL_CASE(2);
FIZZ_CASE(3);
NORMAL_CASE(4);
BUZZ_CASE(5);
FIZZ_CASE(6);
EMPTY_CASE(7);
NORMAL_CASE(8);
FIZZ_CASE(9);
BUZZ_CASE(10);
NORMAL_CASE(11);
FIZZ_CASE(12);
EMPTY_CASE(13);
NORMAL_CASE(14);
}
printf("\n");
}

return 0;
}

Enumerable.Range(0, 1000).Select(x => x % 15 == 0 ? "FizzBuzz" : x % 5 == 0 ? "Buzz" : x % 3 == 0 ? "Fizz" : x.ToString()).ToList().ForEach(WriteLine);

LINQ is the best.

f = dict(zip(range(1,101), range(1,101)))
a = dict.fromkeys(list(filter(lambda n: n % 3 == 0, range(1, 101))), "fizz")
b = dict.fromkeys(list(filter(lambda n: n % 5 == 0, range(1, 101))), "buzz")
c = dict.fromkeys(list(filter(lambda n: (n % 15 == 0), range(1, 101))), "fizzbuzz")
d = {**a, **b, **c}

for key in d:
f[key] = d[key]

for key in f:
print(f[key])


It's shit! Should need python >= 3.5

Javascript. Too long to post here.

pastebin.com/a6UevGxC

PHP, 69 characters

I'm tired of seeing your tripfag 5 dollar bill ass all over this board. Something's gotta change.

no doubt

int range = 100;
for (int i = 1; i

.data
fizz_str: .asciiz "fizz\n"
buzz_str: .asciiz "buzz\n"
fizzbuzz_str: .asciiz "fizzbuzz\n"
newline_str: .asciiz "\n"

.text
ori $s0, $zero, 1
loop_st:
ori $s1, $zero, 15
div $s0, $s1
mflo $s1
mfhi $s2
ori $s1, $zero, 0
beq $s1, $s2, fizzbuzz
ori $s1, $zero, 3
div $s0, $s1
mfhi $s2
ori $s1, $zero, 0
beq $s1, $s2, fizz
ori $s1, $zero, 5
div $s0, $s1
mfhi $s2
ori $s1, $zero, 0
beq $s1, $s2, buzz
j int
fizzbuzz:
la $t0, fizzbuzz_str
jal print_s
j loop_end
fizz:
la $t0, fizz_str
jal print_s
j loop_end
buzz:
la $t0, buzz_str
jal print_s
j loop_end
int:
ori $t0, $s0, 0
jal print_i
loop_end:
addi $s0, $s0, 1
addi $s1, $s0, -100
bgtz $s1, finish
j loop_st
finish:
j finish
print_s:
li $v0, 4
ori $a0, $t0, 0
syscall
jr $ra
print_i:
li $v0, 1
or $a0, $zero, $t0
syscall
li $v0, 4
la $a0, newline_str
syscall
jr $ra


MIPS assembly. I ran it in QTSpim. Branch instructions are technically not "if" statements

This is trash.

fizzbuzz(_, 0, 0, 'fizzbuzz').
fizzbuzz(_, 0, _, 'fizz').
fizzbuzz(_, _, 0, 'buzz').
fizzbuzz(X, _, _, X). % yuno what it is

buzzmyanus(N) :-
FIZZ is N mod 3,
BUZZ is N mod 5,
fizzbuzz(N, FIZZ, BUZZ, R),
write(R), nl.

fizzmybuzz :-
foreach(between(1, 100, N), buzzmyanus(N)).

fizzbuzz(_, 0, 0, 'fizzbuzz').
fizzbuzz(_, 0, _, 'fizz').
fizzbuzz(_, _, 0, 'buzz').
fizzbuzz(X, _, _, X). % yuno what it is

buzzmyanus(N) :-
FIZZ is N mod 3,
BUZZ is N mod 5,
fizzbuzz(N, FIZZ, BUZZ, R),
write(R), nl.

fizzmybuzz :-
foreach(between(1, 100, N), buzzmyanus(N)).

Animefeces McGenericovna

>using the smiley with a carat nose

```
import requests
print(requests.get('raw.githubusercontent.com/Keith-S-Thompson/fizzbuzz-c/master/expected-output.txt').text)
```