[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Show me your FizzBuzz, /g/. Lua: for i = 1, 100, 1 do if

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 88
Thread images: 11

File: mfwthisisastick.png (72KB, 402x443px) Image search: [Google]
mfwthisisastick.png
72KB, 402x443px
Show me your FizzBuzz, /g/.

Lua:
for i = 1, 100, 1 do
if i % 3 == 0 then
if i % 5 == 0 then
print("Fizzbuzz")
else
print("Fizz")
end
else
if i % 5 == 0 then
print("Buzz")
end
end
end


C:
int main() {
char* t[4];
t[0] = "";
t[1] = "Fizz\n";
t[2] = "Buzz\n";
t[3] = "FizzBuzz\n";

int i;
for (i = 1; i <= 100; i++) {
printf("%s", t[(i % 3 == 0) + (i % 5 == 0) * 2]);
}

return 0;
}
>>
>>58816443
But anon, you've just failed FizzBuzz, twice. You're supposed to print the number if none of the conditions hold.
This is one of the major reasons a lot of people fail this stupid test: they simply cannot be bothered to read a fucking sentence from start to finish.
>>
File: 1486348203925.png (16KB, 211x280px) Image search: [Google]
1486348203925.png
16KB, 211x280px
>>58816443
Now now where's the rest of it
>>
>>58816771
Reading comprehension is part of the test. These tests can be intentionally worded to be difficult to understand specifically to test for this ability.
>>
CMD
@echo off
setlocal EnableDelayedExpansion
set count=0
for /L %%i in (1,1,100) do (
set /A count+=1
echo !count!
set /A zz=!count!%%3
if !zz! EQU 0 echo Fizz
set /A zz=!count!%%5
if !zz! EQU 0 echo Buzz
echo.
)
>>
#!/usr/bin/env node

console.log('1')
console.log('2')
console.log('Fizz')
console.log('4')
console.log('Buzz')
console.log('Fizz')
console.log('7')
console.log('8')
console.log('Fizz')
console.log('Buzz')
console.log('11')
console.log('Fizz')
console.log('13')
console.log('14')
console.log('FizzBuzz')
console.log('16')
console.log('17')
console.log('Fizz')
console.log('19')
console.log('Buzz')
console.log('Fizz')
console.log('22')
console.log('23')
console.log('Fizz')
console.log('Buzz')
console.log('26')
console.log('Fizz')
console.log('28')
console.log('29')
console.log('FizzBuzz')
console.log('31')
console.log('32')
console.log('Fizz')
console.log('34')
console.log('Buzz')
console.log('Fizz')
console.log('37')
console.log('38')
console.log('Fizz')
console.log('Buzz')
console.log('41')
console.log('Fizz')
console.log('43')
console.log('44')
console.log('FizzBuzz')
console.log('46')
console.log('47')
console.log('Fizz')
console.log('49')
console.log('Buzz')
console.log('Fizz')
console.log('52')
console.log('53')
console.log('Fizz')
console.log('Buzz')
console.log('56')
console.log('Fizz')
console.log('58')
console.log('59')
console.log('FizzBuzz')
console.log('61')
console.log('62')
console.log('Fizz')
console.log('64')
console.log('Buzz')
console.log('Fizz')
console.log('67')
console.log('68')
console.log('Fizz')
console.log('Buzz')
console.log('71')
console.log('Fizz')
console.log('73')
console.log('74')
console.log('FizzBuzz')
...
>>
>>58816443
Java

for(int i = 1; i <= 100; i++)
{
String test = "";
test += (i % 3) == 0 ? "fizz" : "";
test += (i % 5) == 0 ? "buzz" : "";
System.out.println(!test.isEmpty() ? test : i);
}
>>
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1 {
class Program {

delegate String FB(int n);

static void Main(string[] args) {
FB toPrint = fizzbuzz;
for (int i = 0 ; i < 100 ; i++)
Console.WriteLine(toPrint(i));
Console.ReadKey();
}

static String fizzbuzz(int n) {
String s = "";
if(n % 3 == 0)
s += "Fizz";
if (n % 5 == 0)
s += "Buzz";
return (s == "") ? n.ToString() : s;
}
}
}
>>
#include <stdio.h>
#define LEFT_BRACE {
#define RIGHT_BRACE }
#define LEFT_BRACKET [
#define RIGHT_BRACKET ]
#define LEFT_PARENTHESIS (
#define RIGHT_PARENTHESIS )
#define SEMICOLON ;
#define COMMA ,
#define EQUALS =
#define IS_EQUAL_TO ==
#define IS_NOT_EQUAL_TO !=
#define IS_LESS_THAN <
#define IS_GREATER_THAN >
#define IS_LESS_THAN_OR_EQUAL_TO <=
#define IS_GREATER_THAN_OR_EQUAL_T >=
#define MODULUS %
#define INCREMENT ++
#define DECREMENT --
#define AND &&
#define OR ||

int main LEFT_PARENTHESIS RIGHT_PARENTHESIS
LEFT_BRACE
int i SEMICOLON
for LEFT_PARENTHESIS i EQUALS 0 SEMICOLON i IS_LESS_THAN_OR_EQUAL_TO 100 SEMICOLON i INCREMENT RIGHT_PARENTHESIS
LEFT_BRACE
if LEFT_PARENTHESIS i MODULUS 3 IS_NOT_EQUAL_TO 0 AND i MODULUS 5 IS_NOT_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "%d" COMMA i RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 3 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Fizz" RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 5 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Buzz" RIGHT_PARENTHESIS SEMICOLON

printf LEFT_PARENTHESIS " " RIGHT_PARENTHESIS SEMICOLON
RIGHT_BRACE

printf LEFT_PARENTHESIS "\n" RIGHT_PARENTHESIS SEMICOLON
return 0 SEMICOLON
RIGHT_BRACE
>>
>>58816443
### Functions ###
range = $(if $(filter $1,$(lastword $3)),$3,$(call range,$1,$2,$3 $(words $3)))
make_range = $(foreach i,$(call range,$1),$(call range,$2))
equal = $(if $(filter-out $1,$2),,$1)


### Variables ###
limit := 101
numbers := $(wordlist 2,$(limit),$(call range,$(limit)))

threes := $(wordlist 2,$(limit),$(call make_range,$(limit),2))
fives := $(wordlist 2,$(limit),$(call make_range,$(limit),4))

fizzbuzz := $(foreach v,$(numbers),\
$(if $(and $(call equal,0,$(word $(v),$(threes))),$(call equal,0,$(word $(v),$(fives)))),FizzBuzz,\
$(if $(call equal,0,$(word $(v),$(threes))),Fizz,\
$(if $(call equal,0,$(word $(v),$(fives))),Buzz,$(v)))))


### Target ###
.PHONY: all
all: ; $(info $(fizzbuzz))
>>
>>58820769
Perl is an ugly ass language
>>
>>58820795
I agree, but that's not Perl though
>>
(defun fizzbuzz ()
(loop for x from 1 to 100 for y = x do
(princ (format nil "~d~a~a~%"
(if (and (not (eq (mod x 3) 0)) (not (eq (mod x 5) 0)))
(format nil "~d" y) (format nil ""))
(if (eq (mod x 3) 0)
(format nil "Fizz") (format nil ""))
(if (eq (mod x 5) 0)
(format nil "Buzz") (format nil ""))))))
>>
>>58820433
I got a pretty good laugh out of this, thank you
>>
File: 1384293483728.png (133KB, 645x534px) Image search: [Google]
1384293483728.png
133KB, 645x534px
>>58820433
>>
>>58820433
This is what visual basic looks to me.
>>
let i=1;for(;i<=100;i++)console.log(!(i%3)&&!(i%5)?"FizzBuzz":(!(i%3)?"Fizz":(!(i%5)?"Buzz":i)))


needs to be as unreadable as possible
>>
>>58816443

Shitty C++ TMP version:

https://ideone.com/HPyxEb
>>
>>58818185
Not efficient enough. Should do until i < 101 instead of i <= 100
>>
>>58822907
let i=1,j;for (;i<=100;i++){j="";if(!(i%3))j+="Fizz";if(!(i%5))j+="Buzz";console.log(!!j?j:i)}

better
>>
>>58823094
>>58822907
Imperative plebs

Array.apply(null, {length: 100}).map(function (e,i) {return i+1}).map(function (e) {return e%3?e:"Fizz"}).map(function (e,i) {return (i+1)%5?e:(typeof(e)=="string"?e:"")+"Buzz"}).map(function(e) {console.log(e);return e})
>>

console.log(Array(100)
.fill()
.map((x, i) =>
((++i%3 === 0 ? 'Fizz' : '') + (i%5 === 0 ? 'Buzz' : '')) || i)
.join('\n'))
>>
>>58818141
Kek, have a you
>>
>>58823336
>>58823237

Array(100)
.fill("")
.map(
(e, i) => (i+1) % 3 ? e : "Fizz"
)
.map(
(e, i) => (i+1) % 5 ? e : e + "Buzz"
)
.map(
(e, i) => e ? e : i + 1
)
.forEach((e) => console.log(e))

>>
>>58823465
This actually looks beautiful, I thought functional programming in JavaScript was a /g/ meme...
>>
>>58822993

Less shitty TMP version:

https://ideone.com/HPyxEb

Still shitty though, my tmp skills are not quite there yet.
>>
>>58823539
>>58822993
Not so elegant as yours:
#include <cstdio>

template<bool> struct Value;

template< int n, typename = Value<true> >
struct fizzbuzz
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
printf("%d\n", n);
}
};

