Created
April 7, 2024 17:55
-
-
Save prescod/2737abfff6653d689dd79c7d0f02bf35 to your computer and use it in GitHub Desktop.
Massive shuffles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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