3
$\begingroup$

I am trying to prove a conjecture which involves the SetParitions[n] function (which requires the Combinatorica package). This function returns a list of all the set partitions of n. I'd like to take the max from each "block" in each set partition, add n+1, and then multiple the results together.

For example, if n=3, we have

SetPartitions[3]={{{1,2,3}},{{1},{2,3}},{{1,2},{3}},{{1,3},{2}},{{1},{2},{3}}}

The first set partition is {1,2,3} and only has one block. So its max is 3 and I would like to return (3+4)=7. The next partition is {1}{2,3}, so the two max values are 1 and 3. This should return (1+4)*(3+4)=5*7=35. The following parition is {1,2}{3}, which has max values 2 and 3, yielding (2+4)*(3+4)=6*7=42.

I really appreciate any assistance.

Edit: I also need the size of each block. For example, if I use {1,2}{3}, I need to use the fact that the block {1,2} is of size 2 and the block {3} is of size 1.

$\endgroup$
3
  • 1
    $\begingroup$ Does Times @@@ (Map[Max, SetPartitions[n], {2}] + n + 1) do what you want? $\endgroup$ May 11, 2016 at 0:50
  • $\begingroup$ Yes! Thank you! $\endgroup$
    – C Sel
    May 11, 2016 at 1:04
  • $\begingroup$ With respect to the edit, try Map[Length, SetPartitions[n], {2}]. If these suit your needs, you can write an answer to your own question. $\endgroup$ May 11, 2016 at 1:05

1 Answer 1

5
$\begingroup$

I needed the following two functions:

Times @@@ (Map[Max, SetPartitions[n], {2}] + n + 1)

Map[Length, SetPartitions[n], {2}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.