I want to create a function PartSet[N_,M_]
of two positive integer variables which outputs a list of all pairs of integer partitions for all integers up to $M$ satisfying the two conditions:
- In a tuple of partitions, they can certainly be partitions of a different integer, but they must have the same length. For example,
{{1,3},{3,5}}
is a valid pair of a partition of $4$ and $8$, respectively. - In either partition of a tuple, no number can appear more than $N+1$ times. For example, when $N=2$ the tuple
{{1,2,2,2,2,4},{5,6}}
should not appear in the list because in one of the partitions $2$ appears more than $3$ times.
(The only role of the $M$ is just that on a computer, we can't have an infinite list of partitions of arbitrarily big integers, so I'm just going to set $M$ to be big enough for my application, e.g. maybe $30$ or so.)
Can anyone help me out with this?
My schematic idea is as follows. First create a function Part1[M_]
which outputs a list of all partitions of integers up to $M$. This must be very simple, but I don't know how to do a union over a variable number of lists! Then make Part2[N_,M_]
which outputs the list Part1[M]
but where you eliminate from the list any partition where a number is repeated more than $N+1$ times. Of course you can then take the Cartesian product to get my pairs of partitions. And finally, eliminate pairs where the two partitions have different lengths. My biggest obstacle here is removing things from lists based on some possibly complicated conditions.