Created
April 22, 2013 13:08
-
-
Save Gnitset/5434766 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
def is_sorted(a): | |
for (c,d) in enumerate(a): | |
if c!=d: | |
return False | |
return True | |
def shuffle(a): | |
a_len=len(a) | |
map(a.extend,zip(a[:a_len/2],a[a_len/2:a_len])) | |
del a[:a_len] | |
def shuffle2(a): | |
a_len=len(a) | |
map(a.extend,zip(a[a_len/2:a_len],a[:a_len/2])) | |
del a[:a_len] | |
def try_deck(size): | |
a=range(size) | |
shuffle(a) | |
i=1 | |
while not is_sorted(a): | |
shuffle(a) | |
i+=1 | |
return i | |
def try_deck2(size): | |
a=range(size) | |
shuffle2(a) | |
i=1 | |
while not is_sorted(a): | |
shuffle2(a) | |
i+=1 | |
return i | |
for Z in range(2,1025,2): | |
print Z,try_deck(Z),try_deck2(Z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment