Well, /g/?
>>59080424
Good, efficient, optimized, non-pajeet code you got there anon
>>59080446
PICK ONE, FAGET!
>>59080462
I have no idea, they're both just so fucking good
> javascript
>>59080482
>animu
>>59080424
>clean, structured, understandable and easily maintainable code
VS
>that fucking mess
>right
If someone gave me that obtuse, resource-intensive, "I'm so clever" shit I'd end the interview on the spot.
Is there a way to do fizzbuzz without modulus operation?
>>59080424
What color scheme is that?
Also, left.
>>59080576
std::to_string((double)a / 15).find(".") != std::string::npos
>modulo
neck yourself my man you don't belong here
>>59080530
this, a thousand times. Complex and compact code is just dick measuring without any real application in the real world. It's literally garbage.
>>59080576
By writing your own modulus operation.
>>59080500
>on an anime website
shit who would have thought
>>59080424
I would do it like this:
if statement with modulus % 3
-if true, then try modulus % 5
--if true print "FizzBuzz"
--else print "Fizz"
if statement with modulus % 5
-if true print "Buzz"
-else do nothing
Am I wrong for choosing this structure?
>>59080576int fizz = 3;
int buzz = 5;
for(int i = 1; i < = N; ++i) {
fizz--;
buzz--;
if (fizz == 0 && buzz == 0)
{
outp = "FizzBuzz";
fizz = 3;
buzz = 5;
}
else if (fizz == 0)
{
outp = "Fizz";
fizz = 3;
}
else if (buzz == 0)
{
outp = "Buzz";
buzz = 5;
} else {
outp = i.ToString();
}
result += outp + ", ";
}
>>59080424
> using reduce on inherently sequential problem
> harder to read with no benefit to speed
>>59080624
No, it'lll work, but you can do it with fewer statements.
>>59080424
Bit masking is the better solution.
>>59080711
Even less? How so? I might be stupid but I don't see how one can further shorten this script.
>>59080576var fb_base_arr = [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'Fizz Buzz'];
var fb_arr = fb_base_arr;
for (let i = 15; i < N; i += 15)
fb_arr = fb_arr.concat(fb_base_arr.map((v, k) =>
(Number.isInteger(v))? v+i : v
));
fb_arr.join(', ');
>>59080619
>weeaboos actually believe this
Just stick to your containment boards, neckbeard.
>>59080576
whiles
>>59080809
>not knowing the site was founded on fucking anime
You need to go back
>>59080424
>tries to do functional fizzbuzz
>makes it more complex than the traditional solution somehow
>makes it stateful somehow
Absolutely disgusting.
Whats wrong with right? It seems most efficient.
>>59080424
it sucks
IT IS FUCKING 15 FFS, triggered every time :)
you do few unneeded checks when you do that, so pajeet tier if you ask me
also right one is much better, but could be optimized further
>>59080986
Just dofunction FizzBuzz(n: Integer): String;
begin
Result := '';
while (n > 0) do
begin
if (n mod 3 = 0) then
if (n mod 5 = 0) then
Result := 'Fizz Buzz' + Result
else Result := 'Fizz' + Result
else if (n mod 5 = 0) then
Result := 'Buzz' + Result
else Result := IntToStr(n) + Result;
if n > 1 then Result := ', ' + Result;
Dec(n)
end
end;
>>59080874
>>59081488
>>59080424
readability > speed
almost always
>>59081933
I think the first one might even be faster