Python: faster alternative for itertools.product()?

前端 未结 1 579
忘掉有多难
忘掉有多难 2021-01-14 11:46

I\'m trying to find all possible combinations of a list with length = 22 & element values = 1-9.

When I use [i for i in itertools.product(range(1, 10), rep

相关标签:
1条回答
  • 2021-01-14 12:50

    As everyone commented, try using the generator directly instead of using a list. finding all combinations is unclear. If you need to print them, do this:

    for i in itertools.product(range(1, 10), repeat=22):
        ... #Don't actually print, that may block your computer for a long time.
    

    if you need to do something on those values, then tell us what you need.

    0 讨论(0)
提交回复
热议问题