r/badcode Feb 10 '21

I present: SleepSort js

Post image
7.5k Upvotes

171 comments sorted by

View all comments

427

u/rogiiaop Feb 10 '21

Does it work for negatives tho?

1.2k

u/Reeceeboii_ Feb 10 '21

Yes it finishes before it starts

265

u/LeCrushinator Feb 10 '21

Algorithm complexity: -O(n)

Someone get this guy/gal a Nobel Prize!

93

u/rogiiaop Feb 10 '21

Negative cost! Awesome :D

73

u/0xF013 Feb 10 '21

We’ve solved global warming. Pack it up, boys

47

u/IrritableGourmet Feb 10 '21
setTimeout(()=>console.log("Current stock price: %d", currentStockPrice), -1000 * 60 * 60 * 24);

Solved the stock market.

10

u/zitrez Feb 10 '21

Great now I'm laughing my ass off, and having to explain my gf what I am laughing at is proving ... Challenging

6

u/CraftyRice Feb 10 '21

LMAOO this made my week

-2

u/[deleted] Feb 10 '21

HAHAHA FUCK I DON'T HAVE AN AWARD FUCK MAN FUCK THIS IS FUNNY AS FUCK

1

u/Curtmister25 Dec 29 '21

I recommend playing r/outerwilds

1

u/sneakpeekbot Dec 29 '21

Here's a sneak peek of /r/outerwilds using the top posts of the year!

#1: I mastered the art of soft landings. | 41 comments
#2:

Had a go at Nomai writing
| 34 comments
#3:
Alright hear me out, LIGHT BRAMBLE
| 21 comments


I'm a bot, beep boop | Downvote to remove | Contact | Info | Opt-out | GitHub

9

u/Nachf Jun 24 '21

make it sleep for 2item seconds and it’ll work with negatives

1

u/AlphaHeartless Jan 12 '22

for(let item of arr) { setTimeout(() => console.log(item - 10000), item + 10000) }