0

I have been struggling to create an algorithm, for a problem where we get an array of n coins with their max values. A coin in the array can have a value between 0 and this max value. We want to determine ALL permutations of possible order of coins given a sum target x. For example the array {2,2} with x = 3 has 2 permutations: 1+2, 2+1. I know this problem is related to coin change/knapsack/ sub-set problem. But haven't been able to make an algorithm based on these known solutions. I've tried doing dynamic programing, but all I could conclude that the array of possible targets is some kind of binomial. For example the array of coins with max values {3,3,3}, (n=3) can be any sum value from 0-9, where the number of permutations are:

sum value : permutations

0:1

1:3

2:6

3:10

4:12

5:12

6:10

7:6

8:3

9:1

From doing this I could atleast conclude that the the number of permutations for value 0 and max sum is always 1 and for value 1 and value max-1 is always n (length of the array). But I could not for the life of me figure out a recursion for the rest of the numbers, which is why I need help. Thanks in advance.

0 Answers0