Last active
July 30, 2019 03:11
-
-
Save WangYihang/c1391f0899bfaefe6e1c346bc20b5c12 to your computer and use it in GitHub Desktop.
Array shuffler
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/bin/env python | |
# encoding: utf-8 | |
import random | |
def shuffle(data): | |
for i in range(len(data) - 1, 0, -1): | |
t = random.randint(0, i - 1) | |
data[i], data[t] = data[t], data[i] | |
return data | |
print(shuffle([i for i in range(0x10)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment