about summary refs log blame commit diff
path: root/users/wpcarro/scratch/facebook/hard/fisher-yates.py
blob: 200d1613ddcbeb6a19a0bf1b6c77b35a3897fba2 (plain) (tree)
1
2
3
4
5
6
7






                                    
import random

def shuffle(xs):
    n = len(xs)
    for i in range(n):
        j = random.randint(i, n - 1)
        xs[i], xs[j] = xs[j], xs[i]