Message Boards Message Boards

0
|
7571 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How can I get Permutations of each Integer Partition?

Posted 10 years ago

Hello! Before we begin, let me mention that I am rubbish at coding.

Ok! Time to explain my question a bit more.

What I'm trying to do is get each permutation of each integer partition. You see, if I do

IntegerPartitions[7}

I get a single permutation of each list. For example, I might get {2,2,1,1,1} as an answer, but I won't get {1,2,1,2,1} and {2,2,1,1,1} as answers. So far, I've been manually taking each list and putting it into code, but this takes a while if I'm doing it for each one.

Permutations[{2,2,1,1,1}]

Depending on how large the number is for the IntegerPartitions step, there could be more than a hundred answers, so to manually copy over each list to the Permutations code would take a while.

My question is, how would I get each permutation of each partition without having to manually copy over each partition into the permutation code? Thanks for any help! :)

POSTED BY: Logan Bell
2 Replies

If I understand correctly the question, then you just want to use Map.

Map[Permutations, IntegerPartitions[7]]

(* Out[183]= {{{7}}, {{6, 1}, {1, 6}}, {{5, 2}, {2, 5}}, {{5, 1, 1}, {1, 
   5, 1}, {1, 1, 5}}, {{4, 3}, {3, 4}}, {{4, 2, 1}, {4, 1, 2}, {2, 4, 
   1}, {2, 1, 4}, {1, 4, 2}, {1, 2, 4}}, {{4, 1, 1, 1}, {1, 4, 1, 
   1}, {1, 1, 4, 1}, {1, 1, 1, 4}}, {{3, 3, 1}, {3, 1, 3}, {1, 3, 
   3}}, {{3, 2, 2}, {2, 3, 2}, {2, 2, 3}}, {{3, 2, 1, 1}, {3, 1, 2, 
   1}, {3, 1, 1, 2}, {2, 3, 1, 1}, {2, 1, 3, 1}, {2, 1, 1, 3}, {1, 3, 
   2, 1}, {1, 3, 1, 2}, {1, 2, 3, 1}, {1, 2, 1, 3}, {1, 1, 3, 2}, {1, 
   1, 2, 3}}, {{3, 1, 1, 1, 1}, {1, 3, 1, 1, 1}, {1, 1, 3, 1, 1}, {1, 
   1, 1, 3, 1}, {1, 1, 1, 1, 3}}, {{2, 2, 2, 1}, {2, 2, 1, 2}, {2, 1, 
   2, 2}, {1, 2, 2, 2}}, {{2, 2, 1, 1, 1}, {2, 1, 2, 1, 1}, {2, 1, 1, 
   2, 1}, {2, 1, 1, 1, 2}, {1, 2, 2, 1, 1}, {1, 2, 1, 2, 1}, {1, 2, 1,
    1, 2}, {1, 1, 2, 2, 1}, {1, 1, 2, 1, 2}, {1, 1, 1, 2, 2}}, {{2, 1,
    1, 1, 1, 1}, {1, 2, 1, 1, 1, 1}, {1, 1, 2, 1, 1, 1}, {1, 1, 1, 2, 
   1, 1}, {1, 1, 1, 1, 2, 1}, {1, 1, 1, 1, 1, 2}}, {{1, 1, 1, 1, 1, 1,
    1}}} *)
POSTED BY: Daniel Lichtblau
Posted 10 years ago

Cool! Thanks! :)

POSTED BY: Logan Bell
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract