AI have multiple arrays I'm putting into the itertools.product()
.
Array lengths:
A - 108
B - 126
C - 5
D - 8
E -8
It takes me a good few minutes to process the arrays and I was wondering if there's another way to speed it up.
total = 0
maxPoints = 0
for combination in itertools.product(A, B, C, D, E):
currentTotal = int(combination[0][1]) + int(combination[1][0][1]) + int(combination[1][1][1]) + int(combination[1][2][1]) +int(combination[2][0][1]) + int(combination[2][1][1]) + int(combination[2][2][1]) + int(combination[1][0][1]) + int(combination[1][1][1])
if currentTotal < 50000:
pointTotal = float(combination[0][2]) + float(combination[1][0][2]) + float(combination[1][1][2]) + float(combination[1][2][2]) + float(combination[2][0][2]) + float(combination[2][1][2]) + float(combination[2][2][2]) + float(combination[1][0][2]) + float(combination[1][1][2])
if currentTotal >= total:
if pointTotal > maxPoints:
total = currentTotal
maxPoints = currentPoints
D
orE
lists, so you can probably leave them out of yourproduct
call to reduce the amount of work by a 64 times.