Re: Listing the partitions of a set
- To: mathgroup at smc.vnet.net
- Subject: [mg65314] Re: [mg65282] Listing the partitions of a set
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 25 Mar 2006 05:17:55 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
What about... Needs["DiscreteMath`Combinatorica`"] ?KSetPartitions Flatten[KSetPartitions[{1, 2, 3, 4}, #] & /@ Range[4], 1] Length[%] {{{1, 2, 3, 4}}, {{1}, {2, 3, 4}}, {{1, 2}, {3, 4}}, {{1, 3, 4}, {2}}, {{1, 2, 3}, {4}}, {{1, 4}, {2, 3}}, {{1, 2, 4}, {3}}, {{1, 3}, {2, 4}}, {{1}, {2}, {3, 4}}, {{1}, {2, 3}, {4}}, {{1}, {2, 4}, {3}}, {{1, 2}, {3}, {4}}, {{1, 3}, {2}, {4}}, {{1, 4}, {2}, {3}}, {{1}, {2}, {3}, {4}}} 15 David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Richard Palmer [mailto:mapsinc at bellatlantic.net] To: mathgroup at smc.vnet.net Is there a simple way to list the partitions of a set? For example, there are 15 partitions on a set of 4 elements. {{{1, 2, 3, 4}}, {1, {2, 3, 4}}, {{1, 3, 4}, 2}, {{1, 2, 4}, 3}, {{1, 2, 3}, 4}, {{1, 2}, {3, 4}}, {{1, 3}, {2, 4}}, {{1, 4}, {2, 3}}, {1, 2, {3, 4}}, {1, 3, {2, 4}}, {1, 4, {2, 3}}, {2, 3, {1, 4}}, {2, 4, {1, 3}}, {3, 4, {1, 2}}, {1, 2, 3, 4}} .