When rolling 1 0 dice with 2 0 faces each (numbered 1 to 2 0 ), how many ways are there of rolling a total sum of 1 5 ?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
I did the same way....
Consider all arrangements of 1 5 − 1 0 = 5 X s and 1 0 − 1 = 9 I s, such as I I X I I I I X I I X X I X . We can bring these into a 1 to 1 correspondence to the possible ways of throwing our 1 0 dice. Each I marks the beginning of the next dice and we count the amount of X s in between the I s and add 1 for the amount rolled. The example is thus put into a correspondence with ( 1 , 1 , 2 , 1 , 1 , 1 , 2 , 1 , 3 , 2 ) . The amount of ways to put 9 I s in between (or around) the 5 X s is ( 9 5 + 9 ) = 2 0 0 2 .
Therefore, in general, for n dice with each p faces and a total sum of k ≤ p , we have a total amount of ( n − 1 k − 1 ) possible combinations.
1 5 = 9 ( 1 ) + 1 ( 6 ) = 8 ( 1 ) + 1 ( 2 ) + 1 ( 5 ) = 8 ( 1 ) + 1 ( 3 ) + 1 ( 4 ) = 7 ( 1 ) + 2 ( 2 ) + 1 ( 4 ) = 7 ( 1 ) + 1 ( 2 ) + 2 ( 3 ) = 6 ( 1 ) + 3 ( 2 ) + 1 ( 3 ) = 5 ( 1 ) + 5 ( 2 )
The number of ways to roll a total of 1 5 is: 1 0 ! ( 9 ! 1 + 8 ! 1 + 8 ! 1 + 7 ! 2 ! 1 + 7 ! 2 ! 1 + 6 ! 3 ! 1 + 5 ! 5 ! 1 ) = 2 0 0 2
I'm not proud of the code I wrote for this but here it is
Only thing I can say is with rolling 10 dice, minimum of 1 per dice, that means youre never going to want any number over 6, so we can save ourselves some time on loops by not counting to 20 and by using the 'continue' keyword any time our sum exceeds 15.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
I understand the code but man so many for loops my eyes are hurting! Good job though
x1+x2+x3+...+x10=15 : xi>=1 * *
yi=xi-1 then : yi>=0 * *
y1+y2+y3+...+y10=5 * *
n=C(10+5-1,10-1)=C(14,9)=2002
There is a formula to find how many ways are there to get sum p when rolling n dice each having s faces:
∑ k = 0 k m a x ( − 1 ) k ( k n ) ( p − s × k − n p − s × k − 1 )
where k m a x = floor of s p − n
In this case its ( 0 1 0 ) ( 1 5 − 1 0 1 5 − 1 ) = ( 5 1 4 ) = 2 0 0 2 .
a 1 + a 2 + a 3 + . . . + a 1 0 = 1 5 ( 1 ≤ a i )
Let a i − 1 = b i and then,
b 1 + b 2 + b 3 + . . . + b 1 0 = 5 with ( 0 ≤ b i )
So, we get 10H5 = 14C5 = 2002
Problem Loading...
Note Loading...
Set Loading...
We want the coefficient of x 1 5 in ( x + x 2 + x 3 + ⋯ + x 2 0 ) 1 0 = x 1 0 ( 1 + x + x 2 + ⋯ + x 1 9 ) 1 0 = x 1 0 ( 1 − x 1 − x 2 0 ) 1 0 which is therefore the coefficient of x 5 in ( 1 − x ) − 1 0 , which is ( 9 1 4 ) = 2 0 0 2 .