[ create a new paste ] login | about

Project: alcari
Link: http://alcari.codepad.org/rgSnxACi    [ raw code | output | fork ]

Python, pasted on Aug 5:
1
2
3
4
#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:
1
[1, 2, 2, 3, 5, 7]


Create a new paste based on this one


Comments: