If you roll x total y sided dice whose faces are numbered 0 to y-1, what is the probability that the sum of the x dice is greater than or equal to z?
probability(2, 2, 1) = 0.75
possibilities are
1 + 1 = 2
1 + 0 = 1
0 + 1 = 1
0 + 0 = 0
3/4 rolls >= 1 so we return 0.75
probability(2,2,2) = 0.25 since only 1/4 rolls equals to 2
Can someone provide an optimized python solution for it?
def probability(x: int, y: int, z: int):
pass