Last active
January 4, 2019 10:47
-
-
Save Lazzlo2096/f81c9560a7e066eae33d80b9da90b8a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://ru.wikipedia.org/wiki/Bogosort | |
import random | |
#random.sample(a, b) # https://docs.python.org/3.7/library/random.html#random.sample | |
def isSorted(list): | |
for i in range(len(list)-1): | |
if not(list[i] < list[i+1]): | |
return False | |
return True | |
#list2 = [1,2,4,5] | |
#print(isSorted(list2)) # True | |
list = [1,100,64,13,55,8,66,44,22] | |
while not isSorted(list): | |
list = random.sample(list, len(list)) | |
print(list) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment