Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-340

Maximum of Two Dice Distribution

Problem

For two independent fair d-sided dice, P(max = k) = (2k - 1) / d^2.

Given d, return the list of probabilities for k = 1..d.

Hint

Count pairs with both dice at most k minus both at most k - 1.

Test cases

case 1
in: [2]
expected: [0.25,0.75]
case 2
in: [4]
expected: [0.0625,0.1875,0.3125,0.4375]
case 3
in: [6]
expected: [0.027777777777777776,0.08333333333333333,0.1388888888888889,0.19444444444444445,0.25,0.3055555555555556]
Starter codePython
def maximum_of_two_dice_distribution(d):
    # Your code here
    pass

3 test cases · run your code against them in the editor