3 ms·
> 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 diffe
by xg15 11mo ago
> 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...
- cowsandmilk 11mo agoHow horridly inefficient, he should have just flipped a Boolean on each iteration.
- _ache_ 11mo agoYeah... 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");""")
- NetMageSCW 11mo agoWhat happens when you try to compute 2**8+1 ?
- PurpleRamen 11mo agoI 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.
- travisgriggs 11mo agoI’m disappointed there is no docker image for this. How will I test it out?
- PurpleRamen 11mo agoMicroservice kinda implies usage of a container for me. How else would we google-scale it to serve all requests in parallel? But thinking about, we probably have to use some more microservices, we can't put all that burden on the requester. So a dedicated service for compiling and executing in sandboxes would be necessary. Also, some local load balancers to control the flow and filter out the useless answers. So I'm not an expert on that devops-magic, but I guess this means ~12.5 billion pods fast enough result. Do Amazon or Google offer planetary scale for services?
- layer8 11mo agoIt should have used a flag that is being toggled.
- catigula 11mo agoClaude's version: even, odd = "even", "odd" for i in range(2\*32): print(f' if (number == {i}) puts("{even}");') even, odd = odd, even As usual, a non-marginally superior mind to commentators.