Infallible Code
-
Better/fastest approch would be to check the last bit of the int and return the result.
Second use modulo.This? Dev should burn in hell.
Who created this?Alternatively you can divide by 2, turn it into an int, mtiply it by 2 and check if both numbers are the same.
-
This post did not contain any content.
At least this madness is isolated to this function. It can easily be fixed.
Pirate’s code is just cluttered with magic numbers everywhere. Hard coded numbers that are referring to a big ”story array”, or characters. It’s just a giant web of complexity. The only fix is to start from scratch.
-
This post did not contain any content.
-
This isn’t his actual code, right? Like this specific code pictured here? I’m aware of the “drama” surrounding him currently.
this is an old meme about yanderedev
-
This post did not contain any content.wrote on last edited by [email protected]
After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion
private bool IsEven(int number){ if (number > 1) return IsEven(number - 2); if (number == 0) return true; if (number == 1) return false; }
-
Better/fastest approch would be to check the last bit of the int and return the result.
Second use modulo.This? Dev should burn in hell.
Who created this?wrote on last edited by [email protected]or another stupid, but viable way to do it,
if number = 0:
return true
runloop = true
while runloop:
if number > 0:
number -= 2
else:
number += 2
if number = 1:
return false
runloop = false
if number = 2:
return true
runloop = false
still very shitty amature coding, doesn't depend on modulos, or anything that I can think of that some languages might lack an equivelant of.
-
After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion
private bool IsEven(int number){ if (number > 1) return IsEven(number - 2); if (number == 0) return true; if (number == 1) return false; }
assert IsEven(-2);
-
After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion
private bool IsEven(int number){ if (number > 1) return IsEven(number - 2); if (number == 0) return true; if (number == 1) return false; }
I removed the tail recursion for you:
private book IsEven(int number) { if(number > 1) return IsEven(number - 2) == true; if(number == 0) return true; if(number == 2) return false; }
-
I removed the tail recursion for you:
private book IsEven(int number) { if(number > 1) return IsEven(number - 2) == true; if(number == 0) return true; if(number == 2) return false; }
I didn't get this.
Why return
book
? Does that have some Blizzard reference?
And why wouldnumber == 2
⇒return false
? This is a function for gettingtrue
when the number is even, right? -
This post did not contain any content.
Not to take from all the funny answers ... but
bool IsEven(int i) => (i & 1) != 1;
(C#)
-
I didn't get this.
Why return
book
? Does that have some Blizzard reference?
And why wouldnumber == 2
⇒return false
? This is a function for gettingtrue
when the number is even, right?wrote on last edited by [email protected]Haha, you're right. I've now learned two things:
- I should not write code on a mobile
- I should not become a proof reader
At the end of the day i just wanted the function to be worse, by causing stack overflows
-
Not to take from all the funny answers ... but
bool IsEven(int i) => (i & 1) != 1;
(C#)
Though, obviously I had to come up with some ridiculous solutions:
bool IsEven(int i) => ((Func<string, bool>)(s => s[^1] == 48))($"{i:B}");
This one works without conditionals
bool IsEven(int i) { try { int _ = (i & 1) / (i & 1); } catch (Exception) { return true; } return false; }
-
This post did not contain any content.
Lol the amount of bullying this guy is getting lately. I've seen similar spins and bends that looks somewhat legit, making people believe he suck at coding
-
This post did not contain any content.
Then again, Duff’s Device works rather similarly.
-
Pah, mathematicians and their generally applicable pure approach to solutions and fancy modulus operations, who needs 'em? Computing is applied and we always work with well-defined finite precision. Granted, writing the boilerplate for all possible 64 bit integers is a bit laborious, but we're programmers! That's what code generation is for.
Granted, writing the boilerplate for all possible 64 bit integers is a bit laborious,
I've been trying to figure out roughly how many lines of code that would equal out to but I've run out of fingers.
-
I worked at Blizzard. I worked at Blizzard. I worked at Blizzard.
Yeah, but did your dad work at Blizzard??
-
At least this madness is isolated to this function. It can easily be fixed.
Pirate’s code is just cluttered with magic numbers everywhere. Hard coded numbers that are referring to a big ”story array”, or characters. It’s just a giant web of complexity. The only fix is to start from scratch.
It's simple. The only problem is that your code sucks!
-
Though, obviously I had to come up with some ridiculous solutions:
bool IsEven(int i) => ((Func<string, bool>)(s => s[^1] == 48))($"{i:B}");
This one works without conditionals
bool IsEven(int i) { try { int _ = (i & 1) / (i & 1); } catch (Exception) { return true; } return false; }
s[^1]
Ohh wow, I've been learning it casually for years, and I didn't know that existed in C#. I guess I should go back and hit the books some more.
-
If small numbers are much more frequent, it's better to return early. Really, you should gather statistics about the numbers the function is called with, and put the most frequent ones at the top.
-
The fuck is that