I want to count the integer partitions of n with k partition elements. The possible partition elements are defined through a given vector v with distinct elements. Partition elements can be choosen more than once. How Can i do this? Optimal without iterating through all integer partitions of n.
Example:
n := 10
k := 3
v := 1,2,6,7,8
=> 3
One way is to have the recurrence consider each element in order.
Unmemoised JavaScript: