Now we just need to someone to package it and upload it to NPM.
What’s another 40 gb of node_modules anyway
Could be easily made 50% space saving by only iffin all odds and return even on else. Maybe one if before to handle overflow to avoid wrong even if over the last if.
Well yeah, if you allow cheating!
Yeah but then ALL even numbers would be slow to compute because you would have to chain through every odd before you know that
2
is even.Depends on the expected distribution of input values
Heuristic: keep it until 512, afterwards powers of 2, and numbers like 1000, 2000,…, 10000, 20000,… (regex: [0-9]000+)
This is poetry.
My favourite part is that he uses the modulo operator in his Python script to generate the C code.
@programming_horror , anyone? We have an in production version of this used in Wikipedia
Andreas is a maniac
I’m not a good reader - I skim most articles and often miss most of the meaning. I read, and enjoyed, every word of that!
Thanks, I totally would’ve skipped it without this comment.
It’s not a trade off between dev time, execution time and memory as the author claims. It’s materially worse for all 3
I think he was being sarcastic, playing with words. Meaning, that you trade in time, runtime and memory and get nothing in return :D so a pretty bad trade haha.
Of course it’s worse, I mean, that was the point of this blogpost, wasn’t it? :p It’s just a (long) joke.
On reread, you’re totally right. Went right over my head
Well i hate this:
PS > .\program.exe 0
THIS:
.\
This is peak YandereDev.
I’ve lost some of my sanity reading this !
It works don’t it
This is why every programmer needs to understand the modulo operator.
Or bitwise AND.
This is what I prefer too! I also some times prefer to use bitshift when it comes to division or multiplication of power of 2.
I would divide by two (floating point) and check the fractional part.
turns out that 2^53 + 1 is an even number
The article only covers unsigned 32-bit numbers, so floating point division would be fine.
Those are rookie numbers. Professionals came up with the nested logic monstrosity that is the JSON-LD specification:
https://www.w3.org/TR/json-ld11-api/#context-processing-algorithm
Looks through the algorithm bits in the various sections. How would you implement that? The answer is invariably by copying the highly nested statements of the spec directly into your language. Maybe there’s a better way, but you’d have to understand all that nested logic first, and you’d be exhausted at that point and just want to move on.
I first saw this joke back in the days of 8-bit home microcomputers. Of course then it only needed 256 lines of code, and took up about 8k of your precious, precious RAM.
I honestly thought this was going to be about AI 😅
No, this is about NS. Natural Stupidity.
Wait, what’s with the creative commons license? Are you licensing your comments?