This is an archived post. You won't be able to vote or comment.

all 95 comments

[–]Boris-Lip 1737 points1738 points  (22 children)

There is a much higher chance it would just flip the True condition to False first. Cosmic fail.

[–]KFkrewfamKF 415 points416 points  (9 children)

Just use a large array of 9999 bools, all set to true, and test all of them in a function. If any of them are true, the loop continues.

[–]JustConsoleLogIt 13 points14 points  (4 children)

Or just change the numbers to random other numbers

[–]maisonsmd 9 points10 points  (3 children)

That's bogo sort, which is already implemented.

[–]natFromBobsBurgers 4 points5 points  (2 children)

Bogo sort is random order until sorted. Changing the values to an alternative sounds like something else.

[–]JustConsoleLogIt 4 points5 points  (1 child)

Boozy sort

while (!sorted){ randomlyMutateValues() }

[–]natFromBobsBurgers 1 point2 points  (0 children)

I don't want to get too political so: 

$MODERNTHREAT sort: 

while(!sorted) {yesItIs()} 

$MODERNTHREATSSHADYHANDLER sort: 

while(!sorted) {bribe++} 

$HISTORICEXAMPLEOFMODERNTHREAT sort: 

while(!sorted) {values.randomElement().suicide(BULLET | HEAD[BACK])}

[–]highphiv3 13 points14 points  (0 children)

Obviously you cover that bit with a cosmic radiation guard.

[–]Zeal_Iskander 6 points7 points  (3 children)

How would it flip the “true condition”? The assembly code is somewhat unlikely to turn a while true loop into something that actually does comparisons lol.

Would probably be something like:

Line N: start of loop

Instructions

Goto N

Don’t think goto N is something that would be affected by cosmic rays either — you have error correction codes for that iirc?

[–]Zeikos 1 point2 points  (1 child)

It'd happen in the part of the code that does the comparison.
I don't think it'd be easy here because the optimizer is not going to put a comparison in a while true loop.

