Tim Harig <user...@ilthio.net> writes: > A friend was trying to derive a mathematical formula for determining > the possibly distribution of results from rolling arbitrariy numbers > of m n-sided dice
http://en.wikipedia.org/wiki/Multinomial_distribution > To generate a listing of all (non-uniq) possible roles, I would call > the first dices increment method read and read the dice faces into a > log until the first dice threw an exception that it could not be > further incremented. Then I would call reset() on the first dice and > increment the second and so on much like the odometer of a car. from itertools import product m, n = 5, 2 for roll in product(*(xrange(1,m+1) for i in xrange(n))): print roll -- http://mail.python.org/mailman/listinfo/python-list