Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
from time import sleep
|
||||
from threading import Timer
|
||||
|
||||
def sleepsort(values):
|
||||
sleepsort.result = []
|
||||
def add1(x):
|
||||
sleepsort.result.append(x)
|
||||
mx = values[0]
|
||||
for v in values:
|
||||
if mx < v: mx = v
|
||||
Timer(v, add1, [v]).start()
|
||||
sleep(mx+1)
|
||||
return sleepsort.result
|
||||
|
||||
if __name__ == '__main__':
|
||||
x = [3,2,4,7,3,6,9,1]
|
||||
if sleepsort(x) == sorted(x):
|
||||
print('sleep sort worked for:',x)
|
||||
else:
|
||||
print('sleep sort FAILED for:',x)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
from asyncio import run, sleep, wait
|
||||
from sys import argv
|
||||
|
||||
async def f(n):
|
||||
await sleep(n)
|
||||
print(n)
|
||||
|
||||
if __name__ == '__main__':
|
||||
run(wait(map(f, map(int, argv[1:]))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue