Created
April 6, 2018 13:34
-
-
Save au5ton/d7d3386ba261f4bdd7350cc341604dea to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/local/bin/python3 | |
from random import randint | |
print('hello') | |
some_array = [1,9,4,2] | |
lll = [1,2,3,4] | |
# bogo sort | |
def shakey(ray): | |
temp = list(range(0,len(ray))) | |
done = [] | |
prog = 0 | |
while len(done) < len(ray): | |
# get random index and log index | |
r = randint(0,len(ray)-1) | |
if r in done: | |
continue | |
else: | |
temp[prog] = ray[r] | |
prog += 1 | |
done.append(r) | |
return temp | |
def is_sorted(ray): | |
for i in range(0,len(ray)): | |
if i > 0: | |
if ray[i - 1] > ray[i]: | |
return False # its gotta be ascending | |
return True | |
def boogoo(ray): | |
poop = shakey(ray) | |
if is_sorted(ray): | |
return ray | |
elif is_sorted(poop): | |
return poop | |
else: | |
return boogoo(poop) | |
print(is_sorted(some_array)) | |
print(is_sorted(lll)) | |
print(boogoo(some_array)) | |
print(boogoo(lll)) | |
#def muh_sort(ray): | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment