I'm trying to do a bruteforce string generator in Python and itertools.combinations_with_replacement
seemed to do just the trick.
gen = itertools.combinations_with_replacement('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',12)
for combination in gen:
check(''.join(combination))
Say the user runs the program for some hours and reaches up to string aaaeabdouzIU
.
Is there any way given a string where they left off to start making combinations from that point onwards?
So if I pass the string 'acc
' it should start trying 'acd
','ace
',...
itertools.combinations_with_replacement
does not provide this natively, is there any way someone could achive this?
Taking the original code from the itertools man page copy the code for the combinations_with_replacement code but replace line 7 with new indices starting from your entered word.
And then run the rest of the code from the man page.
EDIT: For a complete running function: