Live data from Hacker News

4 billion if statements (2023)

andreasjhkarlsson.github.io

81–90 of 183 posts

Re: 4 billion if statements (2023)

#81
post #54

kind of expected gcc to see right through the 300 gigs of code and compile it down to the tenish instructions.

I'm curious what GCC would do if it wasn't purposely lobotomised and fed 300 GB of this nuclear waste.

Well I created the 16 bit .c file, because I'm not that curious. gcc -O0 completed immediately and made a 1,5MB executable. -O1 took about 10 minutes for a 1,8 MB executable. -O2 has been running for 1h15m so far... i7-14700K

I'm in too deep now, so I'll let it run while I'm at work.

Re: 4 billion if statements (2023)

#82
post #53

Similar humour if opposite directions to an old favourite: https://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/

I expected some job interview meme[1][2] but I did not know this one and it looks like a real story too! Thanks for sharing, that was a fun read.

[1]: https://aphyr.com/posts/342-typing-the-technical-interview

[2]: https://www.richard-towers.com/2023/03/11/typescripting-the-...

Re: 4 billion if statements (2023)

#83
I recently asked a Qwen model to write me some code to remove errant spaces ("c he es e" instead of "cheese") in OCR'd text. It proceeded to write 'if' blocks for every combo of all English words and all possible errant spaces. I did not wait for it to finish...

Re: 4 billion if statements (2023)

#86

Ah, yes, exactly the pointless diversion I needed for my lunch break. For science: generating a C# switch statement for similar purposes took 7 minutes on similar-ish hardware, but the resulting 99.2GB file could not be opened or compiled ('Stream is too long'), which was slightly disappointing. Optimization efforts included increasing the internal buffer size of the StreamWriter used to create the source code: this…

Diversion for your whole next week: just generate machine code binary for this

Re: 4 billion if statements (2023)

#87
post #41
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…

>Think deeply about it and tell me if it is not or or not even I think I just experienced a segfault

Hey, why segfault and not stack overflow?

Re: 4 billion if statements (2023)

#88
post #13

Earlier quoted context omitted.

Yeah... I come here to talk about that. Should have been for i in range(0, 2**8, 2): print(" if (number == "+str(i)+")") print(" printf(\"even\\n\");") print(" if (number == "+str(i + 1)+")") print(" printf(\"odd\\n\");") or for i in range(0, 2**8, 2): print(f""" if (number == {i}) puts("even"); if (number == {i + 1}) puts("odd");""")

What happens when you try to compute 2**8+1 ?

Should work fine with long long?

Re: 4 billion if statements (2023)

#89
I see this is 2023… the article refs GPT even then. Can’t believe it’s already that much time gone by, still seems like “last years big news”

I was gonna comment “this is what I really like to see on HN”. Then I saw the date and was sad that we’re having to dip into the history box to find fun/interesting articles more often of late it seems.

Anyone else interested in a temporary moratorium on all things LLM? We could have GPT-free-Wednesday, or something like that :)

Re: 4 billion if statements (2023)

#90
post #10

> Now, this is a time-memory tradeoff, but my time on this earth is limited so I decided to meta-program the if statements using a programmer program in a different programming language. for i in range(2*8): if i % 2 == 0: No comment...

I think we can improve this. Just make a microservice who generates the code on the fly and streams it to the compiler. Then you also just have to create the necessary code and don't waste the SSD with unused code-paths.

I’m disappointed there is no docker image for this. How will I test it out?
Post reply on HN