Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Genius sorting algorithm: Sleep sort

Name: Anonymous 2011-01-20 12:22

Man, am I a genius. Check out this sorting algorithm I just invented.


#!/bin/bash
function f() {
    sleep "$1"
    echo "$1"
}
while [ -n "$1" ]
do
    f "$1" &
    shift
done
wait


example usage:
./sleepsort.bash 5 3 6 3 6 3 1 4 7

Name: Anonymous 2011-06-20 6:21

>>319 notsureiftrolling.jpg

Name: Anonymous 2011-06-20 14:43

Ok, I've been thinking about this sleep sort thing for a few days now.  Thanks OP for nerd-sniping me.  First off, the command `usleep` should be used in place of `sleep` for a significant speedup.  But along this same vein, what we really want is to get to the granularity of the number of clock cycles it takes to print a number.  Furthermore, if we alter this for a real-time scheduler, then we can just schedule each print with a priority of i times a constant (the amount of time it would take to print i).  The scary part is that this would run in O(n) time -- which is supposed to be impossible.

Name: Anonymous 2011-06-20 14:58

i still dont get for what u should use that thing

Name: Anonymous 2011-06-20 15:03

sleepsort is a variation on loopsort which is O(n)

You first find the minimum and maximum O(n)

make a bitfield with size [maximum - minimum] O(1)

Loop through the input array again, setting a bit to 1 at [iterator - minimum] O(n)

Loop through the bitfield and push the value (iterator + minimum) on a stack. O(n)

O(n) + O(n) + O(n) + O(1) = O(n)

Name: Anonymous 2011-06-20 15:11

But isn't it a counting sort?

Name: Anonymous 2011-06-20 15:33

[code]#!/usr/bin/python2
import sys, time, threading

def ss(i):
    time.sleep(int(i))
    print i

for i in sys.argv[1:]:
    threading.Thread(target=ss, args=i).start()

Name: Anonymous 2011-06-20 16:15

>>326
reddit children, behave!

Name: Anonymous 2011-06-21 7:58

Keep, Because you editors keep behaving as nazis. I am a German citizen and when I was a young boy watched books being burned. You delete article of programming language because they are "not notable". By your definition, "Puff Daddy" are "not notable" to me. I should propose to delete their article. There is nothing wrong with information. You are nazis. To hell with you. 79.169.56.225 (talk) 11:58, 21 June 2011 (UTC)

Name: Anonymous 2011-06-21 8:59

>>328
VIPPER detected

Name: Anonymous 2011-06-21 13:48

Hey guys, It isn't any linear or quadratic time algorithm. Its an exponential time algorithm - "The worst" we can say in sorting algorithms. However the sleep thing is fantastic as CPU can perform another operations interim.

Name: Anonymous 2011-06-21 15:16

>>330
Hey guys, It isn't any linear or quadratic time algorithm. Its an exponential time algorithm

The one implementation can run in linear time. Now shut the fuck up and let the little jewish girls show us what they know.

Name: Anonymous 2011-06-21 15:25

<-- check em dubz

Name: Anonymous 2011-06-21 15:26

>>332
nice

Name: Anonymous 2011-06-21 17:21

OP here. Did someone submit this to reddit, or did they jsust randomly pick it up?   This has gone full lulz - especially the wikipedia afd discussion...also been googling, loads of blogs and stuff fapping over it - google translate is my friend for reading all the jap/chinny blogs

Name: Anonymous 2011-06-21 19:47

>>334
OP here.
Will save to disbelieve…success!

gone full lulz
We had a funny joke.  A bunch of idiots who hadn't heard a joke in 10 years eventually ran into it.  Now we have a funny joke and a bunch of idiots.

Name: Anonymous 2011-06-21 20:04

>>334
Wait, WAIT. It's on wikipedia too? Goddamn.

Name: Anonymous 2011-06-21 20:12

>>336
What did you expect?

Name: Anonymous 2011-06-21 22:56

It's on #scheme too.


<klutometis> cky: It turns out the pjb was actually talking about sleep-sort: <http://dis.4chan.org/read/prog/1295544154>;.

Name: Anonymous 2011-06-22 5:28

http://en.wikipedia.org/wiki/Sleep_sort
Although its origins are unclear, an internet forum thread from 2011 by an anonymous programmer is believed to be the earliest known reference to the algorithm.

Also this thread is an ``unreliable source''.

Name: Anonymous 2011-06-22 5:59

We Wikipedia now!

Name: Anonymous 2011-06-22 8:46

>>340

No, I'm Wikipedia!

Name: Anonymous 2011-06-22 8:53

requesting a picture of the sussman being peed on to undermine this site as a soruce

Name: Anonymous 2011-06-22 9:08

http://hackerne.ws/item?id=2657942
The mailto:sage links in some of the posts are essentially public downvotes; from the Japanese "下げ", meaning "down", and pronounced "sah ge".
Incorrect, sbierwagen.

Name: Anonymous 2011-06-22 9:26

>>343
DOWNVOTED! SAGE!

Name: Anonymous 2011-06-22 9:31

>>344
Downvoted.

Name: Anonymous 2011-06-22 9:38

<-- check em dubz

Name: Anonymous 2011-06-22 9:40

>>346
Good job.

Name: Anonymous 2011-06-22 9:47

Sageru in the Japanese language is the dictionary form of to lower. The case of applying sage to the email field will mean that the thread is not bumped to the top of the thread list, the thread position is maintained as opposed to the standard behaviour when the thread position is normally bumped to the top of the list.

Name: Anonymous 2011-06-22 10:01

>>348
Downvoteru.

Name: Anonymous 2011-06-22 10:26

>>348

upboat

Name: Anonymous 2011-06-22 11:02

DEY TURK ERRR DUBZ!!!!

Name: Anonymous 2011-06-22 16:54

I consider myself conversant with 4chan, and I had no idea that the dis subdomain existed.
I always wondered if there was a chan for hackers...now I realize there is. And oh boy, what a chan it is.

Boy is he in for a surprise when he finds out /prog/ is just a bunch of autistic undergrads with a hard-on for functional programming.

Name: Anonymous 2011-06-22 17:50

>>352
speak for yourself machumbo... i work as a developer and only use imperative languages

Name: Anonymous 2011-06-22 17:55

GTFO

Name: Anonymous 2011-06-22 18:40

>>352

You never realized the whole read SICP thing was just a joke?
Wow, you must be pretty stupid.

Name: Anonymous 2011-06-22 18:44

>>355

You never realized the whole ``You never realized the whole read SICP thing was just a joke? Wow, you must be pretty stupid.'' thing was just a joke?
Wow, you must be pretty stupid.

Name: Anonymous 2011-06-22 19:04

>>356

You never realized the whole ``You never realized the whole ``You never realized the whole read SICP thing was just a joke? Wow, you must be pretty stupid.'' thing was just a joke? Wow, you must be pretty stupid.'' thing was just a joke?
Wow, you must be pretty stupid.

Name: Anonymous 2011-06-22 19:54

>>356,357

You're not funny, please go back to /g/ or wherever you came from.

Name: Anonymous 2011-06-22 20:00

>>355-357
[m]Back to /prog/, please.[m]

Name: Anonymous 2011-06-22 20:02

>>359
Ah, fuck, messed up.

>>355-357
Back to /prog/, please.

Newer Posts