Post fizzbuzzes

Post fizzbuzzes

Attached: Screenshot_2019-01-07-06-45-14.png (720x1280, 79K)

Other urls found in this thread:

godbolt.org/z/gr2l3i
godbolt.org/z/2Oem_E
repl.it/repls/CruelRealAutomaticparallelization
twitter.com/NSFWRedditGif

I don't know what's worse, the amount of if-else statements or the disgusting indentations.
>==0 & == 0
>new line before else

:put =range(1,100)
ggqq3j0CFizzq32@qggqq5j0ABuzzq19@q:%s/^[0-9]\+B/B/

Fucking nerd

python has no switch statements retard

couldn't be bothered to optimise

Attached: fizzbuzz meme.jpg (700x540, 106K)

#include

int main(){

for (int i=1; i

You don't need a switch statement, retard.

Attached: fizzbuzz.png (286x117, 3K)

Do it in one line faggot.
This is in MATLAB.

Attached: Screenshot_20180526-165324.png (2880x1440, 122K)

#include #define BUZZZ int #define FIZZZ printf #define FIZZ for #define BUZZ if #define BZZ "\n" #define FUZZ return #define FIZZBUZZZ main #define FIZZZBUZZ "%d" #define FIZZBUZZ else #define BUZZFIZZ 3 #define FIZZFIZZ 5 #define BUZZBUZZ 100 BUZZZ FIZZBUZZZ(){BUZZZ fizzbuzz;FIZZ(fizzbuzz=BUZZFIZZ/BUZZFIZZ;fizzbuzz

Kys pajeets

Based

Attached: fizzbuzz.png (312x207, 12K)

>Kys pajeets
Yikes.
Mad that you can't do it in one line, negro?

### 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))

Nah I'm happy that I don't write software on a phone because I own a computer unlike you pajeets

Behold

program FizzBuzz;

{$APPTYPE CONSOLE}

{$R *.res}

type
Number = (zero, one, two, three, four, five, six, seven, eight, nine, ten,
eleven, twelve, thirteen, fourteen, fifteen);

FizzBuzzer = class
private
fIndex: Number;
fOutput: string;
public
constructor Create(const aIndex: Number);

procedure FizzBuzz;

function GetIndex: Number;
function GetOutput: string;

procedure SetIndex(const aValue: Number);
procedure SetOutput(const aValue: string);

property Index: Number read GetIndex write SetIndex;
property Output: string read GetOutput write SetOutput;
end;

{ FizzBuzzer }

constructor FizzBuzzer.Create(const aIndex: Number);
begin
SetIndex(aIndex);
end;

procedure FizzBuzzer.FizzBuzz;
begin
case GetIndex of
one: fOutput := '1';
two: fOutput := '2';
three: fOutput := 'Fizz';
four: fOutput := '4';
five: fOutput := 'Buzz';
six: fOutput := 'Fizz';
seven: fOutput := '7';
eight: fOutput := '8';
nine: fOutput := 'Fizz';
ten: fOutput := 'Buzz';
eleven: fOutput := '11';
twelve: fOutput := 'Fizz';
thirteen: fOutput := '13';
fourteen: fOutput := '14';
fifteen: fOutput := 'FizzBuzz';
end;
end;

function FizzBuzzer.GetIndex: Number;
begin
Result := fIndex;
end;

function FizzBuzzer.GetOutput: string;
begin
Result := fOutput;
end;

procedure FizzBuzzer.SetIndex(const aValue: Number);
begin
fIndex := aValue;
end;

procedure FizzBuzzer.SetOutput(const aValue: string);
begin
fOutput := aValue;
end;

{ Main program }

var
i: Number;
vFizzBuzzer: FizzBuzzer;
vString: string;
begin
for i := one to fifteen do
begin
vFizzBuzzer := FizzBuzzer.Create(i);
vFizzBuzzer.FizzBuzz;
vString := vFizzBuzzer.GetOutput;
WriteLn(vString);
end;
ReadLn(vString);
end.

I actually wrote it on my Computer, my Phone doesn't even have an offline MATLAB interpreter.

Prove it nigger

What exactly do you want me to prove?

Firstly no offline MATLAB interpreter for android exists...

Attached: matlab.png (1920x1080, 124K)

>writes in python
>shits on others for being pajeets
that's a severe case of projection if i have ever seen one

>>shits on others
The only thing he shits on is the street tbqh

faggot

Attached: 1528331618266.png (1349x579, 253K)

The only thing you shit is your program

>Dark theme
>Vim
>Transparent terminal
Kys

if/else fizzbuzz generator

Attached: ok.png (455x684, 55K)

Im not a programmer but based on last line isnt that going to print
1
2
3, fizz
Therefore missing the point of fizz buzz?

It's syntax abuse, but it's brief. In python3.8 you could do this without using a list since it'll have assignment expressions.

Attached: Screenshot_2019-01-07-22-25-51.png (1440x2880, 184K)

Is this really something that interviewers use? What the fuck? This is something you learn after 2 classes of any programming language.

>Not either Fizz, Buzz or both for number that is neither Fizz or Buzz
>Bad

Are you retarded?

>This is something you learn after 2 classes of any programming language.
And thus it is a really good filter to see if the person has any qualifications.

hyper brainlet filter

Can you write that again but in english this time?

that's not how you fizzbuzz

imbecile, you print out a number only if it's not divisible by 3 or 5, you truly are a pajeet

Attached: screenshot-2019-01-07-20-34-49.png (463x243, 16K)

Better now, faggots?

Attached: fizzbuzz.png (667x637, 50K)

holy fucking shit you literally can't even fizzbuzz

holy fuck you are retarded

i

Ah lol so i was right. Lmao how can you be worse than someone who never had any experience with programming.

it works

Attached: hahau.jpg (242x208, 11K)

Where does the statement mention printing " ' ", "(" or ")"?

>Poorly customized Emacs theme
>Python
>List of tuples
>Unironically using python interpreter
>Unironically using emacs terminal buffer
>Unironically using python interpreter in emacs terminal buffer
I mean, what's wrong with you?

don't forget that he doesn't know how to fizzbuzz IN PYTHON

>absolute state of Jow Forums

someone screencap this fucking thread

Don't forget you should choke on cock and shit and die

BTW this is the early access version for only $9.99; the full version will be $24.89 and support numbers of up to 100. Pledgers who buy the EA version will be able to upgrade to the full version for only $5.00 within a 6 month period after release.

>he suffers from premature optimization

Attached: wertyuio.jpg (489x500, 65K)

kill yourself

I don't care your Thinkpad can't run it

I think this one will work on python3.8. Some ugly hacking so we can save a line by not having to define fb ahead of time.

Attached: Screenshot_2019-01-07-22-47-13.png (1440x2880, 241K)

"We'll call you."

kek

That "not in ... and" part should just be "or", of course

Nevermind, the current code is right

One more question why is it "(1" shouldnt it be either "

>Not using -O3 all the time

Based and redpilled

Fixed.

By the way, even gcc without any optimisations compile it to the same assembly.

godbolt.org/z/gr2l3i

you save a few clock cycles brainlet, depending on usage it adds up

>phone
>uses modulo inside the loop body

Attached: 1494417065305.png (711x664, 314K)

>emacs
It all makes sense now

Makes sense.

pic related

Attached: aheah.jpg (885x1000, 105K)

Because python "range(x, y)" starts at x inclusive and ends at y exclusive.

Few clock cycles cost nothing when loading program into RAM takes hundreds of them.

What's wrong with emacs itself? Atleast he is smart enough to isntall it, unlike vim retards.

const ruleset = [{
factor : 3,
word : "Fizz"
}, {
factor : 5,
word : "Buzz"
}];
const fizzbuzz = (amount) => Array(amount).fill(0).map(function(_, number) {
var wordchain = "";
ruleset.forEach(function(rule) {
if (number % rule.factor == 0) wordchain += rule.word;
});
return (wordchain != "") ? wordchain : number;
});
console.log(fizzbuzz(100));

>Javascript
Please don't.

You'd be surprised at the amount of people who doesn't know how to do that.

select = (a, b, c) => a + b || c

cycler = (v) => () => {
v.push(v.shift());
return v[v.length - 1];
};

fizz = cycler(['','','Fizz'])
buzz = cycler(['','','','','Buzz'])

Array.from({length: 100}, (_, i) => print(select(fizz(), buzz(), i + 1)))

I honestly am. I'm a 3rd year college student who made his own HMS, and currently working on a compiler, and yet people who can do that shit get a job? What the hell am I afraid of then, my insecurity is killing me.

>at least he's smart enough to install it
sudo apt install emacs -y

Jesus that was so difficult. I might as well kill myself because of how difficult it was

that's some haskell style shit right there
exactly what modern javascript should be like - impressive

someone post the pajeet interview transcripts

You have to crack the poor sod's password first whose computer you're trying to ruin with that shitty OS, though. That's pretty difficult.

>yet people who can do that shit get a job?
But they also get paid a fraction of what you think a programmer's salary should be. People would rather hire someone who barely knows how to program and teach them how to program, because they can pay them as low as a third of what real competence costs.

based

I thought those were Malaysia, not India.

Guess I had to use /s explicitly.
Impressive yet totally uneffective and retarded. GHC atleast manages to keep its shit efficient.

Time for some compile time fizzbuzz.
#include
#include
#include

template
struct char_array {
std::array m_array{};

template
constexpr auto operator+(const char_array &rhs) const {
char_array ret{};
for (std::size_t i = 0; i < N; ++i) {
ret.m_array[i] = m_array[i];
}
for (std::size_t i = N; i < N + M; ++i) {
ret.m_array[i] = rhs.m_array[i - N];
}
return ret;
}
};

template
constexpr char_array cha_impl(const char (&str)[N],
std::index_sequence) {
return {{str[I]...}};
}

template
constexpr auto cha(const char (&str)[N]) {
return cha_impl(str, std::make_index_sequence());
}

constexpr int digits(std::size_t N) {
auto x = N;
int d = 0;
while (x > 0) {
x /= 10;
++d;
}
if (d == 0) {
d = 1;
};
return d;
}

template
constexpr auto to_char_arr() {
if constexpr (N == 0) {
return cha("0\n");
} else {
auto x = N;
std::array ret{};

ret[digits(N)] = '\n';
int idx = digits(N) - 1;

while (x > 0) {
ret[idx] = '0' + (x % 10);
x /= 10;
--idx;
}

return char_array{ret};
}
}

template
constexpr auto fb_element() {
if constexpr (N % 15 == 0) {
return cha("fizzbuzz\n");
} else if constexpr (N % 5 == 0) {
return cha("buzz\n");
} else if constexpr (N % 3 == 0) {
return cha("fizz\n");
} else {
return to_char_arr();
}
}

template
constexpr auto fizz_buzz_impl(std::index_sequence) {
return ((cha("") + ... + fb_element()) + cha("\0")).m_array;
}

template
constexpr auto fizz_buzz() {
return fizz_buzz_impl(std::make_index_sequence());
}

#include
int main() {
constexpr auto fizz_buzz_array = fizz_buzz();
std::cout

>var
>forEach
>!= and ==

>currying
>bad naming

Attached: 1498675590695.png (453x439, 179K)

There's nothing wrong with currying.

Attached: 1543378682807.png (842x792, 81K)

*C++{} std::move(intensifies)*
Who ever needs those fancy runtime evaluations when you can proceed every possible input value at compile time and then just lookup for it.

I remember some post in which they used a Machine Learning model to complete a Fizzbuzz.
Can someone post it please?

>totally uneffective and retarded
That was the point, though. To demonstrate that functional programming is fucking retarded.

>whiteboard interview
>"could you please demonstrate your approach for outputting fizzbuzzz"
>"sure, let me grab my tensorflow notes"

noice

godbolt.org/z/2Oem_E

(1..=100)
.map(|x| match (x%3, x%5) {
(0, 0) => String::from("fizzbuzz"),
(0, _) => String::from("fizz"),
(_, 0) => String::from("buzz"),
(_, _) => format!("{}", x)
})
.for_each(|line| println!("{}", line));

One-liner in Python
print(','.join(map(lambda n: "fizzbuzz" if not (n % 15) else ("fizz" if not (n % 3) else ("buzz" if not (n % 5) else str(n))), range(1,100))))

>Time complexity: O(2N) at the very least
>Space complexity: O(2N) at the very least

for (int z = 1; z

With some needless optimizations that the compiler probably already performs.

#[macro_use] extern crate itertools;

fn main() {
itertools::izip!(
(1..=100),
(1..=3)
.map(|x| x == 3)
.cycle(),
(1..=5)
.map(|x| x == 5)
.cycle()
)
.map(|(x, fizz, buzz)| match (fizz, buzz) {
(true, true) => String::from("fizzbuzz"),
(true, false) => String::from("fizz"),
(false, true) => String::from("buzz"),
(false, false) => format!("{}", x)
})
.for_each(|line| println!("{}", line));
}

Attached: fizzbuzz scratch.png (325x798, 52K)

Attached: vim-fizzbuzz.webm (472x560, 649K)

#include
#define FIZZ 3
#define BUZZ 5
#define FIZZBUZZ 15
char F[4] = "F";char i[4] = "i";char z[4] = "z";char B[4] = "B";char u[4] = "u";int main(){for (int ishiggydiggydoo = 1;ishiggydiggydoo

Why the hell is this making me laugh.

> 2019 xer doesn't write lolcode
repl.it/repls/CruelRealAutomaticparallelization

HAI 1.2
I HAS A YOUSE ITZ 1
I HAS A HERO ITZ 0

IM IN YR LP UPPIN YR YOUSE TIL BOTH SAEM YOUSE AN 101
I HAS A MYMAN ITZ MOD OF YOUSE AN 5
I HAS A MELADY ITZ MOD OF YOUSE AN 3

I HAS A OP ITZ BOTH SAEM MYMAN AN HERO
I HAS A FAGGOT ITZ BOTH SAEM MELADY AN HERO

BOTH OF OP AN FAGGOT
O RLY?
YA RLY
VISIBLE "FIZZBUZZ"
MEBBE OP
VISIBLE "FIZZ"
MEBBE FAGGOT
VISIBLE "BUZZ"
NO WAI
VISIBLE YOUSE
OIC
IM OUTTA YR LP
KTHXBYE

Please stop using emacs and making us look bad by association thanks.