TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

4B If Statements

1518 pointsby r4umover 1 year ago

82 comments

furyofantaresover 1 year ago
I wish I still had one of the earliest programs I wrote. It would have been 1996, I was 16, and I had a linear algebra book which had an appendix entry on computer graphics. I had taken a programming class the prior quarter.<p>I got hooked writing a program to draw rotating wireframes of a few different shapes. I almost failed the class because I was so distracted by this.<p>I didn&#x27;t know about arrays yet. Every vertex was its own variable with a hardcoded default. Every entry in the rotation matrices was its own variable. The code to do matrix multiplication therefore didn&#x27;t have loops, just a long list of calculations. Which had to be duplicated and adapted to every vertex.<p>I did know about pointers, I had to draw to the screen after all, which was done by writing to memory starting at a known address. So at least I had loops rasterizing the lines between vertices.<p>Which means I definitely had the concept of arrays and indexing into them, I just didn&#x27;t know enough to make my own.
评论 #38793777 未加载
评论 #38795388 未加载
评论 #38799628 未加载
评论 #38799452 未加载
评论 #38798747 未加载
评论 #38793235 未加载
评论 #38802871 未加载
bilinguliarover 1 year ago
It seems over-engineered to me. Why go through all the hustle of code generation? It can be solved with a simple “for loop”:<p><pre><code> func isOdd(n int) bool { var odd bool for i := 0; i &lt; n; i++ { odd = !odd } return odd } </code></pre> Playground link: <a href="https:&#x2F;&#x2F;go.dev&#x2F;play&#x2F;p&#x2F;8TIfzGrdWDF" rel="nofollow">https:&#x2F;&#x2F;go.dev&#x2F;play&#x2F;p&#x2F;8TIfzGrdWDF</a><p>I did not profile this one yet. But my intuition, and my industry experience, tell me that this is fast.
评论 #38794183 未加载
评论 #38794142 未加载
评论 #38802193 未加载
评论 #38793854 未加载
评论 #38793278 未加载
评论 #38803893 未加载
评论 #38793256 未加载
评论 #38799844 未加载
oefrhaover 1 year ago
This approach is perfect for the is-even npm package[1], with 196,023 weekly downloads, or the is-odd npm package[2], with 285,501 weekly downloads. Wouldn&#x27;t it be cool if you type `npm install` and it starts downloading a 40GB is-even and a 40GB is-odd?<p>[1] <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-even" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-even</a><p>[2] <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-odd" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-odd</a>
评论 #38791336 未加载
评论 #38792262 未加载
评论 #38793355 未加载
评论 #38792082 未加载
评论 #38791235 未加载
评论 #38791149 未加载
评论 #38792296 未加载
评论 #38795851 未加载
评论 #38793062 未加载
评论 #38795748 未加载
评论 #38793227 未加载
评论 #38800346 未加载
评论 #38797566 未加载
评论 #38792210 未加载
评论 #38794866 未加载
评论 #38797854 未加载
评论 #38792073 未加载
评论 #38791972 未加载
BillyTheKingover 1 year ago
why though? this is exactly what databases have been invented for! One could simply store a mapping of numbers to their classifications as &#x27;even&#x27; or &#x27;odd&#x27; in an SQLite database. This approach has the added benefit of not requiring program updates whenever a number&#x27;s classification changes from odd to even.
评论 #38791886 未加载
评论 #38792164 未加载
评论 #38792196 未加载
评论 #38792287 未加载
评论 #38792145 未加载
raegisover 1 year ago
This is one of the most entertaining articles I&#x27;ve ever read here. He should put the source code online so ChatGPT can &quot;learn&quot; from it.
评论 #38794758 未加载
krickover 1 year ago
The joke is completely lost on me. I don&#x27;t even mean the person who did this — why not, after all. 1198 upvotes ATM is what confuses me.<p>Lookup tables for computable values are not novel, nor are they a joke. This actually is a solutions for the time&#x2F;memory tradeoff, as author well knows. The problem at hand is absurd, but quite primitive, so there was absolutely no doubt this can be done. No real measurements were performed, apart from the observations that it took about 10 seconds to chew through 40GB program on his computer. So what did we learn? That exe files cannot be more than 4GB? That a program with 2^32 ifs is about 300 GB? Why 1198 people found this interesting?<p>Maybe I&#x27;m spoiled, but unlike &quot;Hexing the technical interview&quot; or some SIGBOVIK stuff, this doesn&#x27;t seem crazy, just pointless.
评论 #38801412 未加载
评论 #38801792 未加载
评论 #38801476 未加载
评论 #38801963 未加载
friedrich_zipover 1 year ago
This is amazing technology. You should sell it to AWS so they can offer an Enterprise-ready AWS EvenOrOdd API for everyone who does not know how to host the 40GB executable properly. With the power of the cloud this programme would be unstoppable
评论 #38798812 未加载
winwangover 1 year ago
I&#x27;m surprised no one has chimed in on how the program is &quot;processing&quot; 40GB of instructions with only 800 MB&#x2F;s * 10s of disk read.<p>If I had to hazard a guess, there&#x27;s some kind of smart caching going on at the OS level, but that would entail the benchmark of &quot;n close to 2^32&quot; not being run correctly.<p>...Or that the CPU is smart enough to jump millions of instructions ahead.
评论 #38791038 未加载
评论 #38791079 未加载
评论 #38792488 未加载
评论 #38792092 未加载
评论 #38796471 未加载
评论 #38791073 未加载
评论 #38796504 未加载
Hugsunover 1 year ago
Visionary genius Ross van der Gussom is my new favorite mythological creature.
评论 #38790856 未加载
评论 #38792190 未加载
Patient0over 1 year ago
I feel like the whole article is an allegory of LLM development (as a critic would write it: devoting a stupendous amount of resources and &#x27;training data&#x27; to &#x27;memorize&#x27; the solution). I wonder if this was the author&#x27;s intent?
评论 #38791104 未加载
评论 #38791106 未加载
评论 #38800014 未加载
NKosmatosover 1 year ago
I’m pleasantly surprised that nobody started the discussion on whether zero is odd or even ;-) <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Parity_of_zero" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Parity_of_zero</a>
评论 #38791853 未加载
评论 #38796343 未加载
评论 #38795028 未加载
评论 #38792114 未加载
评论 #38802396 未加载
评论 #38792049 未加载
ashvardanianover 1 year ago
Jokes aside, lookup tables are a common technique to avoid costly operations. I was recently implementing one to avoid integer division. In my case I knew that the nominator and denominator were 8 bit unsigned integers, so I&#x27;ve replaced the division with 2 table lookups and 6 shifts and arithmetic operations [1]. The well known `libdivide` [2] does that for arbitrary 16, 32, and 64 bit integers, and it has precomputed magic numbers and lookup tables for all 16-bit integers in the same repo.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;ashvardanian&#x2F;StringZilla&#x2F;blob&#x2F;9f6ca3c6d3cbc2b9fa090bedb6fbf0d04b788279&#x2F;include&#x2F;stringzilla&#x2F;stringzilla.h#L1679">https:&#x2F;&#x2F;github.com&#x2F;ashvardanian&#x2F;StringZilla&#x2F;blob&#x2F;9f6ca3c6d3c...</a> [2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;ridiculousfish&#x2F;libdivide">https:&#x2F;&#x2F;github.com&#x2F;ridiculousfish&#x2F;libdivide</a>
phkahlerover 1 year ago
Clearly they should have optimized using binary search. Use nested if-else statements 31 deep. This would require using a more sophisticated comparison like &lt; less than instead of equals. You&#x27;d get a similar amount of code, but it would execute on O(logN) instead of O(N). That would surely be the mark of an expert. ;-)
keitmoover 1 year ago
I&#x27;d like to see a fully distributed version. All you need is 4B hosts (IPV6 FTW) named N.domain.com (where N varies from 0 to 4B-1). The driver app sends N to the first host (0.domain.com). Each host compares the incoming N with their N.domain.com name; if they match, return the host&#x27;s true&#x2F;false value. If they don&#x27;t match, forward the request to (N+1).domain.com and return the result.
评论 #38799332 未加载
评论 #38799061 未加载
glandiumover 1 year ago
It&#x27;s kind of ironic that the python generator script uses modulo. The author could have pushed it to the point of not using one.<p>I&#x27;m tempted to write a followup doing even crazier things...
评论 #38792415 未加载
评论 #38792323 未加载
评论 #38791878 未加载
评论 #38791520 未加载
satiricover 1 year ago
Surely any solution that claims to be performant would use a binary search, rather than looping through every number. Would be a little trickier to generate the code though.<p>Edit: &#x2F;s of course
评论 #38791360 未加载
评论 #38790880 未加载
评论 #38791052 未加载
评论 #38792168 未加载
faizshahover 1 year ago
This metaprogramming reminds me of the post where they serialized data to ruby code to get around a slow XML parser: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36311924">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36311924</a><p>I’m curious if anyone has found a serious application for metaprogramming large amounts of data in a high level language like this?<p>So far the only application I have thought of was meta programming a series of api calls before executing them so the entire transaction can be replayed as a script.
评论 #38791678 未加载
评论 #38791365 未加载
评论 #38791769 未加载
评论 #38791269 未加载
评论 #38793754 未加载
bryanlarsenover 1 year ago
That reminds me of my first program ever as an 11 year old. Not only did I not know about modulus, I didn&#x27;t know about less than or greater than. The program picked bingo numbers. So there were 5 lines that looked something like `10 IF n=1 OR n=2 OR n=3 OR n=4 OR n=5 OR n=6 OR n=7 OR n=8 OR n=9 OR n=10 OR n=11 OR n=12 OR n=13 OR n=14 OR n=15 THEN l=&quot;B&quot;`
LASRover 1 year ago
At 9, I tried to make a game that combined SimCity 2000 and Transport Tycoon Deluxe - my favs at the time. I used MFC(Windows) because my parents got me a big black book about it. My game was a simple train simulator with four trains. Each train moved turn by turn to its destination from its origin. Each train had to finish its move before the next train had a chance to move.<p>I wrote it in C++ but didn&#x27;t know much about managing the game&#x27;s state or objects. But there was some fancy acceleration code in there.<p>You &quot;played&quot; the game by modifying the hardcoded x,y coordinates in the code and admiring how the trains moved on screen.<p>I thought real games used multi-threading to move each train at the same time. When I tried it, the game broke, probably because of UI updates from other threads.<p>So I never quite built my game. But this project, with all its problems, got me into software development years later.
Joker_vDover 1 year ago
If your programming language of choice has no arrays (like most of the languages implemented in one of the many, many, many &quot;How to write your own interpreter&#x2F;simple compiler&quot; tutorials out there) but supports variables, then you can use this technique to kinda implement them anyway, Okasaki-style:<p><pre><code> var arr0, arr1, arr2, arr3, arr4, ..., arr65535 : int; func get_arr(index: int): int { if index &lt; 0 or index &gt; 65535 { exit(); } if index &lt; 32768 { if index &lt; 16384 { if index &lt; 8192 { ... if index &lt; 2 { if index &lt; 1 { return arr0; } else { return arr1; } } else { if index &lt; 3 { return arr2; } else { return arr3; } } ... } else { ... } } else { ... } } else { ... } } proc set_arr(index: int, value: int) { if index &lt; 0 or index &gt; 65535 { exit(); } if index &lt; 32768 { if index &lt; 16384 { if index &lt; 8192 { ... if index &lt; 2 { if index &lt; 1 { arr0 = value; } else { arr1 = value; } } else { if index &lt; 3 { arr2 = value; } else { arr3 = value; } } ... } else { ... } } else { ... } } else { ... } } </code></pre> It even has O(log n) access time which is actually the same complexity as accessing a RAM by a pointer anyway! Just replicate this code for any array variable you need to simulate and pre-allocate enough of the memory, it&#x27;s totally free with that .bss trick anyhow.<p>So technically, languages without arrays are about as Turing-complete as those with limited-size pointers&#x2F;array indices (funnily enough Brainfuck — where the pointer is invisible to the progammer — <i>actually</i> is Turing-complete).
评论 #38790999 未加载
评论 #38791048 未加载
i_k_kover 1 year ago
When I was in college, I had to take an assembly language course. It was on MIPS: 32 registers.<p>One assignment said, roughly:<p>- Read ten numbers into an array.<p>- Sort the numbers into the array.<p>Nothing said I needed to read the array, so I read in the numbers, both to the array and registers, hardcoded a bubble sort on the registers, and wrote the result to the array. End of program.<p>I was being cute. I got full marks with a note to stop being cute.
cushpushover 1 year ago
Fantastic use of meta-programming, and I like the benchmarking at the end, you have clarified much for the beginner and expert alike.
dorfsmayover 1 year ago
That work is amazing!<p>Now before you laugh at the original meme and the use of AI chosing the wrong algorithm, read this:<p><a href="https:&#x2F;&#x2F;fosstodon.org&#x2F;@gabrielesvelto&#x2F;110592904713090347" rel="nofollow">https:&#x2F;&#x2F;fosstodon.org&#x2F;@gabrielesvelto&#x2F;110592904713090347</a><p>There is no proof AI was used, but:<p>&gt; Google&#x27;s code was allocating 20000 variables in a single frame.
zimpenfishover 1 year ago
Weirdest bit is this, I think.<p>&gt; After all, IPv4 is still standing stronger than ever, 60 years after it was deemed deprecated due to so called “address exhaustion”.<p>IPv4: deprecated in 1963, 19 years before it was introduced.
评论 #38791935 未加载
Retr0idover 1 year ago
&gt; for the large number close to the 2^32 limit the result is still returned in around 10 seconds.<p>This could be improved by arranging the if&#x2F;else statements in a binary tree.
评论 #38791353 未加载
评论 #38791503 未加载
评论 #38791350 未加载
评论 #38791514 未加载
schaeferover 1 year ago
From the article:<p>“Now, in a world where AI is replacing programmers by the minute, taking their jobs and revolutionizing the way we think about code, maybe we should…”<p>Excuse me ?!?<p>I get that job loss due to AI is a common fear. But is there any hard evidence that the job market is losing “a software engineering job a minute” to AI? That’s 525600 jobs annually…
评论 #38793281 未加载
midjjiover 1 year ago
% is a surprisingly slow way to do so compared to x &amp; 1.
评论 #38790840 未加载
gwernover 1 year ago
I&#x27;m mildly surprised that the compiler seems to compile the code so literally so that the binary blows up like that with a linear runtime as well. I would&#x27;ve guessed that for such a straight-line execution on one of the simplest mathematical operations to yield a boolean, a modern highly-optimizing compiler would&#x27;ve done <i>something</i> with it.<p>What would it take to make the compiler optimize this code meaningfully?
评论 #38819413 未加载
adastra22over 1 year ago
I enjoyed this more than I should have.
gverrillaover 1 year ago
First program I ever wrote was to bypass an anti-afk program in a game: it needed to click on a button which was x vs y pixels, and would appear on random positions on the screen every time. I manually inserted one line for each viable position using x-1 and y-1. In v2 I implemented a for loop which made the script go from tens of pages to not even a single full one - computer magic! (EasyUO language)
kazinatorover 1 year ago
That looks like a program developed with TDD that has gone on too long without refactoring.<p>The author probably has a billion individual tests that will all lose their value if it were to be simplified, since they would no longer correspond to special cases in the code.
Nevermarkover 1 year ago
As a kid I heard that circuits like adders were made from boolean algebra AND, OR and NOT gates.<p>I played around on a big paper pad, and finally got a 4 bit adder implementation.<p>But since my unit circuit was [A,B]-&gt;[S], instead of the canonical [A,B,carry-in]-&gt;[S,carry-out], I had to add a second layer of units to propagate the first carry onward. And a third layer of units in case that also generated a carry. Etc.<p>So my circuit had gate of order N^2&#x2F;2 and depth order of 2*N instead of gate and depth orders of N.
Der_Einzigeover 1 year ago
I was hoping that this would be about someone finally building an LLM out of a decision tree or decision tree derived technique (which ultimately boils down to nested if statements). Not sure why no one has tried it yet.
评论 #38790890 未加载
tcgvover 1 year ago
&gt; In fact, the above code is a perfect example of a time-memory tradeoff<p>Not as much since the program will take increasingly more time to run as the input number gets higher. Checking if a &#x27;small&#x27; number is even or odd will be pretty fast. Checking a &#x27;large&#x27; number will be slow since it will go through all &#x27;IFs&#x27; until it reaches the result.<p>It&#x27;s like O(M&#x2F;2) average time complexity where &#x27;M&#x27; is a constant, the program memory size (number of &#x27;IFs&#x27; stored).
评论 #38793714 未加载
orhanoover 1 year ago
Not to compete with your brilliant code on optimization, bu I have also written a swap routine that excels especially on numbers close to each other. I know sign function result can be put into a variable, but computers nowadays are so fast...<p>Anyone feel free to use it.<p>static void swap(ref int a, ref int b) { int c = (b - a) ; while (c != 0) { a += Math.Sign(c); b -= Math.Sign(c); c -= Math.Sign(c); } }
Perepiskaover 1 year ago
The whole article looks like a misunderstanding to me. The author writes about a trade-off between memory and processor, although in his example both memory (on disk and in RAM) and processor are wasted (executing all IF instructions in turn).<p>It is also strange that the author is trying to generate code in assembly language, which he does not know very well, because there is a DIV&#x2F;IDIV instruction.
评论 #38807443 未加载
Twirrimover 1 year ago
I gave similar a shot in rust, using build.rs to dynamically create the file, inspired by the blog post. I&#x27;d been meaning to look at build.rs for a while.<p>It seems to hit a pretty pathological compilation situation. Done as ifs, rust ran out of stack. Done as &quot;match&quot; it has been compiling for about 24 hours.
JacobSeatedover 1 year ago
Interesting. How would this compare to making a while loop or recursive function, I wonder?<p>And, what about switch statements? In theory it is said they should be faster, but I am not sure that&#x27;s necessarily the case.<p>Another option would be to keep a database with the numbers indexed, and then compare with performing a database query.
gigantinoover 1 year ago
When I was young I tried to make my own alarm clock.<p>My masterplan was to print the time to the display (starting from 8 AM), wait a second and print the next value. All manually, obviously.<p>I remember eventually giving up because it was getting too boring. I think I discovered about loops a year after the event.<p>Great times :)
wenyuanyuover 1 year ago
better to keep &quot;4 billion&quot; in the title... I was confused with &quot;4 bytes&quot; before open the link
majkeover 1 year ago
In the blog post &quot;Branch predictor: How many &quot;if&quot;s are too many?&quot;, I started with the same premise, but focused on branch predictor :P<p><a href="https:&#x2F;&#x2F;blog.cloudflare.com&#x2F;branch-predictor" rel="nofollow">https:&#x2F;&#x2F;blog.cloudflare.com&#x2F;branch-predictor</a>
1vuio0pswjnm7over 1 year ago
&quot;Since I&#x27;m a great believer in performant code I decided to implement this in the C programming language as it&#x27;s by far the fastest language on the planet to this day (thanks to the visionary genius Dennis Richie).&quot;<p>Fastest portable language. Assembler is faster.
MPSimmonsover 1 year ago
This is the kind of insanity I miss from the early internet. Excellent job. Thank you for this.
maxlinover 1 year ago
I&#x27;d be interested in seeing how this would have gone with a switch statement instead.
评论 #38792997 未加载
Subdivide8452over 1 year ago
Can’t you just test the last digit of main’s arg and get the best of both worlds?
评论 #38791435 未加载
docfortover 1 year ago
So I honestly thought that this was going to be another LLM article, but using the venerable ReLU activation function instead of the usual. A ReLU is exactly an if statement when rendered in a decision tree (if less than 0, emit 0; otherwise, emit the input). Given the relative popularity of the 4B parameter models (any transformer is dominated by the number of parameters in good old fully-connected feedforward layers), you can perhaps describe such models as 4B if statements. I was disappointed that the author didn’t go there as a means of parody.
timrobinson333over 1 year ago
I&#x27;m afraid I take issue with the phrase &quot;amazingly performant&quot;. I would struggle to come up with another way of determining whether a number near 2^32 is even that takes anything like 10 seconds
评论 #38793831 未加载
davidy123over 1 year ago
What was really hurting me was all the literal strings &quot;even&quot; and &quot;odd.&quot; I would have made them into constants. I guess then the next step would be to use constants for all the numbers.
amaiover 1 year ago
Reminds me of that guy who scrolled to the end of Excel: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;sF8k3zl70os" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;sF8k3zl70os</a>
irrationalover 1 year ago
&gt; we need more if statements!<p>Waiting for the Will Ferrel skit of this. Though this article was funny enough on its own. The Python program to generate the C code was hilarious.
brcmthrowawayover 1 year ago
Those APIs seem like fake pseudocode, until I realized... Windows
winddudeover 1 year ago
I to do lots of &quot;researching&quot; on social media.
notfedover 1 year ago
&gt; modulus operation<p>Isn&#x27;t it normally called the modulo operation?
评论 #38792077 未加载
asylteltineover 1 year ago
The TikTok is fake. Obviously it was created to drive engagement. Everything you see on TikTok is there to manipulate your emotions.
quickthrower2over 1 year ago
Home run! (First blog post blows up on HN)
klochover 1 year ago
This seems dangerously close to spawning a new busy beaver type inefficient resource utilization game
kolinkoover 1 year ago
He should&#x27;ve used regex for that.
评论 #38796076 未加载
cchanceover 1 year ago
Not gonna lie, i really thought he was gonna end it with... now lets try 64bit, and leave us hanging
OkGoDoItover 1 year ago
Ah, the holidays: when the most ridiculous and interesting technical work gets done. I love it.
otteromkramover 1 year ago
I wish people would stop putting open curly braces on new lines. Makes it harder to read, IMHO.
KETHERCORTEXover 1 year ago
Come on, we live in 2023 and we can achieve better performance. It should be parallelized with checks evenly distributed between GPU cores. Unless you think that efforts by NVIDIA and AMD should be wasted.
3cats-in-a-coatover 1 year ago
I&#x27;d say wrap this with a good interface and we can optimize it later.
sdwvitover 1 year ago
This feels like a game of utilizing a PC at 100% capacity.
Liebnitzover 1 year ago
&gt;Apple declined to comment for this article.
brcmthrowawayover 1 year ago
The skeleton of this post can make a good interview question
csoursover 1 year ago
My biggest hope for code GPTs is replacing dependencies.
lowiiover 1 year ago
Seems like a poorly chosen example, since you could simply &quot;lookup&quot; the last bit of the integer to see if it is even or odd, which should be instant for any integer?
HeavyStormover 1 year ago
Why did I waste my time reading this? Hahaha
kaetemiover 1 year ago
Lmao. The copyright headers.
评论 #38790919 未加载
rezonantover 1 year ago
Well this has been hilarious.
foxhopover 1 year ago
performant != high performance he used it twice so I felt compelled to state this
ykonstantover 1 year ago
Although not quite as spectacular as that, here is some funny codegen in POSIX shell I wrote; `sh` doesn&#x27;t have a `repeat` command, so I wrote a script to implement it without forcing any loops at all. Along the way I uncovered some interesting segfaults for most sh implementations (including, sadly, dash), which is the reason for the somewhat convoluted code. Have fun!<p><pre><code> #!&#x2F;bin&#x2F;sh # # Usage: repeat TIMES COMMAND # Repeat COMMAND a given number of TIMES. eval_full_quotes=&#x27; s&#x2F;\\&#x2F;\\\\&#x2F;g ; s&#x2F;\&quot;&#x2F;\\\&quot;&#x2F;g ; s&#x2F;&lt;&#x2F;\\&lt;&#x2F;g ; s&#x2F;&gt;&#x2F;\\&gt;&#x2F;g ; s&#x2F;\$&#x2F;\\\$&#x2F;g ; s&#x2F;\[&#x2F;\\\[&#x2F;g ; s&#x2F;*&#x2F;\\*&#x2F;g ; s&#x2F;?&#x2F;\\?&#x2F;g ; s&#x2F;|&#x2F;\\|&#x2F;g ; s&#x2F;&amp;&#x2F;\\&amp;&#x2F;g ; s&#x2F;~&#x2F;\\~&#x2F;g ; s&#x2F;=&#x2F;\\=&#x2F;g ; s&#x2F;;&#x2F;\\;&#x2F;g ; s&#x2F; &#x2F;\\ &#x2F;g ; s&#x2F;%&#x2F;\\%&#x2F;g ; s&#x2F;`&#x2F;\\`&#x2F;g ; s&#x2F;(&#x2F;\\(&#x2F;g ; s&#x2F;)&#x2F;\\)&#x2F;g ; s&#x2F;{&#x2F;\\{&#x2F;g ; s&#x2F;}&#x2F;\\}&#x2F;g ; s&#x2F;#&#x2F;\\#&#x2F;g ; s&#x2F;&#x27;&quot;&#x27;&quot;&#x27;&#x2F;\\&#x27;&quot;&#x27;&quot;&#x27;&#x2F;g&#x27; errorx() { printf &#x27;Error: %s\n&#x27; &quot;${*:-&quot;unknown error.&quot;}&quot; &gt;&amp;2; exit 1; } _rep() { rep_times=&quot;$((2 * $1))&quot; rep_string=&quot;$2&quot; output=&quot;&quot; while [ 0 -lt &quot;${rep_times}&quot; ]; do test 1 -eq &quot;$(((rep_times &#x2F;= 2) % 2))&quot; &amp;&amp; output=&quot;${output}${rep_string}&quot; rep_string=&quot;${rep_string}${rep_string}&quot; done printf &#x27;%s&#x27; &quot;${output}&quot; } { times=&quot;$1&quot; shift test 0 -lt &quot;${times}&quot; || errorx &quot;First argument must be a positive integer.&quot; test 0 -lt &quot;$#&quot; || errorx &quot;No command given to repeat.&quot; repeat_command=&quot;$*&quot; command_length=&quot;${#repeat_command}&quot; max_arg=&quot;${ARG_MAX:-&quot;$(getconf ARG_MAX)&quot;}&quot; if [ &quot;${max_arg}&quot; -le &quot;$((times * (command_length + 2)))&quot; ]; then : &quot;$(( block_size = max_arg &#x2F; (20 * (command_length + 2)) ))&quot; : &quot;$(( blocks = times &#x2F; block_size + 1 ))&quot; : &quot;$(( remainder = (block_size + (times % block_size)) % block_size ))&quot; eval_string=&quot;$(_rep &quot;${block_size}&quot; &quot;${repeat_command}; &quot; | sed -e &quot;${eval_full_quotes}&quot;)&quot; while [ 0 -lt &quot;$((blocks -= 1))&quot; ]; do eval eval &quot;${eval_string}&quot; done eval_string=&quot;$(_rep &quot;${remainder}&quot; &quot;${repeat_command}; &quot; | sed -e &quot;${eval_full_quotes}&quot;)&quot; eval eval &quot;${eval_string}&quot; else eval_string=&quot;$(_rep &quot;${times}&quot; &quot;${repeat_command}; &quot; | sed -e &quot;${eval_full_quotes}&quot;)&quot; eval eval &quot;${eval_string}&quot; fi } exit</code></pre>
matrix2596over 1 year ago
its funny but the large language models can be seen as billions of if statements learnt from data
评论 #38790941 未加载
pbwover 1 year ago
I like the engineering effort, but it&#x27;s tainted by puerile comments like &quot;visionary genius of Ross van der Gussom&quot;.
junonover 1 year ago
It took me way too long to realize this was satire. It was a stressful read up until that point.
keepamovinover 1 year ago
This was hilarious thank you. Many lols
teaearlgraycoldover 1 year ago
&gt; Now, in a world where AI is replacing programmers by the minute, taking their jobs and revolutionizing the way we think about code<p>I’m dumb. This is a joke right? At most I can say AI has revolutionized how I interface with documentation.
评论 #38791018 未加载
评论 #38793874 未加载
评论 #38791693 未加载
评论 #38790793 未加载
评论 #38790819 未加载
usrbinbashover 1 year ago
&gt; Running this gives us a nice 40 GB file which contains all 4.2 billion comparisons needed to determine if any 32 bit number is even or odd!<p>For some reason I am thinking of npm now ...
Racing0461over 1 year ago
&gt; ; add the next 2...2^32-1 comparisons here<p>Chatgpt is getting so lazy these days.
stevefan1999over 1 year ago
Why do people always got skill issue and can&#x27;t learn to use proper modulo arithmetic? It seems like those &quot;TikTok idiots&quot; always get the limelight over this kind of silly thing
charcircuitover 1 year ago
Here is a version with 0 if statements<p><pre><code> #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main(int argc, char** argv) { return printf(atoi(argv[1]) &amp; 1 ? &quot;odd&quot; : &quot;even&quot;) &lt; 0; }</code></pre>
评论 #38791015 未加载
lmmover 1 year ago
&gt; Considering the computer has to read 40 GB of data from disk, map it to physical memory and then let the CPU has a rip of it<p>No it doesn&#x27;t? Maybe it needs to set up page tables for 40GB, but it doesn&#x27;t need to read the parts you&#x27;re not using into memory, that&#x27;s part of the point of memory-mapping like this - it sets up a page fault handler to load the page into memory when accessed, rather than needing to do it all up-front.
评论 #38790692 未加载
评论 #38791450 未加载
评论 #38790771 未加载