I'm trying to find a way to write a Python script wherein I can produce a file containing a list of entries (strings) which are permutations of specific inputs. To elaborate:
Imagine you have 9 digits in a string. But the only possible value in each digit is within the range of 0123456789. So I want all permutations of 0123456789 over 9 digits...and a string list of all those permutations (i.e. 1,000,000,000 possible permutations).
Simple enough to use itertools.permutations right? No. According to the official documentation:
def permutations(iterable, r=None):
# permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
If you look closely at the results there are no repeats...so no instances of say AA or BB. That means if I try to run all permutations of 0123456789 over 9 digits I won't get the combinations "11111111" or "111222333". I.e. I won't get my 1 billion results, right?
Am I misunderstanding the itertools module here? What can I do to create a file with a string list of all possible permutations of '0123456789' over 9 digits?
'{:09}'.format(counter)' wherecounter` is some number between0and999999999. (What you're looking for is the Cartesian product, but that seems overkill here.) - Rufflewind