I'm trying to model Yahtzee (a dice game). As a first step, I'm trying to enumerate all possible combinations of 5 dice being rolled simultaneously. I only want unique combinations (e.g. 5,5,5,4,4 is the same as 5,5,4,5,4 and so on.) is there an easy way to do this in Python or maybe C or perhaps Mathematica? Thanks in advance. Cleerline
CodePudding user response:
You can use itertools.combinations_with_replacement()
in Python:
from itertools import combinations_with_replacement
options = list(range(1, 7))
print(list(combinations_with_replacement(options, 5)))
CodePudding user response:
In Mathematica
Tuples[Range[6],5]