Created
July 23, 2021 15:38
-
-
Save Gk0Wk/9d469dba30b7359e0b13ea5b58ba2907 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 shuffle(lst): | |
for i in range(len(lst))[::-1]: | |
rand = random.randint(0, i) | |
tmp = lst[rand] | |
lst[rand] = lst[i] | |
lst[i] = tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment