Below is a simplified version of my question, the background summary underneath provides a greater context.
Problem:
Create a function that lists all elements from a list that sum to a given value in an array.
Given:
List<int> list = new List<int>() { 1, 2, 3, 4, 5, 9 };
If the value provided was 10, then the function should return an array with lists 1, 2, 3, 4, and 1, 4, 5, and 2, 3, 5, and 1, 9.
Background:
I'm trying to digitize an old card game called Pastra (or Bastra) and the objective is to collect cards from the board. You can only collect cards that match the number value of a card or any numbered cards that sum to the played card's number. Ace's are 1s.
I already have the code for collecting the card that has an equal value.
What I need is to create an array of values from the original list with the elements that sum to the given value.
I'll need to know which list is larger as well as to know which list contains which cards so that the same card is not collected more than once. (Note: This is out of scope for this question. I want to discover that myself, however it's here to provide context as to why I need the information this way).
Example:
Same as above, if the board has an Ace, 2, 3, 4, 5, and 9, if I were to play a 10, I could collect Ace, 2, 3, 4, or Ace, 4, 5, or 2, 3, 5, or Ace, 9.
Thank you for your help, it's greatly appreciated.