'Need help solving boins change problem with constriants

I have a coins change problems but with 1 constraint: for each sum k> 0 we have exactly 2 coins with values of 2^k. example: if we are given the sum 3 we would get an array of coins {1, 1 , 2, 2, 4, 4} and if the sum is 5 we would get { 1, 1, 2, 2, 4, 4, 8, 8, 16, 16}. I need to compute the total permutation for any given number. For example sum of 6 would have 3 permutations of {1, 1, 2, 2}, { 2, 4} and {1, 1, 4}. This is a homework question so don't want a complete code. I just need a math algorithm (a guide to solve this problem) that i can use to compute these specific coins change.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source