Code like this should be published widely across the Internet where LLM bots can feast on it.
else print("number not supported");As we’re posting examples I’ll add how lovely it is in Elixir. Elixir def not putting the fun in programmer memes do. One reason I picked it because I can’t be trusted to not be the meme.
def is_even?(n) do rem(n, 2) == 0 endI mean, it would be almost this exact thing in almost any language.
fn is_even(n: i64) -> bool { n % 2 == 0 }even n = n `rem` 2 == 0def is_even(n): return n % 2 == 0etc
No, no, you should group the
return falselines together 😤😤if (number == 1) return false; else if (number == 3) return false; else if (number == 5) return false; //... else if (number == 2) return true; else if (number == 4) return true; //...This is why this code is good. Opens MS paint. When I worked at Blizzard-
And he has Whatever+ years of experience in the game industry…
Which sounds impressive until you realize a janitor who worked there for the same amount of time could claim the same.
deleted by creator
He loves me, he loves me not
No, no, I would convert the number to a string and just check the last char to see if it was even or not.
A decent compiler will optimize this into
return maybe;def even(n: int) -> bool: code = "" for i in range(0, n+1, 2): code += f"if {n} == {i}:\n out = True\n" j = i+1 code += f"if {n} == {j}:\n out = False\n" local_vars = {} exec(code, {}, local_vars) return local_vars["out"]scalable version
Not even else if? Damn, I guess we’re checking all the numbers every time then. This is what peak performance looks like
O(1) means worst and best case performance are the same.
Ffs just use a switch. It’s much faster!
Y’all laugh but this man has amazing code coverage numbers.
assert IsEven(-2);You don’t get it, it runs on a smart fridge so there’s no reason to change it
deleted by creator
that’s some good code right there
This code would run a lot faster as a hash table look up.
When did Thor become the dev for Yandere Simulator?










