707
submitted 22 hours ago* (last edited 22 hours ago) by not_IO@lemmy.blahaj.zone to c/programmer_humor@programming.dev
top 42 comments
sorted by: hot top controversial new old
[-] Prime@lemmy.sdf.org 2 points 2 hours ago

100% of the time, baby =)

[-] Semi_Hemi_Demigod@lemmy.world 3 points 6 hours ago* (last edited 6 hours ago)

If you scaled it based on the size of the integer you could get that up to 99.9% test accuracy. Like if it's less than 10 give it 50% odds of returning false, if it's under 50 give it 10% odds, otherwise return false.

[-] Jayjader@jlai.lu 2 points 3 hours ago

Now you're thinking with ~~portals~~ primes!

[-] zbyte64@awful.systems 5 points 8 hours ago

Pssh, mine uses a random number generator for odd numbers to return true 4% of the time to achieve higher accuracy and a bettor LLM metaphor

[-] apex32@lemmy.world 53 points 14 hours ago
[-] ulterno@programming.dev 7 points 6 hours ago

infoView the source to see how I embedded the picture without copying it. The hover text had to be copied though.

[-] savedbythezsh@sh.itjust.works 55 points 14 hours ago
[-] ulterno@programming.dev 4 points 6 hours ago

infoView the source to see how I embedded the picture without copying it. The hover text had to be copied though.

[-] BradleyUffner@lemmy.world 30 points 15 hours ago* (last edited 15 hours ago)

My favorite part of this is that they test it up to 99999 and we see that it fails for 99991, so that means somewhere in the test they actually implemented a properly working function.

[-] anton@lemmy.blahaj.zone 8 points 10 hours ago

That's a legitimate thing to do if you have a slow implementation that's easy to verify and a fast implementation that isn't.

[-] frank@sopuli.xyz 23 points 14 hours ago

No, it's always guessing false and 99991 is prime so it isn't right. This isn't the output of the program but the output of the program compared with a better (but probably not faster) isprime program

[-] BradleyUffner@lemmy.world 29 points 14 hours ago

Yes, that's what I said. They wrote another test program, with a correct implementation of IsPrime in order to test to make sure the pictured one produced the expected output.

[-] GalacticSushi@lemmy.blahaj.zone 36 points 14 hours ago

Plot twist: the test just checks to see if the input exists in a hardcoded list of all prime numbers under 100000.

[-] AI_toothbrush@lemmy.zip 17 points 13 hours ago

I mean people underestimate how usefull lookup tables are. A lookup table of primes for example is basically always just better except the one case where you are searching for primes which is more maths than computer programming anyways. The modern way is to abstract and reimplement everything when there are much cheaper and easier ways of doing it.

[-] ozymandias@sh.itjust.works 3 points 10 hours ago

more maths than computer programming anyways

Computer programming is a subset of maths and was invented by a mathematition, originally to solve a maths problem...

[-] AI_toothbrush@lemmy.zip 3 points 9 hours ago

Yeah but they slowly develop to be their own fields. You wouldnt argue that physics is math either. Or that chemistry could technically be called a very far branch of philosophy. Computer programing, physics, etc are the applied versions of math. You are no longer studying math, you are studying something else with the help of math. Not that it matters much, just makes distinguising between them easier. You can draw the line anywhere but people do generally have a somewhat shared idea of where that lies.

[-] ozymandias@sh.itjust.works 1 points 9 hours ago

Chemistry is a branch of alchemy

[-] MajorasTerribleFate@lemmy.zip 1 points 6 hours ago

I suppose, but only about insofar as the U.S. is a branch of the British Empire.

[-] frank@sopuli.xyz 3 points 12 hours ago

Ah gotcha. Or a known list yeah

[-] draco_aeneus@mander.xyz 3 points 10 hours ago

For prime numbers, since they're quite difficult to calculate and there's not that many of them, that's what's most common.

[-] Flipper@feddit.org 100 points 18 hours ago* (last edited 18 hours ago)

Has the same vibes as anthropic creating a C compiler which passes 99% of compiler tests.

That last percent is really important. At least that last percent are some really specific edge cases right?

Description:
When compiling the following code with CCC using -std=c23:

bool is_even(int number) {
   return number % 2 == 0;
}

the compiler fails to compile due to booltrue, and false being unrecognized. The same code compiles correctly with GCC and Clang in C23 mode.

Source

Well fuck.

[-] PlexSheep@infosec.pub 22 points 17 hours ago

If this wasn't 100% vibe coded, it would be pretty cool.

A c compiler written in rust, with a lot of basics supported, an automated test suite that compiles well known c projects. Sounds like a fun project or academic work.

[-] into_highest_invite@lemmygrad.ml 5 points 17 hours ago

any llm must have several C compilers in its training data, so it would be a reasonably competent almost-clone of gcc/clang/msvc anyway, right?

is what i would have said if you didn't put that last part

[-] renzhexiangjiao@piefed.blahaj.zone 22 points 16 hours ago* (last edited 16 hours ago)

you can increase its accuracy by changing the parameter type to long

[-] SexualPolytope@lemmy.sdf.org 65 points 19 hours ago

The error is ~1/log(x), for anyone interested.

[-] JustARegularNerd@lemmy.dbzer0.com 15 points 15 hours ago

I'm struggling to follow the code here. I'm guessing it's C++ (which I'm very unfamiliar with)

bool is_prime(int x) {
    return false;
}

Wouldn't this just always return false regardless of x (which I presume is half the joke)? Why is it that when it's tested up to 99999, it has a roughly 95% success rate then?

[-] Hexarei@beehaw.org 5 points 9 hours ago

Because only 5% of those numbers are prime

[-] kraftpudding@lemmy.world 34 points 15 hours ago

I suppose because about 5% of numbers are actually prime numbers, so false is not the output an algorithm checking for prime numbers should return

[-] JustARegularNerd@lemmy.dbzer0.com 11 points 15 hours ago

Oh I'm with you, the tests are precalculated and expect a true to return on something like 99991, this function as expected returns false, which throws the test into a fail.

Thank you for that explanation

[-] Agent641@lemmy.world 3 points 8 hours ago

And the natural distribution of primes gets smaller as integer length increases

[-] flamingo_pinyata@sopuli.xyz 28 points 15 hours ago

That's the joke. Stochastic means probabilistic. And this "algorithm" gives the correct answer for the vast majority of inputs

[-] fckreddit@lemmy.ml 34 points 18 hours ago* (last edited 18 hours ago)

LLMs belong to the same category. Seemingly right, but not really right.

[-] Viceversa@lemmy.world 5 points 18 hours ago* (last edited 18 hours ago)
[-] lemmydividebyzero@reddthat.com 17 points 16 hours ago

I have seen that algorithm before. It's also the implementation of an is_gay(Image i) algorithm with around 90% accuracy.

[-] Kekzkrieger@feddit.org 8 points 18 hours ago

If you think this is bad and not nearly enough accuracy to be called correct, AI is much worse than this.

It's not just wrong a lot of times or hallucinates but you can't pinpoint why or how it produces the result and if you keep putting the same data in, the output may still vary.

[-] red_tomato@lemmy.world 10 points 19 hours ago

It has actually 100% accuracy

[-] JustJack23@slrpnk.net 11 points 17 hours ago
[-] clav64@lemmy.world 5 points 15 hours ago

Can we just call the algorithm sex panther and move on?

[-] CanadaPlus@lemmy.sdf.org -3 points 9 hours ago* (last edited 8 hours ago)

I mean, an application could exist where this isn't even wrong. Maybe as a "subroutine" of another algorithm that only needs a truly composite number most of the time to work.

That this reads as a joke says a lot about what application we're intuitively expecting.

Edit: Not sure why this is being downvoted.

[-] ulterno@programming.dev 1 points 6 hours ago* (last edited 6 hours ago)

Edit: Not sure why this is being downvoted.

Perhaps because it would do better, being replaced with noop.

A link time optimiser might actually do so.

[-] CanadaPlus@lemmy.sdf.org 1 points 4 hours ago* (last edited 4 hours ago)

That's kind of what I meant by putting "subroutine" in quotes. You obviously wouldn't write it like this, you'd just use a random large number with a bit of explanation.

Oh well, live and learn. I'll try to be clearer next time.

this post was submitted on 22 Feb 2026
707 points (99.3% liked)

Programmer Humor

29947 readers
1008 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS