Skip to content

Instantly share code, notes, and snippets.

@romeroadrian
Created February 8, 2024 18:49
Show Gist options
  • Save romeroadrian/132a763817a092ec8d4ac2457ad82c7a to your computer and use it in GitHub Desktop.
Save romeroadrian/132a763817a092ec8d4ac2457ad82c7a to your computer and use it in GitHub Desktop.
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