Reminds me of quantum-bogosort: randomize the list; check if it is sorted. If it is, you're done; otherwise, destroy this universe.
Programmer Humor
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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
The creation and destruction of universes is left as an exercise to the reader
Creation is easy, assuming the many-worlds interpretation of quantum mechanics!
What library are you using for that?
is-sorted and a handful of about 300 other npm packages. Cloning the repo and installing takes about 16 hours but after that you're pretty much good for the rest of eternity
that explains why it took god 7 days to make the universe
We still suffer from the runtime errors that could've been caught at compilation time.
In Python you just use
import destroy_universe
Since randomizing the list increases entropy, it could theoretically make your cpu cooler just before it destroys the universe.
My favorite is StalinSort. You go through the list and eliminate all elements which are not in line.
I tend to prefer Hiroshima sort. Sorting completed in O(1) time, and it frees up memory too.
Underrated comment.
// portability
Gave me the giggles. I've helped maintain systems where this portable solution would have left everyone better off.
import yhwh
def interventionSort(unsortedList):
sortedList = yhwh.pray(
"Oh great and merciful Lord above, let thine glory shine upon yonder list!",
unsortedList
)
return sortedList
Camelcase in python, ew, a fundamentalist would do that
This is the algoritm I use at work.
Everyone does... it's funny how it eventually works.
The most beautiful thing about this program is that it would work.
Various bit flips will once lead to all numbers being in the correct order. No guarantee the numbers will be the same, though...
Might also take a very long time (or a large amount of radiation).
Those bitflips are probably more likely to skip the section erroneously than waiting for the array to be sorted.
Fair enough! But won't they flip again to start the program?
The OS would crash entirely before that happens
Not necessarily. I don't have the numbers in front if me, but there is actually a probability that, past that point, something is so unlikely that you can consider it to be impossible (I.e. will never happen within the lifetime of the universe)
Yet... The chance is never zero 😁
Is it thread safe?
I hear, it actually significantly increases the chance of the miracle occurring when you pass the array into multiple threads. It's a very mysterious algorithm.
Shameless plug for my sort lib
edit: Looking at my old code it might be time to add typescript, es6 and promises to make it ✨ p r o d u c t i o n r e a d y ✨
Goos stuff, I will start using it. My code needs to chill out anyway
Hello programmers...
I recently took a course that went through basic python, C, and C++.
I had a hard time implementing various forms of sorting functions by hand (these were exercises for exam study). Are there any resources you folks would recommend so that I can build a better grasp of sorting implementations and efficiency?
Skiena's Algorithm design manual is very widely recommended for learning algorithms, I've also heard good things about A common sense guide to algorithms and data structures. Skiena's also has video lectures on YouTube if you prefer videos.
From what I've seen, a common sense guide seems to be more geared towards newer programmers while Skiena assumes more experience. Consequently, Skiena goes into more depth while A common sense guide seems to be more focused on what you specifically asked for. algorithm design manual
Thank you, awesome! I will definitely check out this material :)
Wait, that's exactly how i tidy up my kitchen!
On a long enough time scale, yes, it will get tidy.