-4

I have following patterns of list available to play with.

Values : 
20,
25,
30,
35,
40,
45,
50,
55,
60,
70,
75,
80,
90,
100,
120

Next I have another set of values like these:

200,225,300,50,45,75, 15, 72

Now for the value 200, I want the algorithm that to fetch possible values that might result it's sum in to a

LIST [100+100], [100+50+50], [50+50+50+50], [120+80]..

Similarly for 225:

[25+120+80], [25+100+100], [100+45+80]..

and put it on another list.

exceptionally for 15,

it can fetch [20]

for 72 it can fetch [70], [75]

Can any body help me to derive this logic?

Bali C
  • 30,582
  • 35
  • 123
  • 152
user936597
  • 191
  • 2
  • 9

1 Answers1

1

Here's something to get you started:

var zs = ys.Select(y => Tuple.Create(y, xs.Subsets().Where(s => s.Sum() == y)));
dtb
  • 213,145
  • 36
  • 401
  • 431