I'm writing a program that looks at every possible sum of a dice roll given X die with X sides. For example, with 2 dice with 6 sides, I need a list of elements giving all possible unique sums achievable with these dice (something like 2,3,3,4,4,4,4 etc..). I can do this for smaller sets (2 dice 6 sides is fine), but larger sets like 10 dice and 10 sides I run into mem issues. I think I've found the solution, but am having issues with implementation.
I have a list of lists containing all rolls of each individual dice. For this example, we have 3 dice that can roll a 1, 2, or 3.
dice = [[1,2,3], [1,2,3], [1,2,3]]
outcomes = list(map(sum, zip(itertools.product(*dice))))
I think the pieces are there, but I keep getting TypeError: unsupported operand type(s) for +: 'int' and 'tuple'. I've tried moving the pieces around in numerous ways but nothing has clicked. What am I doing wrong? Ultimately I'm given a number, say 6, that I have to find out what the odds are I'll roll that number. So my goal with the above code is to get a generator that I get the total times X number appeared and figure out the probability of rolling X number. I've gotten a list for smaller inputs, but like I said, once I get larger inputs the list gets too big