There is a classic Knapsack problem. My version of this problem is a little different.
Given set of items, each with a mass, determine the number of combinations to pack items so that the total weight is less than or equal to a given limit.
For example, there is 5 items with mass: 1, 1, 3, 4, 5
. There is a bug with limit = 7
. There are the following combinations:
1 + 3
1 + 4
1 + 5
1 + 1 + 3
1 + 1 + 4
1 + 1 + 5
3
3 + 4
4
5
Is there a way to count number of combinations without brute?