List Calculations: Automatically generate all possible list additions (combinatorics)

Hey guys! I have the following thing to do:
I have five lists.
E.g.:
l1 = [1,2,3,4,5,6,7,8,9,10]
l2 = [1,2,3,4,5,6,7,8,9,10]
l3 = [1,2,3,4,5,6,7,8,9,10]
l4 = [1,2,3,4,5,6,7,8,9,10]
l5 = [1,2,3,4,5,6,7,8,9,10]

I need all possible list addtions of those lists, in which the values at the respective index will be added. In total there should be 31 solution lists possible: 5 singular, 10 doubles, 10 triples, 4 quadruples, 1 quintuple.

An example for a double list would in this case be: l1_l2 = [2,4,6,8,10,12,14,16,18,20]
(Doing all of this manually would take forever I guess.)

After that I want to be able to use a list by setting an integer, say I = 10 automatically grabs list 10 out of my solutions. In the end, depending on the integer value as an input (from 1-31). However, I want to be able to access each list individually, without having to create 31 list names that I fill manually by additions and call manually. I only have the integer option to call a list and work with it.

Is that possible?

I would be very happy if you could help me with this. I think there must be a much faster and easier solution instead of writing each list individually. Also, I might add a list at the beginning, giving me even more possible combination results.

Looking forward to your help!!!

Best
Maximilian

If this is for a school project or test we cannot offer help as it goes against the guidelines.

My best suggestion would be to write out the logic on how you think it should work, do some research.

Its neither. Rather an individual project/experiment I am doing on my own.
Ok

You could try some nested loops or a recursive function to generate the appropriate lists of sums.

1 Like

I found a way! I had to use the itertools to automatically calculate all solutions and included this in a list.append loop to store all results in a very long list with sublists. Now I can access each sublist just with one integer!
Thanks for the loop idea!