Project:
alcari
Python,
pasted
on Aug 5:
|
#Bogosort! can't use the other testcases because O(21!) is an unreasonable runtime.
globals().update(bogosort=lambda l:(l,reduce(lambda x,y:__import__('random').shuffle(l),__import__('itertools').takewhile(lambda b:not reduce(lambda x,y:x and y,[l[n]<=l[n+1]for n in range(len(l)-1)]),__import__('itertools').repeat(0))))[0])
print(bogosort([1, 5, 3, 2, 7, 2]))
|
Output:
|