Skip to content

Instantly share code, notes, and snippets.

@prescod
Created April 7, 2024 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prescod/2737abfff6653d689dd79c7d0f02bf35 to your computer and use it in GitHub Desktop.
Save prescod/2737abfff6653d689dd79c7d0f02bf35 to your computer and use it in GitHub Desktop.
Massive shuffles
from snowfakery.utils.randomized_range import random_range
countries = ["Canada", "Mexico", "United States", "Japan", "China"] * 1_000_000
def shuffle_sequence(sequence):
indexes = random_range(0, len(sequence))
for index in indexes:
yield sequence[index]
shuffles = [shuffle_sequence(countries) for _ in range(1_000_000)]
print(next(shuffles[0]))
print(next(shuffles[1]))
print(next(shuffles[0]))
print(next(shuffles[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment