-
-
Save romeroadrian/132a763817a092ec8d4ac2457ad82c7a to your computer and use it in GitHub Desktop.
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
import random | |
def test(samples, num_participants): | |
win_count = [0] * num_participants | |
for x in range(samples): | |
participants = list(range(0, num_participants, 1)) | |
available = num_participants | |
total = available - 1 | |
seed = random.randrange(0, 2**256) | |
# print("SAMPLE %s" % x) | |
for i in range(5): | |
winner = seed % available | |
win_count[participants[winner]] += 1 | |
participants[total - i], participants[winner] = ( | |
participants[winner], | |
participants[total - i], | |
) | |
available -= 1 | |
# print(participants, winner) | |
print(win_count) | |
test(100_000, 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment