this post was submitted on 15 Jul 2025
450 points (94.8% liked)
Programmer Humor
37208 readers
236 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I prefer good ole regex test of a binary num
Amateur! I can read and understand that almost right away. Now I present a better solution:
~~(I mean, it's funny cause it's unreadable, but I suspect this is also one of the most efficient bash implementations possible)~~
(Actually the obvious one is a slight bit faster. But this impl for
odd
is the fastest one as far as I can tellodd() (($1&1))
)I'm waiting for a code golf style solution now.
I don't think there's much to codegolf. The "obvious" solution (
even() (($1%2))
) is both shorter and faster. Don't think it can be optimized much more.