The other day I’ve read this post & the accompanying thread on Twitter:
It reminded me of something I mentioned in a talk a rather long wile ago. — Sadly I can’t remember which conference that was, although I do know it was no earlier than 2006.
- If you do it in a weird way, you may be wrong.
- If they do it in a weird way, they may be right.
The image that I relate to this::
It seems wrong, doesn’t it? The football field is on the slope of a hill. There are also bushes growing in the field. And furthermore the field is so close to a lake that a football may easily get shot into it.
Why would anyone do this? Well, the location in the Olympia Park in Munich and the year was 2006 — when the world football championship took place in Germany. The Olympia Park was one of the big areas that offered public viewing (something hard to imaging now in 2020…).
If something doesn’t make sense in the first moment, that doesn’t mean it can’t possibly make sense at all. It may be a joke. — I personally like the joke that I don’t get immediately.
Returning to the original problem of figuring out if a number is even, here’s a solution I came up with. Yes, I know the original didn’t use Ruby. And yes, this work for many, but quite not all numbers. 🥳
def is_even?(int) (int.object_id.pred % 4).zero? end
In Ruby, use
even?. It comes with the language and it works.