# Trying to optimize combination of combinations. Any mathematical method to make this easier?

I'm trying to make a program for my game and would like to see if there is an easier way of optimizing the teams to get maximum results.

Context: Each team is made up of 3 characters. The level of each of the characters determines how many points can be gained. I am trying to find out what combination of 9 characters into 3 teams will make for maximum points.

The equation for total team level is as follows: 1.5x + 0.85y + 0.65z - 1
where x is the highest level character, y the middle, and z the lowest level character.

So... now to the problem. Given 9 characters and 3 per team, there are 84 possible teams. Not only this but after selecting the first team, there are 20 possible teams to pick from for the second team (and then the third team is just the last three characters remaining). Is there any way to cut through this process to spit out which 3 teams will yield the most points?

Here are the character values just in case anyone wants to play around with them:
* A - 74698
* B - 52093
* C - 35562
* D - 21726
* E - 21019
* F - 20131
* G - 18161
* H - 17019
* I - 16889

So for instance, plugging A, B, and C into the team level equation, you get 179,440

If I understand your question correctly: to get the maximum you obviously want each $x$ (which has the highest factor) to be the multiplied by the highest level possible, then each $y$ to be multiplied by the next highest after that etc.

For your example they are ordered lowest to highest from $I \rightarrow A$; a team $T_n = \{v_1, v_2, v_3 \}$ (where $v_1$ is multiplied by the factor for $x$, $v_2$ multiplied by factor for $y$ etc.) we can get this: $$T_1 = \{A, -, -\}$$ $$T_2 = \{B, -, -\}$$ $$T_3 = \{C, -, -\}$$

So for just one iteration with $3$ players, this is obviously the most points we can get. If we extend it by $3$ new players, we want the next three highest values, which now are $D, E, F$, to be at the place with the next highest factor, which is $y$: $$T_1 = \{A, D, -\}$$ $$T_2 = \{B, E, -\}$$ $$T_3 = \{C, F, -\}$$

Do this for the last iteration of players, in the same manner, to get:

$$T_1 = \{A, D, G\}$$ $$T_2 = \{B, E, H\}$$ $$T_3 = \{C, F, I\}$$

So the algorithm here is quite clear, the first place in each team (for the factor $x$) is any of the three highest values. The second place in each team (for the factor $y$) is any of the next three highest values etc.

Note that the constant term $-1$ in your equation doesn't matter because it's applied the same across the board.

• it's really that simple? I mean I did this strategy just as a placeholder until I found it out. I mean it makes sense in words, but I feel like that is too simple. Any trick to what makes this work? – Ninja Octopus Oct 1 '17 at 3:55
• It works because of the simple fact that we are optimizing it each step in regards to the character values, which must mean that it's optimized overall. For the first iteration you can't get anything higher, then for the second iteration you can't get anything higher etc. If we can't get anything higher at any stage, then we can't get anything higher overall. – Sam Anderson Oct 1 '17 at 4:04
• Alright, sounds right. I marked it as the answer. I would upvote it as well but I am new and don't have enough rep. – Ninja Octopus Oct 1 '17 at 4:08