Let's say I have a row vector composed of 5 integers, where the first integer is int1 and the second is int2
int1 int2 int3 int4 int5
and i want to create a list of all possible combinations assuming each one of the integers can be between 1 and 99.
One possibility would be to write 5 nested loops:
my list = []
for i in range(1,99):
for j in range(1,99):
for k in range(1,99):
for l in range(1,99):
for m in range(1,99):
my_list.append([[m,l,k,j,i]])
This would be pretty inefficient, and we would need 9,509,900,499 iterations.
is there a more efficient way of adding all possible combinations to a list (i.e. an alternative to 5 nested loops)?
i will write the code in python but the response needs not be python specific.