Tuesday, January 7, 2014

Code-trolling - sorting by spawning threads

http://codegolf.stackexchange.com/a/16316

I came across this while searching for something else. I saw an obvious homework-type question in the right-side links. This is a hilarious solution.

Basically the question is, user inputs a list of doubles. I want to return it sorted to the user. There are various "trolling" answers, but I found this one to be the funniest.

Basically...

for each input i
  spawn thread with data i
  thread.sleep(i seconds)

thread callback
 put thread.data into output





No comments:

Post a Comment

There was an error in this gadget