Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,10 +1,15 @@
|
|||
#!/bin/python3
|
||||
import random
|
||||
from itertools import zip_longest
|
||||
|
||||
# This is wrong, it works only on specific examples
|
||||
def beadsort(l):
|
||||
return list(map(sum, zip_longest(*[[1] * e for e in l], fillvalue=0)))
|
||||
def beadsort(l: list[int]) -> list[int]:
|
||||
transposed = list(map(sum, zip_longest(*[[1] * e for e in l], fillvalue=0)))
|
||||
return [sum(n > i for n in transposed) for i in range(len(l))]
|
||||
|
||||
def test_beadsort() -> None:
|
||||
for _ in range(100):
|
||||
ints = [random.randint(0, 50) for _ in range(random.randint(0, 10))]
|
||||
assert beadsort(ints) == sorted(ints, reverse=True)
|
||||
|
||||
# Demonstration code:
|
||||
print(beadsort([5,3,1,7,4,1,1]))
|
||||
if __name__ == "__main__":
|
||||
test_beadsort()
|
||||
print(beadsort([5, 3, 1, 7, 4, 1, 1]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue