(I'm trying to solve a problem for computer programming. Don't have much of a math background, so I hope I am using the right terminology)


Is there a formula for getting the partitions of a number with these three restrictions:


1. the partition numbers are from a limited nonconsecutive set.
2. Each partition number is distinct and can only be used once in each partition sum.
3. The number of partition numbers in each sum is constant.


Any help is appreciated even if it's just pointing me in the right direction to research further.


Thanks.



Number partitions
There is no way to get a *formula* for these partitions, as it depends upon the list of available partition numbers. Nevertheless, here's *Mathematica* code that implements what you seek:



```
constrainedPartitions[s_: Integer, k_: List, t_: Integer] := 
 Select[IntegerPartitions[s, {t}], 
 (ContainsOnly[#, k] && DuplicateFreeQ[#]) &]

```

Examples:



```
constrainedPartitions[28, {1, 3, 9, 14, 16, 23, 25, 27}, 2]

```

(\* {{27, 1}, {25, 3}} \*)



```
constrainedPartitions[40, {1, 3, 5, 7, 10, 13, 16, 21}, 3]

```

(\* {{21, 16, 3}} \*)


