Problem solved!
For those who get the same error, here is the answer:
the problem in the line that causes this error is the transformation from a generator (a piece of code that yields one result at a time until it finishes running) that is very memory-efficient, to a list by using [] around
by converting it into a list you make the generator output all its values into a list, which cannot contain more than 536,870,912 items on 32bit machines. when the list gets bigger than that you get the memory error.
solution: remove the []
For those who get the same error, here is the answer:
the problem in the line that causes this error is the transformation from a generator (a piece of code that yields one result at a time until it finishes running) that is very memory-efficient, to a list by using [] around
functools.reduce(operator.add, p) for p in itertools.product(chars, repeat=n).
by converting it into a list you make the generator output all its values into a list, which cannot contain more than 536,870,912 items on 32bit machines. when the list gets bigger than that you get the memory error.
solution: remove the []