Say we have $n$ lists with a variable number of elements that we need to pick one element from each one, and combining them to produce one resultant list with every element of the input lists. The input lists have a familiar pattern as described below. They are not random.
Say we have 2 lists like:
l1={0,1,2} (* the first and the last list is always this one. *)
l2={0,1,2} (* the last list is always equal to the first and with these elements *)
and the result we expect is
l3={{0,0},{0,1},{0,2},{1,0},{1,1},{1,2},{2,0},{2,1},{2,2}} with 9 elements.
If we have 3 lists they will be:
l1={0,1,2} (* the first and the last are always this one *)
l2={0,1,2,3} (* the second have one more element than the first *)
l3={0,1,2} (* the last one is always equal to the first *)
and the expected result would be:
l4={{0,0,0},{1,0,0},{2,0.0}.........{0,3,2},{1,3,2},{2,3,2}} (total of 36 elements.
If we have 4 lists they will be:
l1={0,1,2} (* As always this is the first *)
l2={0,1,2,3} (* The second has one digit more *)
l3={0,1,2,3} (* The third is equal to the second because n is even *)
l4={0,1,2} (* The last is always equal to the first *)
and the expected result will be like:
l5={{0,0,0,0},.........{2,3,3,2}} with 144 elements
If we have 5 lists it will be:
l1={0,1,2} (* As always the first *)
l2={0,1,2,3} (* The second one digit more *)
l3={0,1,2,3,4} (* This one has one more digit because n is odd *)
l4={0,1,2,3} (* This one is always equal to the second *)
l5={0,1,2} (* This one is always equal to the first *)
and the expected result:
l6={{0,0,0,0,0}........{2,3,4,3,2}} with 720 elements
With 6 lists it will be like:
l1={0,1,2} (* The first is always this one *)
l2={0,1,2,3} (* The second has one digit more *)
l3={0,1,2,3,4} (* The third has one digit more *)
l4={0,1,2,3,4} (* The fourth repeats because n is even *)
l5={0,1,2,3} (* The next to last is always equal to the second *)
l6={0,1,2} (* The last is always this one *)
and the expected resulting list:
l7={{0,0,0,0,0,0}.......{2,3,4,4,3,2}} with 3600 elements
The input to the program will just be $n$ since the lists will be generate with the above pattern (like a Pascal triangle).
Please feel free to get in touch if more clarification is needed.