Friday puzzle

My good friend Frank just sent me this email (I did translate to English though). I had never seen the algorithm before, so it gave me a good laugh. Now I need to share it. It’s written in Groovy:

If you just need to get some blood through the neural cells after the pork roast, try to figure out the code below.

Hint: a classic sort algorithm, but which one?


import java.util.concurrent.*

def list = new CopyOnWriteArrayList()

def task = { n ->
t = {
} // job in a closure
t as Callable // return block as a callable }

def workers = []

[5, 3, 7, 2, 1, 1, 3, 4].each { n ->

def executor = Executors.newFixedThreadPool(workers.size());
def futures = executor.invokeAll(workers, 10, TimeUnit.SECONDS);

println list # the sorted list

So, what is it? Eh’? Eh’? :o)

Please leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s