Comparison with False - something I don't understand
Paul Rubin
no.email at nospam.invalid
Sun Dec 5 00:37:22 EST 2010
Tim Harig <usernet at 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
More information about the Python-list
mailing list