Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- n = 3
- number = 2
- amount = 2
- n_simulations = 100000
- success = 0
- def check(vector, num, amount):
- count = 0
- for i in range(len(vector)):
- if vector[i] is num:
- count += 1
- if count >= amount:
- return 1
- return 0
- for i in range(n_simulations):
- vect = [0] * n
- for j in range(n):
- vect[j] = random.randint(1, 6)
- if check(vect, number, amount) is 1:
- success += 1
- print('Result: ' + str(success / n_simulations * 100) + '%')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement