codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#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]))
Private
[
?
]
Run code
Submit