Expected Value of Modified Dice
Problem statement
Ten fair six-faced dice are supplied by their complete integer face lists. Die i is rolled rollCounts[i] times, and the counts sum to exactly 100. The game pays the sum of all rolls and charges a fixed entry fee of 350.
Return eleven reduced fractions in numerator/denominator form. The first ten values are the expected face value of each die in index order. The final value is the expected net payout after subtracting the entry fee. A zero value is returned as 0/1, and denominators are always positive.
Function
modifiedDiceExpectations(dice: int[][], rollCounts: int[]) → String[]Examples
Example 1
dice = [[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6]]rollCounts = [10,10,10,10,10,10,10,10,10,10]return = ["7/2","7/2","7/2","7/2","7/2","7/2","7/2","7/2","7/2","7/2","0/1"]Every die has expectation 3.5, so one hundred rolls have expected payout 350 and net expectation zero.
Example 2
dice = [[1,1,3,4,5,6],[1,2,2,4,5,6],[1,2,3,3,5,6],[1,2,3,4,4,6],[1,2,3,4,5,5],[2,2,3,4,5,6],[1,3,3,4,5,6],[1,2,4,4,5,6],[1,2,3,5,5,6],[1,2,3,4,6,6]]rollCounts = [100,0,0,0,0,0,0,0,0,0]return = ["10/3","10/3","10/3","10/3","10/3","11/3","11/3","11/3","11/3","11/3","-50/3"]Only the first modified die is rolled, giving expected payout 1000/3 and net expectation -50/3.
Constraints
dice.length == rollCounts.length == 10.- Every die has exactly six integer face values.
0 <= rollCounts[i] <= 100and their sum is100.- Every face value is between
-10^6and10^6.