[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]

Well, /g/?

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: 34
Thread images: 8

File: FizzBuzz™.png (44KB, 944x398px) Image search: [Google]
FizzBuzz™.png
44KB, 944x398px
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
>>
File: smug1.png (117KB, 372x351px) Image search: [Google]
smug1.png
117KB, 372x351px
> javascript
>>
File: B7v56zvCYAE7FVU.jpg (12KB, 299x264px) Image search: [Google]
B7v56zvCYAE7FVU.jpg
12KB, 299x264px
>>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.
>>
File: CIYYRCFVAAEyglU.jpg (67KB, 600x928px) Image search: [Google]
CIYYRCFVAAEyglU.jpg
67KB, 600x928px
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
>>
File: spinnin spurdo.gif (13KB, 250x194px) Image search: [Google]
spinnin spurdo.gif
13KB, 250x194px
>>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?
>>
>>59080576
int 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.
>>
>>59080576
var 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 do
function 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;
>>
File: 1457812310783.png (34KB, 790x620px) Image search: [Google]
1457812310783.png
34KB, 790x620px
>>59080874
>>
File: 4_0217.png (49KB, 448x240px) Image search: [Google]
4_0217.png
49KB, 448x240px
>>59081488
>>
File: .jpg (264KB, 1691x752px) Image search: [Google]
.jpg
264KB, 1691x752px
>>59081488
>>
>>59080424
readability > speed

almost always
>>
>>59081933
I think the first one might even be faster
Thread posts: 34
Thread images: 8


[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.