Dice Throw Problem (Dynamic Programming)

There are d dice each having f faces. We need to find the number of ways in which we can get sum s from the faces when the dice are rolled.

Let us first understand the problem with an example-

If there are 2 dice with 2 faces, then to get the sum as 3, there can be 2 ways-1st die will have the value 1 and 2nd will have 2.1st die will be faced with 2 and 2nd with 1.

Hence, for f=2, d=2, s=3, the answer will be 2.

Approach -

1) BRUTE FORCE -
The naive approach is to find all the possible com...

 •  0 comments  •  flag
Share on Twitter
Published on January 30, 2021 07:43
No comments have been added yet.