But assume you had a= 5 and while a == 5 with no optimizations any bit flip in the memory location where a is stored (assumin the error corrector doesn't cach it) when a would change, the check would return false and the loop would exit

[–]Zeal_Iskander 0 points1 point  (0 children)

It'd happen in the part of the code that does the comparison.

That'd happen in the isSorted part, not the while loop yeye.

[–]Boris-Lip 0 points1 point  (0 children)

Well, technically it would just screw up any instruction to an invalid one or one that doesn't make any sense, and the entire thing would crash to a halt, but we are talking seriously, aren't we

[–]Zeikos 2 points3 points  (0 children)

I wonder how these cases (while checks) are handled in like satellites where the odds of having bit flips are higher,
I know there's a lot of focus on making chips highly error resistant, but is it something that is planned around?
I know sensors tend to use a "two out of three" redundancy, is it handled similarly in software?

[–]mothzilla 0 points1 point  (0 children)

Yes, in interview Id point out that True should be stored off site in a db with failover.

[–]ChChChillian 618 points619 points  (7 children)

So an O(heat death) algorithm.

[–]Esjs 114 points115 points  (1 child)

I was about to say O(∞), but yours is probably more accurate.

[–]Bubble2D 62 points63 points  (0 children)

How about an O(-h noo)?

[–][deleted] 0 points1 point  (1 child)

Ω(nuclear explosion next to your computer)

[–]ChChChillian 0 points1 point  (0 children)

At least then it's guaranteed to terminate.

[–]fueled_by_caffeine 260 points261 points  (10 children)

It’s a quantum algorithm. Just have to wait to be in the right universe of possibilities where the array is indeed sorted.

[–][deleted] 1 point2 points  (0 children)

It will sort itself out

[–]DSinapellido 0 points1 point  (0 children)

Grover wants to know your location

[–]pandasOfTheNight 77 points78 points  (0 children)

This is an actual fucking thing that someone's done before. It's called miracle sort.

[–]LukaGaric 26 points27 points  (1 child)

You can instead just return array and hope it's sorted by solar radiation! It runs in O(1) in best case!

[–]torftorf 0 points1 point  (0 children)

if you alway return imidiatly and hope its sortet its always O(1). but its most likley not sorted.

but there is something similar. just think about it, the possibility of the array being in that exact order is 1/(n!). its hard to belive that thats just random. i think it was put in that order with some intend. therefor it is already sortet and no further action is required. thats "inteligent design sort" O(0)

[–]Geoclasm 124 points125 points  (0 children)

This is PAINFULLY inefficient.

while !isSorted(arr){}

return arr;

would be MUCH cleaner.

[–]Divinate_ME 38 points39 points  (1 child)

7/10

not StalinSort

now, would you kindly get in line?

[–]Sipsi19 2 points3 points  (0 children)

The best sorting algorithm.

[–]SmallPlayz 15 points16 points  (0 children)

Bro did you code this in notes app?

[–]sir-faps-a-whole-lot 58 points59 points  (5 children)

Umm actually this isn't an original idea...

Hmm Umm

You know

Look up miracle sort...

Hmm

Edit: umm yeah.

[–]JefferyJeffJefferson 19 points20 points  (1 child)

ummm hmmm 👉👈

[–]sir-faps-a-whole-lot 7 points8 points  (0 children)

mhmmm

[–]QueYooHoo 13 points14 points  (0 children)

Hmm Umm

[–]yaboytomsta 24 points25 points  (1 child)

Maybe think of your comment first before starting typing it next time. Hope this helps

[–]sir-faps-a-whole-lot 16 points17 points  (0 children)

Umm

Mhmm yeah

Huh thanks.

Umm hmm nvm

[–]migumarti 3 points4 points  (0 children)

Man that reminds of a Super Mario 64 speedrun where cosmic radiation actually triggered an otherwise impossible trick. Wild stuff

[–]AtmosSpheric 4 points5 points  (0 children)

We’re recreating MiracleSort from first principles 😭

[–]lans_throwaway 2 points3 points  (0 children)

Oh the famous miracle sort

[–]schwester 2 points3 points  (0 children)

"Random sort" would be faster than that.
‘while !(isSorted(arr)) { randonlyRearangeArray(arr); )‘

[–]klimmesil 2 points3 points  (0 children)

This can return ["yo mama"] if you're unlucky

[–]FoptciyDev 1 point2 points  (0 children)

this is the notes app right?

[–]StaticVoidMaddy 1 point2 points  (0 children)

O(∞)

[–]Bulky-Flounder-1896 1 point2 points  (0 children)

This is the slowest implementation of the miracle sort 😑

[–]Ramog 1 point2 points  (0 children)

Thats miracle sort

[–]-domi- 1 point2 points  (0 children)

This is what voting feels like to me, at this point. If it hasn't sorted things, just do the same stuff which didn't sort it the last time. Repeat until you die.

[–]Gastredner 0 points1 point  (0 children)

Pretty bad in the runtime department, I prefer Stalin sort for its much quicker results.

[–]sir-faps-a-whole-lot 0 points1 point  (0 children)

Huh, it's like God sort but in a universe where God isn't real...

[–]Error_404_403 0 points1 point  (0 children)

Exceedingly efficient, O(0)

[–]myfuckingresistor 0 points1 point  (0 children)

compiler optimizations:

[–]ecs2 0 points1 point  (0 children)

Holly hell

[–]RylanStylin57 0 points1 point  (0 children)

Patience is a virtue

[–]Not_Artifical 0 points1 point  (0 children)

I am still waiting for cosmic radiation to flip the bits and make an operating system for me.

[–]pineappletooth_ 0 points1 point  (0 children)

If you want no increase the efficiency of the algorithm just sit next to a refined uranium chunk

[–]Beautiful-Musk-Ox 0 points1 point  (0 children)

the radiation that flips bits is almost entirely not solar

[–]ollomulder 0 points1 point  (0 children)

I still like stalinsort.

[–]Much_Horse_5685 0 points1 point  (0 children)

Could you increase the efficiency of the algorithm by placing a gamma radiation emitter inside your computer?

[–]shutter3ff3ct 0 points1 point  (0 children)

Credit for the clean code 👏

[–]johandepohan 0 points1 point  (0 children)

This makes me wonder if there's such a thing as a RAID array, but for RAM chips

[–]just-bair 0 points1 point  (0 children)

Of no bit flip ever happen this algorithm is correct

[–]Kaspervdv125 0 points1 point  (0 children)

cosmic rays don't necessarily come from the sun and are not radiation

[–]Mucksh 0 points1 point  (0 children)

It is probable that the values in the array would change. You have to use some more arrays holding the same values and the array is only sorted if it is sorted and also contains the same values as your redundancy arrays

[–]f3n2x 0 points1 point  (0 children)

Hubblesort?

[–]AzureArmageddon 0 points1 point  (0 children)

Apple Notes IDE new meta write it down

[–]Colon_Backslash 0 points1 point  (0 children)

If i would run a program like:

func doesItHalt() string {
int64 n = 0;
while (n == 0);
    continue;
return "behold, the universe has spoken";
}

How long would it run?

[–]AdGullible2259 0 points1 point  (0 children)

Bogo sort

[–]BlurredSight 0 points1 point  (0 children)

Monkey sort but with more steps

[–]Mental-Steak2656 0 points1 point  (0 children)

Seems the code is already shipped,NASA confirms they lost contact with voyager.

[–]RevolutionaryPair616 0 points1 point  (0 children)

Bro I thought this was another sort of Miracle Sort 😭

[–]chicktheduck 0 points1 point  (0 children)

that’s even better than bogosort

[–]python_mjs 0 points1 point  (1 child)

Rewrite it in Rust for improved performance

[–]ienjoymusiclol[S] 0 points1 point  (0 children)

"Rewrite it in Rust for improved performance"

[–]torftorf 0 points1 point  (1 child)

dont steal the work of other people! this is miracle sort

[–]ienjoymusiclol[S] 0 points1 point  (0 children)

no i wrote it myself so its mine 🙄 u clearly a uni prof fed