# Finding all possible sums given 2 lists, matched one to one

• B
• mishima
In summary, the conversation is about finding all the different ways to add elements from two lists of numbers, A and B. The number of permutations is the number of ways to pick an entry from A and an entry from B, which is n!. However, this number is reduced by the fact that many of the sums are the same. The speaker is trying to make a spreadsheet to calculate all the possibilities.
mishima
Hi, its been a while since I have thought about this type of math, and I can't really remember how to do this or what its even called. I have two lists of numbers:

A: 8, 8, 9, 10, 7, 8
B: 6, 5, 4, 3, 3, 3

I want to find all the different ways I can add elements from A with elements of B. For instance, just adding them vertically as they are here I could get one combination as:

C: 14, 13, 13, 13, 10, 11

When an element from a list is used, its gone. For example, if I added 10 from A and 6 from B, I can't use 6 again (or vice versa). Can anyone nudge me in the right direction?

The number of ways you can pick an entry in the A list to be added to an entry in the B list is the number of permutations, which is n! This number will be reduced by the fact that many of the sums are the same, which feels like a hard problem to handle.

Ok, so 720 possibilities. I could've sworn there was a way to account for repeats but like I said it has been a while since I have touched on this style of thinking. Ultimately I am just trying to make a spreadsheet to crunch it all out.

## 1. What is the purpose of finding all possible sums given 2 lists, matched one to one?

The purpose of this task is to determine all the possible combinations of sum that can be obtained by adding one element from each list. This can be useful in various mathematical and scientific applications, such as optimization problems, data analysis, and probability calculations.

## 2. How do you match the elements from the two lists?

The elements from the two lists are matched one to one based on their position in the list. For example, the first element from the first list will be matched with the first element from the second list, the second element from the first list with the second element from the second list, and so on.

## 3. Can the two lists have different lengths?

Yes, the two lists can have different lengths. In this case, the matching process will stop when the shorter list runs out of elements to be matched. The remaining elements from the longer list will not be included in the sum calculation.

## 4. What is the time complexity of finding all possible sums given 2 lists, matched one to one?

The time complexity of this task depends on the length of the lists. If the two lists have lengths n and m, the time complexity would be O(n*m) as each element from the first list needs to be matched with each element from the second list.

## 5. Can this task be generalized to more than two lists?

Yes, this task can be generalized to more than two lists. The same matching process can be applied, but the time complexity would increase as the number of lists increases. The time complexity would be O(n^k), where n is the length of each list and k is the number of lists.

• General Math
Replies
24
Views
2K
• General Math
Replies
2
Views
1K
• General Math
Replies
68
Views
9K
• General Math
Replies
4
Views
2K
• General Math
Replies
5
Views
949
• General Math
Replies
7
Views
1K
• Nuclear Engineering
Replies
7
Views
2K
• General Math
Replies
2
Views
1K
• Set Theory, Logic, Probability, Statistics
Replies
12
Views
1K
• General Math
Replies
1
Views
753