291
Infallible Code (feddit.uk)
you are viewing a single comment's thread
view the rest of the comments
[-] _cnt0@sh.itjust.works 3 points 2 weeks ago

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

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

(C#)

[-] _cnt0@sh.itjust.works 2 points 2 weeks ago

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 was submitted on 15 Jul 2025
291 points (100.0% liked)

Programmer Humor

25436 readers
993 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