qzazwxsx

Untitled

Jan 3rd, 2024
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. from random import randint
  2. from tqdm import tqdm
  3.  
  4. successes = 0
  5. games = 10 ** 7
  6. for game in tqdm(range(games)):
  7.     counts = [0, 0, 0, 0, 0]  # in order: red, blue, green, yellow, crow
  8.  
  9.     while any([i < 4 for i in counts[:-1]]) and counts[-1] != 5:
  10.         n = randint(1, 6)
  11.         if n == 6:
  12.             min_idx = min(range(len(counts[:-1])), key=counts[:-1].__getitem__)
  13.             counts[min_idx] += 1
  14.         else:
  15.             counts[n-1] += 1
  16.  
  17.     if counts[4] < 5:
  18.         successes += 1
  19.  
  20.  
  21. print(successes * 100 / games)
  22.  
Advertisement
Add Comment
Please, Sign In to add comment