Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- from tqdm import tqdm
- successes = 0
- games = 10 ** 7
- for game in tqdm(range(games)):
- counts = [0, 0, 0, 0, 0] # in order: red, blue, green, yellow, crow
- while any([i < 4 for i in counts[:-1]]) and counts[-1] != 5:
- n = randint(1, 6)
- if n == 6:
- min_idx = min(range(len(counts[:-1])), key=counts[:-1].__getitem__)
- counts[min_idx] += 1
- else:
- counts[n-1] += 1
- if counts[4] < 5:
- successes += 1
- print(successes * 100 / games)
Advertisement
Add Comment
Please, Sign In to add comment