[Jprogramming] Dice rolls

David Vaughan purpleblues13 at googlemail.com
Tue Oct 11 18:48:04 HKT 2011


I'm trying to work out the probability of any number being rolled by an n-sided die with r rolls. For example, a 6-sided die with 2 rolls, 7 has probability 6/36=1/6.

I was hoping to achieve this by having a list of the possible rolls and then trying every possible sum down through each row/column.

For example, a 2-sided die with 3 rolls, I'd want to get something along these lines:

1 2 1 1 2 2 1 2
1 1 2 1 2 1 2 2
1 1 1 2 1 2 2 2

.. then sum the columns to get:

3 4 4 4 5 5 5 6

Any help? Thanks.


More information about the Programming mailing list