template <int n>
struct fizzbuzz< n, Value<(n == 0)> >
{
fizzbuzz() { }
};

template <int n>
struct fizzbuzz< n, Value<(n > 0 && n % 15 == 0)> >
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
puts("fizzbuzz");
}
};

template <int n>
struct fizzbuzz< n, Value<(n > 0 && n % 3 == 0 && n % 5 != 0)> >
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
puts("fizz");
}
};

template <int n>
struct fizzbuzz< n, Value<(n > 0 && n % 5 == 0 && n % 3 != 0)> >
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
puts("buzz");
}
};

int main()
{
fizzbuzz<100> fb;
return 0;
}
>>
>>58823539

#include <iostream>
#include <type_traits>

template<int N>
auto disp() -> typename std::enable_if<N % 3 && N % 5>::type
{
std::cout << N << "\n";
}

template<int N>
auto disp() -> typename std::enable_if<N % 3 == 0 && N % 5 == 0>::type
{
std::cout << "FizzBuzz\n";
}

template<int N>
auto disp() -> typename std::enable_if<N % 3 == 0 && N % 5>::type
{
std::cout << "Fizz\n";
}

template<int N>
auto disp() -> typename std::enable_if<N % 5 == 0 && N % 3>::type
{
std::cout << "Buzz\n";
}

