Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Probably Dice solution in Uncategorized category for Probably Dice by capback250
# migrated from python 2.7
import itertools
from math import factorial
from functools import reduce
def probability(number, sides, target, good=0):
for roll in itertools.combinations_with_replacement(list(range(1, sides + 1)), number):
if sum(roll) == target:
good += factorial(len(roll)) * 1.0 / reduce(lambda x, y: x * y, list(map(factorial, [roll.count(x) for x in set(roll)])))
return round(good * 1.0 / float(sides ** number), 4)
March 2, 2016