Skip to content

Instantly share code, notes, and snippets.

@WangYihang
Last active July 30, 2019 03:11
Show Gist options
  • Save WangYihang/c1391f0899bfaefe6e1c346bc20b5c12 to your computer and use it in GitHub Desktop.
Save WangYihang/c1391f0899bfaefe6e1c346bc20b5c12 to your computer and use it in GitHub Desktop.
Array shuffler
#!/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