template<int N>
struct FizzBuzz
{
void display()
{
prev.display();
disp<N>();
}
FizzBuzz<N-1> prev;
};

template<>
struct FizzBuzz<1>
{
void display()
{
disp<1>();
}
};


int main()
{
FizzBuzz<100> p;
p.display();
return 0;
}

>>
File: Al Bundy Yes.gif (476KB, 200x199px) Image search: [Google]
Al Bundy Yes.gif
476KB, 200x199px
>Oh boy, a fizzbuzz thread, whatever fun awaits me?

>>58820433

sasuga /g/
>>
>>58820769
>Make
Wait, what, how, wtf?

Make doesn't even have arithmetic, how the fuck?
>>
>>58823558

Long live templates

Also your usage of mixed puts and printf annoys me
>>
org 0x100
use16
xor cx, cx
begin:
inc cx
push 0
push 0x0d
push 0x0a
mov ax, cx
mov bx, 5
xor dx, dx
div bx
test dx, dx
jnz @f
push 0x7a
push 0x7a
push 0x75
push 0x42
@@: mov ax, cx
mov bx, 3
xor dx, dx
div bx
test dx, dx
jnz @f
push 0x7a
push 0x7a
push 0x69
push 0x46
@@: pop dx
cmp dx, 0x0a
push dx
jne fb
mov ax, cx
@@: mov bx, 10
xor dx, dx
div bx
add dl, '0'
push dx
test ax, ax
jnz @b
fb: mov ah, 6
@@: pop dx
test dl,dl
jz @f
int 0x21
jmp @b
@@: mov dx, 0xff
int 0x21
jz begin
mov ax, 0x4c00
int 0x21


what the fuck am i doing with my life.
>>
>>58823601

why are your labels '@@'?
>>
>>58823650
https://en.wikibooks.org/wiki/X86_Assembly/FASM_Syntax#Anonymous_Labels

tldr; lazy labels for lazy people
>>
File: image.png (109KB, 314x3409px) Image search: [Google]
image.png
109KB, 314x3409px
easy
>>
>>58820433
someone put this on the cs graduate meme
>>
>>58816443
Is Lua any good?
Can make shit with Lua?I don't wanna learn a 100 different languages for different things.
>>
>>58816443

OK but here is how one would actually do it with Lua:
("_"):rep(100):gsub("()_", function(i) print(("fizzbuzz"):sub(i % 3 == 0 and 0 or 5, i % 5 == 0 and 8 or 4):gsub("^$", i) .. "") end)
>>
#include<stdio.h>
int main () {
for(int i = 0; i < 100; i++) {
if(i%3==0)printf("Fizz");
else if(i%5==0)printf("Buzz");
else printf("%d",i);
}
return 0;
}
>>
>>58818141
This answer is web-scale.
>>
>>58824601
whoops extra else
#include<stdio.h>
int main () {
for(int i = 0; i < 100; i++) {
if(i%3==0)printf("Fizz");
if(i%5==0)printf("Buzz");
else printf("%d",i);
}
return 0;
}
>>
Pretty sure this works in MATLAB, didn't realize it'd be so similar to OP's:

for i = 1:100;
if rem(i,3) == 0
if rem(i,5) == 0
fprintf('FizzBuzz\n')
else
fprintf('Fizz\n')
end
elseif rem(i,5) == 0
fprintf('Buzz\n')
else
fprintf('%d\n',i)
end
end
>>
>>58824634
...This still doesn't work. Read this: https://www.rosettacode.org/wiki/FizzBuzz

And add some newlines.
>>
>>58820769
is that a fukken makefile
>>
curl "https://s3.amazonaws.com/fizzbuzz/output"
>>
++++++++++[>++++++++++<-]>>++++++++++>->>>>>>>>>>-->+++++++[->++++++++
++<]>[->+>+>+>+<<<<]+++>>+++>>>++++++++[-<++++<++++<++++>>>]+++++[-<++
++<++++>>]>-->++++++[->+++++++++++<]>[->+>+>+>+<<<<]+++++>>+>++++++>++
++++>++++++++[-<++++<++++<++++>>>]++++++[-<+++<+++<+++>>>]>-->---+[-<+
]-<<[->>>+>++[-->++]-->+++[---<-->+>-[<<++[>]]>++[--+[-<+]->>[-]+++++[
---->++++]-->[->+<]>>[.>]>++]-->+++]---+[-<+]->>-[+>++++++++++<<[->+>-
[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->->+<<]>[-]>[<++++++[-
>++++++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]]<<<.<]
>>
Smalltalk
1 to: 100 do: [:x | div3 := (x \\ 3 = 0) .
div5 := (x \\ 5 = 0) .
div3 ifTrue: ['fizz' display] .
div5 ifTrue: ['buzz' display] .
div3 | div5 ifTrue: ['' displayNl] ifFalse: [x displayNl]]
>>
Javascript, run in browser, F12 + paste it in console
(function foo(i){s='',(i%3==0&&(s+='Fizz'),i%5==0&&(s+='Buzz')),s||(s+=i),console.log(s),i<100&&foo(i+1)})(1)
>>
Enterprise FizzBuzz:

interface FizzBuzzable {
public int value();
public String doFizzBuzz();
}

final class FizzBuzzableNumber implements FizzBuzzable {
private final int num;
public FizzBuzzableNumber(int n) {
this.num = n;
}
public final int value() {
return this.num;
}
public final String doFizzBuzz() {
return new Integer(this.num).toString();
}
}

abstract class DivisibleNumber implements FizzBuzzable {
protected final FizzBuzzable original;
public DivisibleNumber(FizzBuzzable origin) {
this.original = origin;
}
public final int value() {
return this.original.value();
}
public final String doFizzBuzz() {
String fizzBuzzed = new String("");
if (this.isDivisible()) {
fizzBuzzed += this.fizzBuzzing();
} else {
fizzBuzzed += this.original.doFizzBuzz();
}
return fizzBuzzed;
}
protected abstract boolean isDivisible();
protected abstract String fizzBuzzing();
}

final class NumberDivisibleByThree extends DivisibleNumber {
public NumberDivisibleByThree(FizzBuzzable origin) {
super(origin);
}
protected final String fizzBuzzing() {
return "Fizz";
}
protected final boolean isDivisible() {
return ((this.value() % 3) == 0);
}
}

final class NumberDivisibleByFive extends DivisibleNumber {
public NumberDivisibleByFive(FizzBuzzable origin) {
super(origin);
}
protected final String fizzBuzzing() {
return "Buzz";
}
protected final boolean isDivisible() {
return ((this.value() % 5) == 0);
}
}

final class NumberDivisibleByThreeAndFive extends DivisibleNumber {
public NumberDivisibleByThreeAndFive (FizzBuzzable origin) {
super(origin);
}
protected final String fizzBuzzing() {
return "Fizz Buzz";
}
protected final boolean isDivisible() {
return (((this.value() % 3) + (this.value() % 5)) == 0);
}
}
>>
>>58826946

Main class:
public class Main {
public static void main(String[] args) {
for (int i = 1; i <= 100; ++i) {
System.out.print(
new NumberDivisibleByThreeAndFive(
new NumberDivisibleByFive(
new NumberDivisibleByThree(
new FizzBuzzableNumber(i)
)
)
).doFizzBuzz()
);
if (i < 100) System.out.print(", ");
}
}
}
>>
(dotimes (i 101)
(if (> i 0)
(cond
((and (= (mod i 3) 0) (= (mod i 5) 0)) (princ "FizzBuzz"))
((= (mod i 3) 0) (princ "Fizz"))
((= (mod i 5) 0) (princ "Buzz"))
(t (princ i))
)))
>>
>>58823558

God template meta programming is so gross looking.

Why do people encourage this?
>>
>>58824700
Yes

>>58826946
https://github.com/enfiskutensykkel/rmi-fizzbuzz

>>58823480

Array(100)
.fill('')
.map(
(
// FizzBuzzer
(f) =>
f[0]() + f[1]()

)
.bind(null,
(
// [Fizzer, Buzzer]
(f) =>
[ f.bind(null, ['', '', 'Fizz']), f.bind(null, ['', '', '', '', 'Buzz']) ]
)(
// Shuffler function
(v) =>
[ v[0], v.push(v.shift()) ][0]
)
)
)
.map(
(
(u, e) =>
[e ? e : u.length, u.push(true)][0]
)
.bind(null,
[true]
)
)
.forEach(
(e) =>
console.log(e)
);

>>
File: 258941.jpg (56KB, 640x480px) Image search: [Google]
258941.jpg
56KB, 640x480px
>>58820433
>>
func main() {
for i := 1; i < 101; i++ {
if i%15 == 0 {
fmt.Println(i, " FizzBuzz")
} else if i%5 == 0 {
fmt.Println(i, " Buzz")
} else if i%3 == 0 {
fmt.Println(i, " Fizz")
} else {
fmt.Println(i)
}
}
}
>>
using System;
using System.Net;

namespace N {
class Program {
static void Main(string[] args) {
using (var myWebClient = new WebClient()) {
var responseString = myWebClient.DownloadString("http://pastebin.com/raw.php?i=uHGPkvhB");
Console.Write(responseString);
}
Console.Read();
}
}
}
>>
>if i%5 = i%3 == 0
You people do realize it's just i%15 == 0, right?
Or are you all trolling?
>>
>>58828379
No one would ever write anything but enterprise quality code in a fizzbuzz thread anon.
>>
>>58818141

came here to post this
>>
File: cs graduate.png (112KB, 1233x668px) Image search: [Google]
cs graduate.png
112KB, 1233x668px
>>58823935
>>
File: cs graduate 2.png (266KB, 836x3232px) Image search: [Google]
cs graduate 2.png
266KB, 836x3232px
>>58823775
>>
>>58824877
my god
>>
>>58828379
If you think that matters you aren't solving the problem correctly.
>>
>>58829001
Fuck you I'll use maths _as much as possible_.
>>
>>58816443
if i == 1: pass
if i == 2: pass
if i == 3: print("fizz")
if i == 4: pass
if i == 5: print("buzz")
....
feels bad man
>>
>>58820433
LFMAO
>>
File: WHAT.jpg (118KB, 410x410px) Image search: [Google]
WHAT.jpg
118KB, 410x410px
>>58823480
>[10, 10, 10].map(parseInt)
>10, NaN, 2
>>
File: 1485332931265.jpg (83KB, 344x382px) Image search: [Google]
1485332931265.jpg
83KB, 344x382px
>>58823775
>>
say "Fizz"x!($_%3)."Buzz"x!($_%5)||$_ for 1 .. 100

Perl
>>
Sorry I don't know any other languages

#!/bin/bash
for i in `seq 1 100`; do
if [ $((i%3)) = 0 ]; then
printf fizz
fi
if [ $((i%5)) = 0 ]; then
printf buzz
fi
printf \\n
done
>>
>>58829437
>>58829499
If 3 and 5 are dividable, you gotta print fizzbuzz
>>
>>58829520
>fizzbuzz as a separate statement
what a dweeb
>>
File: 1485173668037.jpg (106KB, 593x578px) Image search: [Google]
1485173668037.jpg
106KB, 593x578px
>>58829533
What
>>
>>58829520
The perl statement does.
>>
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('P(F(p,a,c,k,e,d){e=F(c){E(c<a?\'\':e(V(c/a)))+((c=c%a)>R?J.U(c+S):c.L(K))};I(!\'\'.H(/^/,J)){G(c--){d[e(c)]=k[c]||e(c)}k=[F(e){E d[e]}];e=F(){E\'\\\\w+\'};c=1};G(c--){I(k[c]){p=p.H(M N(\'\\\\b\'+e(c)+\'\\\\b\',\'g\'),k[c])}}E p}(\'D(f(p,a,c,k,e,d){e=f(c){h c.l(s)};j(!\\\'\\\'.o(/^/,u)){q(c--){d[c.l(a)]=k[c]||c.l(a)}k=[f(e){h d[e]}];e=f(){h\\\'\\\\\\\\w+\\\'};c=1};q(c--){j(k[c]){p=p.o(t r(\\\'\\\\\\\\b\\\'+e(c)+\\\'\\\\\\\\b\\\',\\\'g\\\'),k[c])}}h p}(\\\'8(1=0;1<=b;1++){4(1%3==0||1%5==0){4(1%3==0){2"7"}4(1%5==0){2"9"}2"\\\\\\\\6"}a 2 1+"\\\\\\\\6"}\\\',m,m,\\\'|i|A||j||n|C|B|v|x|y\\\'.z(\\\'|\\\'),0,{}))\',O,O,\'|||||||||||||||F||E||I||L|10||H||G|N|K|M|J|T||Y|W|Q|Z|11|X|P\'.Q(\'|\'),0,{}))',62,64,'||||||||||||||||||||||||||||||||||||||||return|function|while|replace|if|String|36|toString|new|RegExp|40|eval|split|35|29|buzz|fromCharCode|parseInt|100|fizz|else|print|12|for'.split('|'),0,{}))
>>
public void main(String[] args) {
for (int i = 1; i <= 100; i++) {
int temp = 0;
if (i % 3 == 0) temp += 3;
if (i % 5 == 0) temp += 5;
fizzbuzzer(i);
Console.println();
}
}

public void fizzbuzzer(int i) {
switch(i) {
case 3 : Console.print("Fizz"); break;
case 5 : Console.print("Buzz"); break;
case 8 : fizzbuzzer(3); fizzbuzzer(5); break;
default: Console.print(i); break;
}
}
>>
>>58818141
>javascript
kys
>>
GameBoy assembly, here's the ROM

https://drive.google.com/file/d/0B2YI91EWUu1AWTl2c05kM3pJaWc/view?usp=drivesdk

Source

https://drive.google.com/file/d/0B2YI91EWUu1AWWFrTWFDQTdkd1E/view?usp=drivesdk
>>
import Data.Monoid
import Control.Applicative

three :: Integer
three = 3
five :: Integer
five = 5

forb :: Integer -> String
forb = mwhenMof three "Fizz" <> mwhenMof five "Buzz"

mwhenMof = mwhen . ((0 ==) .) . flip rem
mwhen p m x = if p x then m else mempty

fb = rwhen (== mempty) . forb <*> show -- fuck yeah, S combinator
rwhen p x y = if p x then y else x

main = putStr $ foldMap (<> "\n") $ fb <$> [1..100]
>>
>>58823465
What esoteric programming language is this?
>>
>>58816771
You are absolutely right. In my defense, I decided to post this when another guy told me to "loop through 1 to 100 and print fizz if divisible by 3, buzz if divisible by 5, and fizzbuzz if divisible by 15". So internally, I skipped the number part. But I should have known better.

Here are the corrected snippets.

Lua:
for i = 1, 100, 1 do
if i % 3 == 0 then
if i % 5 == 0 then
print("Fizzbuzz")
else
print("Fizz")
end
else
if i % 5 == 0 then
print("Buzz")
else
print(i)
end
end
end


C:
int main() {
char* t[4];
t[1] = "Fizz\n";
t[2] = "Buzz\n";
t[3] = "FizzBuzz\n";

int i;
char num[5];
for (i = 1; i <= 100; i++) {
sprintf(num, "%d\n", i);
t[0] = num;
printf("%s", t[(i % 3 == 0) + (i % 5 == 0) * 2]);
}

return 0;
}


>>58820433
This is great.
>>
using System;
public class FizzBuzz
{
public static void Main()
{
int i = 1;
while(i<101)
{
Console.WriteLine(i%3==0?(i%5==0?"FizzBuzz":"Fizz"):(i%5==0?"Buzz":i.ToString()));
i++;
}
}
}
>>
test_3 <- function(x) identical(x / 3, round(x / 3)
test_5 <- function(x) identical(x / 5, round(x / 5)
for (i in seq_len(100)) {
t3 <- test_3(i)
t5 <- test_5(i)
if (t3 && t5) print("fizzbuzz")
if (t3) print("fizz")
if (t5) print("buzz")
print(i)
}
>>
>>58831996
Actually I'll vectorize it:

tests <- function(x) {
if (identical(x / 3, round(x / 3)) && identical(x / 5, round(x / 5))) {
return("fizzbuzz")
} else {
if (identical(x / 3, round(x / 3))) {
return("fizz")
} else {
if (identical(x / 5, round(x / 5))) {
return("buzz")
} else return(x)
}
}
}
sapply(1:100, tests)
[/code/
>>
i ℅ 3 ? (i ℅ 5 ? Fizzbuzz : Fizz) : Buzz
>>
>>58828797
Thanks anon
>>
>>58820826
worst fizzbuzz you can do in cl
>>
for(int i = 15; i > 0; i--){
if(i == 3 || i == 6 || i == 9 || i == 12)
print.log.document.write.STRING("Fizz")
else if(i == 5 || i == 10)
print.log.document.write.STRING("Buz")
else if(i == 15)
print.string.add(prev-1 + prev-2)
else
i;
}

Thread posts: 88
Thread images: 11


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.