mirror of
https://github.com/codex-storage/bittorrent-benchmarks.git
synced 2025-02-10 18:16:30 +00:00
another fix to shuffle
This commit is contained in:
parent
586932f67e
commit
ccfc7614a7
@ -63,7 +63,7 @@ def sample(n: int) -> Iterator[int]:
|
|||||||
"""Samples without replacement using a basic Fisher-Yates shuffle."""
|
"""Samples without replacement using a basic Fisher-Yates shuffle."""
|
||||||
p = list(range(0, n))
|
p = list(range(0, n))
|
||||||
for i in range(n - 1):
|
for i in range(n - 1):
|
||||||
j = i + random.randint(0, n - i)
|
j = random.randint(i, n - 1)
|
||||||
tmp = p[j]
|
tmp = p[j]
|
||||||
p[j] = p[i]
|
p[j] = p[i]
|
||||||
p[i] = tmp
|
p[i] = tmp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user