fork download
  1. from random import randrange
  2.  
  3. def fy_iter(n):
  4. deck = list(range(n))
  5. for i in range(n):
  6. k = randrange(i,n)
  7. deck[i], deck[k] = deck[k], deck[i]
  8. yield deck[i]
  9.  
  10. for x in fy_iter (20): print(x)
  11.  
Success #stdin #stdout 0.02s 36944KB
stdin
Standard input is empty
stdout
3
6
15
11
9
19
10
1
4
7
0
8
12
16
13
5
18
14
2
17