Live data from Hacker News

4 billion if statements (2023)

andreasjhkarlsson.github.io

111–120 of 183 posts

Re: 4 billion if statements (2023)

#112

Earlier quoted context omitted.

> This is time efficient* but rather wasteful of space. You're saying that the blog's solution is time efficient. Which it is not. Your solution may be O(1) but it is also not efficient. As I'm sure you are aware. I can tell you a practical solution which is also O(1) and takes up maybe 2 or 3 instructions of program code and no extra memory at all. `x & 1` or `x % 2 != 0` This blog post was taking a joke and running…

You need to read their entire comment as a joke.

I guess I should have been more clear that I was just pointing out the obvious in case some confused reader missed the joke.

lol

Re: 4 billion if statements (2023)

#113

This is time efficient* but rather wasteful of space. The best way to save space is to use a Bloom Filter. If we capture all the even numbers, that would sadly only give us "Definitely not Even" or "Maybe Even". But for just the cost of doubling our space, we can use two Bloom filters! So we can construct one bloom filter capturing even numbers, and another bloom filter capturing odd numbers. Now we have "Definitely…

How is this time efficient at all? It takes upwards of 40 seconds to compute on large 32bit values. It's a joke post with some interesting bits and details.

The comment you're replying to is also a joke, with some interesting bits and details.

Re: 4 billion if statements (2023)

#114

Earlier quoted context omitted.

But then, even numbers will have the worst possible performance.

Good point. Have two programs - one checking every even number and returning odd of not even. And then have a program checking every odd number and returning even if not. Then, a simple program to dispatch to either program randomly, so you end up in the long term with good performance for each.

Yeeessss! Microservices!

Re: 4 billion if statements (2023)

#115

> As a side note, the program is amazingly performant. For small numbers the results are instantaneous and for the large number close to the 2^32 limit the result is still returned in around 10 seconds. Amazing!

This line from the article -- I will be laughing about it for days.

Re: 4 billion if statements (2023)

#117

Earlier quoted context omitted.

You need to read their entire comment as a joke.

I guess I should have been more clear that I was just pointing out the obvious in case some confused reader missed the joke. lol

explaining the joke spoils the joke, such is social convention.

Re: 4 billion if statements (2023)

#118

Earlier quoted context omitted.

You need to read their entire comment as a joke.

I guess I should have been more clear that I was just pointing out the obvious in case some confused reader missed the joke. lol

Which was also obvious, but maybe also needed pointing out, which says something about online discussion. Something obvious, probably.

Re: 4 billion if statements (2023)

#119

This is time efficient* but rather wasteful of space. The best way to save space is to use a Bloom Filter. If we capture all the even numbers, that would sadly only give us "Definitely not Even" or "Maybe Even". But for just the cost of doubling our space, we can use two Bloom filters! So we can construct one bloom filter capturing even numbers, and another bloom filter capturing odd numbers. Now we have "Definitely…

How is this time efficient at all? It takes upwards of 40 seconds to compute on large 32bit values. It's a joke post with some interesting bits and details.

How are you able to recognize a joke post but not a joke comment?
Post reply on HN