this post was submitted on 22 Jun 2024
399 points (97.4% liked)

Programmer Humor

19589 readers
480 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 1 year ago
MODERATORS
 
top 21 comments
sorted by: hot top controversial new old
[–] victorz@lemmy.world 48 points 4 months ago* (last edited 4 months ago) (3 children)

How in the hell does anyone f— up so bad they get O(n!²)? 🤯 That's an insanely quickly-growing graph.

Curious what the purpose of that algorithm would have been. 😅

[–] magic_lobster_party@kbin.run 37 points 4 months ago (1 children)

You have two lists of size n. You want to find the permutations of these two lists that minimizes a certain distance function between them.

[–] catastrophicblues@lemmy.ca 2 points 4 months ago (1 children)

Surely you could implement this via a sorting algorithm? If you can prove the distance function is a metric and both lists contains elements from the same space under that metric, isn’t the answer to sort both?

[–] jjagaimo@lemmy.ca 7 points 4 months ago

It's essentially the traveling salesman problem

[–] petersr@lemmy.world 23 points 4 months ago (1 children)

Let me take a stab at it:

Problem: Given two list of length n, find what elements the two list have in common. (we assume that there are not duplicates within a single list)

Naive solution: For each element in the first list, check if it appears in the second.

Bogo solution: For each permutation of the first list and for each permutation of the second list, check if the first item in each list is the same. If so, report in the output (and make sure to only report it once).

[–] victorz@lemmy.world 2 points 4 months ago

lol, you'd really have to go out of your way in this scenario. First implement a way to get every single permutation of a list, then to ahead with the asinine solution. 😆 But yes, nice one! Your imagination is impressive.

[–] suzune@ani.social 6 points 4 months ago (1 children)

Maybe finding the (n!)²th prime?

[–] victorz@lemmy.world 1 points 4 months ago

I guess, yeah, that'll do it. Although that'd probably be yet one or a few extra factors involving n.

[–] raspberriesareyummy@lemmy.world 25 points 4 months ago* (last edited 4 months ago) (1 children)

N00b. True pros accomplish O((n^2)!)

[–] JPAKx4@lemmy.blahaj.zone 11 points 4 months ago

Your computer explodes at 4 elements

[–] alexdeathway@programming.dev 11 points 4 months ago

Did you write an algorithm to manually drag and drop elements?

[–] yetAnotherUser@discuss.tchncs.de 10 points 4 months ago* (last edited 4 months ago) (1 children)

Imagine if the algorithm were in Θ(n!²), that would be even worse

[–] catastrophicblues@lemmy.ca 2 points 4 months ago

You mean omega, not theta

[–] pkill@programming.dev 9 points 4 months ago

Also constant time is not always the fastest

[–] pkill@programming.dev 8 points 4 months ago

plot twist to make it worse: you put in in an onInput hook without even a debounce

How the fuck?!

[–] uis@lemm.ee 4 points 4 months ago* (last edited 4 months ago)

It may be efficient, not scalable for sure

Oh my god, that's inefficient as hell.

[–] Mikina@programming.dev 1 points 4 months ago* (last edited 4 months ago)

It has been a while since I have to deal with problem complexities in college, is there even class of problems that would require something like this, or is there a proven upper limit/can this be simplified? I don't think I've ever seen O(n!^k) class of problems.

Hmm, iirc non-deterministic turing machines should be able to solve most problems, but I'm not sure we ever talked about problems that are not NP. Are there such problems? And how is the problem class even called?

Oh, right, you also have EXP and NEXP. But that's the highest class on wiki, and I can't find if it's proven that it's enough for all problems. Is there a FACT and NFACT class?

[–] Kolanaki@yiffit.net 1 points 4 months ago

Wait... How can time ever not be constant? Can we stop time?! 😮

[–] Mikina@programming.dev 1 points 4 months ago

For me, my common result would be something like O(shit).