Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import random
- totalBags = 0
- numRequiredStatIncreases = 45
- numTrials = 10000
- minBags = math.inf
- maxBags = 0
- for x in range(numTrials):
- statIncreases = 0
- bagCount = 0
- while statIncreases < numRequiredStatIncreases:
- totalBeans = random.randrange(1, 5) + random.randrange(1, 5) + random.randrange(1, 5)
- for y in range(totalBeans):
- n = random.randrange(0, 9)
- if n == 8:
- totalEggs = random.randrange(1, 5) + 3
- for z in range(totalEggs):
- if random.random() < 0.7:
- statIncreases += 1
- bagCount += 1
- totalBags += 1
- if bagCount > maxBags:
- maxBags = bagCount
- if bagCount < minBags:
- minBags = bagCount
- print("Minimum number of bags: " + str(minBags))
- print("Maximum number of bags: " + str(maxBags))
- print("Average number of bags: " + str(totalBags / numTrials))
Advertisement
Add Comment
Please, Sign In to add comment