The players A and B are playing a game with dice. Player A throws numDiceA of his dice, while player B throws numDiceB of his dice. Each of them adds the pips on his dice, and the player with the higher sum wins the game (if both get the same sum, it is a draw). The variables sidesA and sidesB have 6 elements each, and describe how many pips are on each side of the dice of player A and player B respectively. Each die has exactly 1/6 probability for each possible outcome.
Given the number of dice numDiceA and numDiceB each player throws, and their configurations sidesA and sidesB, compute the probability that player A wins the game.
|Parameters:||int, int, int, int|
|Method signature:||double winProbability(int numDiceA, int sidesA, int numDiceB, int sidesB)|
|(be sure your method is public)|
|-||Your return value must have an absolute or relative error less than 1e-9.|
|-||numDiceA and numDiceB are between 1 and 200, inclusive.|
|-||sidesA and sidesB each contain exactly 6 elements.|
|-||Each element of sidesA and sidesB is between 1 and 100, inclusive.|
|This is the simple case, where each player throws a normal die once. Of the 36 possible outcomes, 6 are a tie (both players throw the same number), 15 a win for A and 15 a win for B. So player A wins 15/36 of the games.|
|Note that dice can have several equal sides. Here, player B gets a sum of 3. Player A can beat that only if he gets a 2 on both his throws, giving him a 1/4 chance of winning.|
|Note that sidesA and sidesB need not be sorted.|
|There is a 6-100 probability of player A winning (all his throws are 2).|