Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Probably Dice by MBM_1607
from collections import defaultdict
def probability(dice_number, sides, target):
prev = {0:1}
for _ in range(dice_number):
current = defaultdict(int)
for item, times in prev.items():
for i in range(1, sides + 1):
current[item+i] += times
prev = current
return round(current[target] / sides**dice_number, 4)
June 21, 2018
Comments: