# Number partitions [closed]

(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.

## closed as off-topic by Gabriel C. Drummond-Cole, Neil Hoffman, Alexey Ustinov, Igor Pak, Emil JeřábekNov 21 '18 at 9:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "MathOverflow is for mathematicians to ask each other questions about their research. See Math.StackExchange to ask general questions in mathematics." – Gabriel C. Drummond-Cole, Neil Hoffman, Alexey Ustinov, Igor Pak, Emil Jeřábek
If this question can be reworded to fit the rules in the help center, please edit the question.

• What you are calling "partition numbers" are usually called "parts". So what you want is, for given $n$ and $k$, the number of partitions of $n$ into $k$ distinct parts, the parts differing by at least two. – Gerry Myerson Nov 15 '18 at 21:03
• constrainedPartitions[s_: Integer, k_: List, t_: Integer] := Length[Select[ IntegerPartitions[ s, {t}], (ContainsOnly[#, k] && DuplicateFreeQ[#]) &]] This Mathematica code gives the number of such partitions of $s$ that have exactly $t$ elements selected from the list $k$ (with no duplicates). constrainedPartitions[28, {1, 3, 9, 14, 16, 23, 25, 27}, 2] = 2. – David G. Stork Nov 15 '18 at 21:40

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}} *)