• _cnt0@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    2 days 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;
    }