Skip to content

Instantly share code, notes, and snippets.

@neila
Created February 12, 2019 13:53
Show Gist options
  • Save neila/f878c2bf6cbaa1483c6395e14e84f709 to your computer and use it in GitHub Desktop.
Save neila/f878c2bf6cbaa1483c6395e14e84f709 to your computer and use it in GitHub Desktop.
CS110 5.1 Preclass
import random
def check(list):
for i in range(len(list) - 1):
if list[i] > list[i + 1]:
return False
return True
def badsort(list):
while not check(list):
random.shuffle(list)
return list
list = [int(100*random.random()) for i in range(10)]
badsort(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment