Python: how do I create a list of combinations from a series of ranges of
numbers
For a list of numerical values of n length, e. g. [1, 3, 1, 2, ...], I
would like to create a list of the lists of all possible combinations of
values from range[x]. The output might look something like this:
for list[1, 3, 2] return all possible lists of range[x] values:
# the sequence of the list is unimportant
[
[0,0,0],[1,0,0],[0,1,0],[0,2,0],[0,3,0],[0,0,1],[0,0,2],[1,1,0],
[1,2,0],[1,3,0],[1,0,1],[1,0,2],[0,1,1],[0,2,1],[0,3,1],[0,1,2],
[0,2,2],[0,3,2],[1,1,1],[1,2,1],[1,3,1],[1,1,2],[1,2,2],[1,3,2]
]
No comments:
Post a Comment