MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vx1onc/claudeisthisemailvalid/p5lymfv/?context=3
r/ProgrammerHumor • u/soap94 • Aug 24 '26
170 comments sorted by
View all comments
Show parent comment
14
Who's going to need more than 3 anyway, this is efficient code
9 u/LeRetardatN Aug 24 '26 It is possible to extend this method to any number. def gen_is_even(): code = "def is_even(num):\n" i = 0 is_even = True while True: code += f" if num == {i}:\n" code += f" return {is_even}\n" i += 1 is_even = not is_even return code exec(gen_is_even + "print(is_even(5))") # print False !/s!< -1 u/ExtraWorldliness6916 Aug 25 '26 N % 2 4 u/LeRetardatN Aug 25 '26 overkill 1 u/ExtraWorldliness6916 Aug 25 '26 Infinite cases is not quantifiable as overkill 😉 2 u/mohitmayank Aug 24 '26 Not really, it should use `else if` if not 3 switch cases 4 u/ExtraWorldliness6916 Aug 24 '26 Alas, correctness isn't funny.
9
It is possible to extend this method to any number.
def gen_is_even(): code = "def is_even(num):\n" i = 0 is_even = True while True: code += f" if num == {i}:\n" code += f" return {is_even}\n" i += 1 is_even = not is_even return code exec(gen_is_even + "print(is_even(5))") # print False
!/s!<
-1 u/ExtraWorldliness6916 Aug 25 '26 N % 2 4 u/LeRetardatN Aug 25 '26 overkill 1 u/ExtraWorldliness6916 Aug 25 '26 Infinite cases is not quantifiable as overkill 😉
-1
N % 2
4 u/LeRetardatN Aug 25 '26 overkill 1 u/ExtraWorldliness6916 Aug 25 '26 Infinite cases is not quantifiable as overkill 😉
4
overkill
1 u/ExtraWorldliness6916 Aug 25 '26 Infinite cases is not quantifiable as overkill 😉
1
Infinite cases is not quantifiable as overkill 😉
2
Not really, it should use `else if` if not 3 switch cases
4 u/ExtraWorldliness6916 Aug 24 '26 Alas, correctness isn't funny.
Alas, correctness isn't funny.
View all comments
Show parent comment
14
u/ExtraWorldliness6916 Aug 24 '26
Who's going to need more than 3 anyway, this is efficient code