Live data from Hacker News

4 billion if statements (2023)

andreasjhkarlsson.github.io

131–140 of 183 posts

Re: 4 billion if statements (2023)

#133

Earlier quoted context omitted.

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?

I may have missed the * meaning. I got that the bloom filter was an extension of the joke as I mentioned below. I was just clarifying in case someone else missed the joke.

Re: 4 billion if statements (2023)

#134

Earlier quoted context omitted.

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.

Forgive me for not being funny.

Re: 4 billion if statements (2023)

#135

Earlier quoted context omitted.

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.

I think I'll just avoid commenting on jokes from now on.

Re: 4 billion if statements (2023)

#137

This could be obviously done with much less code: Just add "if"s for all even number, and at the end just return "odd" if none of the evens matched. 50% less code! Or even simpler: If it's 0, return "even". If not, do a recursive call to n-1, if that equals "even", return "odd", otherwise return "even". But the best way is probably to just use a library. Yes, 500MB of additional dependencies, but then it's a one-line…

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

You brought up an important opportunity for optimization. If you know the distribution of your data, it may make more sense to implement it in terms of the odd numbers and leave even numbers as the fallback. It's important to profile with a realistic distribution of data to make sure you're targeting the correct parity of numbers.

Re: 4 billion if statements (2023)

#138

Any good engineer knows there is no "best" solution, only tradeoffs. Save space. def even_flip_flop(number): even = True for _ in range(number): even = not even return even Ditto. Sure, this overflows the stack, but you look cool doing it. def even_recursive(number): return True if number == 0 else not even_recursive(number - 1) Save time. Just buy more RAM. table = [True, False] * 1000 # adjust to your needs def eve…

You can combine the second and third strategies to hit the sweet spot of time and space.

Re: 4 billion if statements (2023)

#140
post #8

Gemini took 4 seconds to answer this prompt: "Here is a number 4200020010101. Think deeply about it and tell me if it is not or or not even." So if you're concerned with privacy issues, you can run the assembly version proposed in the article locally and be well within the same order of performance. Let's thank the author of the article for providing a decent alternative to Google. ah, but the license is not that goo…

Finally a problem that Microsoft Phi can ace. Probably. Maybe. Some of the time at least.

Surely you mean Microsoft CoPhiLot 365
Post reply on HN