From 519d44c0a7356bc03840549e421446656f7f2813 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Mon, 6 Dec 2021 16:22:35 +0000 Subject: Add Python solution to challenge 142 --- challenge-142/paulo-custodio/python/ch-2.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 challenge-142/paulo-custodio/python/ch-2.py (limited to 'challenge-142/paulo-custodio/python/ch-2.py') diff --git a/challenge-142/paulo-custodio/python/ch-2.py b/challenge-142/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..31f6f67abe --- /dev/null +++ b/challenge-142/paulo-custodio/python/ch-2.py @@ -0,0 +1,26 @@ +#!/usr/bin/python3 + +# TASK #2 > Sleep Sort +# Submitted by: Adam Russell +# Another joke sort similar to JortSort suggested by champion Adam Russell. +# +# You are given a list of numbers. +# +# Write a script to implement Sleep Sort. For more information, please checkout +# this post. + +import sys +import threading +from time import sleep + +def sleeper(n): + sleep(n) + print(n) + +thrs = [] +for n in [int(x) for x in sys.argv[1:]]: + thr = threading.Thread(target=sleeper, args=[n]) + thrs.append(thr) + thr.start() +for thr in thrs: + thr.join() -- cgit