Guest User

Untitled

a guest
May 12th, 2022
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import math
  2. import random
  3.  
  4. totalBags = 0
  5. numRequiredStatIncreases = 45
  6. numTrials = 10000
  7. minBags = math.inf
  8. maxBags = 0
  9.  
  10. for x in range(numTrials):
  11. statIncreases = 0
  12. bagCount = 0
  13.  
  14. while statIncreases < numRequiredStatIncreases:
  15. totalBeans = random.randrange(1, 5) + random.randrange(1, 5) + random.randrange(1, 5)
  16. for y in range(totalBeans):
  17. n = random.randrange(0, 9)
  18. if n == 8:
  19. totalEggs = random.randrange(1, 5) + 3
  20. for z in range(totalEggs):
  21. if random.random() < 0.7:
  22. statIncreases += 1
  23. bagCount += 1
  24. totalBags += 1
  25.  
  26. if bagCount > maxBags:
  27. maxBags = bagCount
  28. if bagCount < minBags:
  29. minBags = bagCount
  30.  
  31. print("Minimum number of bags: " + str(minBags))
  32. print("Maximum number of bags: " + str(maxBags))
  33. print("Average number of bags: " + str(totalBags / numTrials))
Advertisement
Add Comment
Please, Sign In to add comment