Function with varying number of For Loops (python)
I'm not clear why you can't use the product of the bounds and do
for x in range(y exp n)
where n is the # of loops.... You say y exp n will be huge, but I'm sure python can handle it.
However, that being said, what about some sort of recursive algorithm?
def loop_rec(y, n):
if n >= 1:
for x in range(y):
loop_rec(y, n - 1)
else:
whatever()
This problem can be solved by recursion. I am just writing an algorithm here, since I believe this can be a general problem.
function Recurse (y, number)
if (number > 1)
Recurse ( y, number - 1 )
else
for x in range (y)
whatever()
Recursion will be your best bet. Consider what it should do in the base case and in the recursive case.
Code left out, as per request.