Your question is Dice Scoring Probability. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Goldman Sachs Marquee simulation needs to estimate the probability that a roll of several ordinary dice produces a specified number of twos. Define a roll's score as the number of dice showing face 2.
Implement probability_of_twos(num_dice, target_twos) to return the probability that exactly target_twos of num_dice independent six-sided dice show 2.
num_dice >= 0 and 0 <= target_twos <= num_dice.0.0 and 1.0.1 through 6.def probability_of_twos(num_dice, target_twos):