MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: [Q] Generalized Partitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29975] Re: [mg29942] [Q] Generalized Partitions
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Fri, 20 Jul 2001 03:28:38 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

You do not state if the partitions should be into ordered or un-ordered
sets. Anyway, probably the easiest way is to make use of the standard
package Combinatorica:

In[1]:=
<<DiscreteMath`Combinatorica`

In[2]:=
OrderedPartitions[n_, k_, l_List] :=
  Select[Compositions[n, k], Complement[#1, l] == {}& ]

In[3]:=
UnorderedPartitions[n_, k_, l_List] :=
  Select[OrderedPartitions[n, k, l], OrderedQ]

Using your list:

In[4]:=
l={1,3,4,5,6,7,9};

In[5]:=
OrderedPartitions[10,2,l]
Out[5]=
{{1,9},{3,7},{4,6},{5,5},{6,4},{7,3},{9,1}}
In[6]:=
UnorderedPartitions[10,2,l]
Out[6]=
{{1,9},{3,7},{4,6},{5,5}}

-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/~andrzej/

on 01.7.19 4:57 PM, Janusz Kawczak at jkawczak at math.uncc.edu wrote:

> Dear Mathematica users:
> 
> do you know of a function in Mathematica that could do the partitioning
> of a number into a fixed number of components out of predefined set,
> i.e. partition number 10 into the elements from the set {1,3,4,5,6,7,9}
> and each partition should have exactly, say, 2 elements.  Of course, I
> have in mind a much bigger problem.
> 
> Thank you in advance for your help.
> Janusz Kawczak.
> 
> 





  • Prev by Date: Re: Solving matrix equations
  • Next by Date: Re: slow integration
  • Previous by thread: Re: [Q] Generalized Partitions
  • Next by thread: Re: [Q] Generalized Partitions