If I have a list of $38$ numbers (from $1$ to $40$, excluding numbers $3$ and $12$), how can I find all the combinations of $4$ different numbers from that list that will give me a total of $68$ when they are added together?
Is there a mathematical formula that can be used here?
Places I have looked for an answer:
Finding all combinations that sum to a target
Finding all combinations of four numbers that equal a sum in R
I feel I'm close to answer with the above link but I am having some difficulties understanding the process to tweak the answers mentioned therein to fit my problem.
Additional note: The four numbers must be unique in each combination. That is, a number cannot be used twice or more in the same combination.
Best Answer
Once you remove the two numbers $3$ and $12$, the chance of finding any 'nice math formula(s)' to solve the problem most likely plummet.
You said you were attempting to tweak some $\text{R programming language}$ code. But consider this brute force method (I am learning Python):
OUTPUT: