iterator? way of generating all possible combinations?

Terry Reedy tjreedy at udel.edu
Sat May 27 18:07:53 EDT 2006


<akameswaran at gmail.com> wrote in message 
news:1148712466.299743.209350 at j73g2000cwa.googlegroups.com...
>
> Terry Reedy wrote:
>
>>
>> Are the dice identical or distinguishable (marked).  In other words, 
>> with 2
>> dice, is 1,2 the same as 2,1 or different?  Note that in most dice 
>> games,
>> such as craps, the dice are not distinguished, but probability 
>> calculations
>> must treast them as if they were to get the elementary events.
>>
> they are distinct.  This isn't necessarily about simulating a game.  So
> yes the dice are marked and I want to track those different
> possibilties.

Then your dice problem is equivalent to generating all n-digit base-d 
numbers, which is also the n-fold cartesian product of a set with itself. 
Sequential generation amounts to a 'plus-1' operation.

tjr






More information about the Python-list mailing list