this post was submitted on 15 Jul 2025
204 points (95.1% liked)

Programmer Humor

25009 readers
1528 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] _cnt0@sh.itjust.works 3 points 18 hours ago (1 children)

Not to take from all the funny answers ... but

bool IsEven(int i) => (i & 1) != 1;

(C#)

[–] _cnt0@sh.itjust.works 2 points 18 hours ago (1 children)

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;
}
[–] Lemminary@lemmy.world 1 points 3 hours ago

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.