about summary refs log tree commit diff
path: root/users/wpcarro/scratch/facebook/shuffle.py
blob: 21a6a96c6072680feca035b6abe9d63ffe69f6a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from random import randint

def get_random(i, j):
    return randint(i, j)

def shuffle(xs):
    for i in range(len(xs)):
        j = get_random(i, len(xs) - 1)
        xs[i], xs[j] = xs[j], xs[i]

xs = list(range(1, 53))
print(xs)
assert len(set(xs)) == 52
shuffle(xs)
assert len(set(xs)) == 52
print(xs)
print("Success!")