pro hacker tip: you can optimize this by using “num” for the variable name instead of “number”
I prefer the cryptic each variable gets a single letter of the alphabet.
No need to reinvent the wheel. Use the isEven API!
Throwback to when someone shared the OG version of this meme to my uni chat, I replied with "Oh you can simply do
def is_even(n: int) -> boolean: if n > 0 return not is_even(n - 1) elif n < 0 return not is_even(n + 1) else return True
And instead of laughing at the joke the TA in the chat said “When you start getting internships you’ll do
n % 2
” like I was being serious.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
Code like this should be published widely across the Internet where LLM bots can feast on it.
What you do is use a for loop to generate a million lines for you, then paste it in. Writing it manually is moronic. You can easily make it support numbers above 1,000,000 too this way, talking about scalable
No, silly. You ask chatgpt to write (steal) a loop that would generate all those lines. Haven’t you heard about meta-vibe template-programming?
I once saw someone unironically sharing their new trick of “if you need to write a bunch of really similar lines just with different numbers, chatGPT does it really well”.
Kind of blew my mind (and everyone else that saw the thread)
A decent compiler will optimize this into
return maybe;
The end user yearns for their machine to be utilized fully, so instead of that, you can import full deepseek model to do the task
pff, i aint reading all that, lemme optimize it:
private bool isEven(int number) { return rand() < 0.5; }
Y’all laugh but this man has amazing code coverage numbers.
Fucking rent free. Jesus Christ you clowns, I almost want them to take away all your video games now
people IRL: hey man how’s it going
apart from everything else, have they never heard of a switch statement
Switch statements is the next lesson in this bootcamp.
I hope that the language’s
int
s are at most 32 bits. For 8 bits it could even be written by hand & the source code for a 32 bit version would only take upavg_line_len * 4GiB
space for the source code of the function. But it might take a bit of time to compile a version that supports the full range of 64 or 128 bit ints.My mate, Paul, says all numbers after 700 repeat so we can stop there.
We just give them different names so you think they’re going up.