Logic to generate a pattern

**Hi All,**

*The requirement is something like this.......*

Example:

Sum = 7

Availability Matrix = [5, 4, 6, 1]

Required: I need all set of possible unique combinations that sums to 7.

Few example combinations: [5, 2, 0, 0], [4, 3, 0, 0], [3, 4, 0, 0]

I also have a few questions...

? Can we tell the number of unique number of solutions that can be formed well in advance.

? There are many solutions to this problem which one would be the good in terms of performance imagine when the availabilty matrix is huge

Early help would be appreciated.

**Thanks,**

V :)