MathGroup Archive 2003

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

Search the Archive

Re: ListNecklaces of n beads of |c| different colors (n!=c)?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42052] Re: ListNecklaces of n beads of |c| different colors (n!=c)?
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Tue, 17 Jun 2003 05:43:49 -0400 (EDT)
  • Organization: University of Washington
  • References: <bcjuvb$htp$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Maneesh,

Something like this, perhaps?

AllNecklaces[n_,m_,c_]:=
    Flatten[ListNecklaces[n,#,c]&/@
        (Distribute[g@@Table[f@@m,{n}],f]
            /.g->(Sort[List[##]]&)
            /.f->(Union[List[##]]&)),1]

For example,

In[15]:=
AllNecklaces[5,{R,G,B},Dihedral]
Out[15]=
{{B, B, B, B, B}, {B, B, B, B, G}, {B, B, B, B, R}, {B, B, B, G, G}, {B, B,
G, B, G},

  {B, B, B, G, R}, {B, B, G, B, R}, {B, B, B, R, R}, {B, B, R, B, R}, {B, B,
G, G, G},

  {B, G, B, G, G}, {B, B, G, G, R}, {B, B, G, R, G}, {B, G, B, G, R}, {B, G,
G, B, R},

  {B, B, G, R, R}, {B, B, R, G, R}, {B, G, B, R, R}, {B, G, R, B, R}, {B, B,
R, R, R},

  {B, R, B, R, R}, {B, G, G, G, G}, {B, G, G, G, R}, {B, G, G, R, G}, {B, G,
G, R, R},

  {B, G, R, G, R}, {B, G, R, R, G}, {B, R, G, G, R}, {B, G, R, R, R}, {B, R,
G, R, R},

  {B, R, R, R, R}, {G, G, G, G, G}, {G, G, G, G, R}, {G, G, G, R, R}, {G, G,
R, G, R},

  {G, G, R, R, R}, {G, R, G, R, R}, {G, R, R, R, R}, {R, R, R, R, R}}

Confirming:

In[16]:=
Length[%]
NumberOfNecklaces[5,3,Dihedral]
Out[16]=
39
Out[17]=
39

Carl Woll
Physics Dept
U of Washington

"maneesh" <maneesh at drunkenbastards.com> wrote in message
news:bcjuvb$htp$1 at smc.vnet.net...
> Hi all,
> Is there anyway I can obtain a list of necklaces of n beads of |c|
> different colors?
>
> I can certainly count the number of them, but I can't figure out how
> to construct them in Mathematica...
>
> I shamefully admit to not understanding why Length[c] has to be equal
> to n for ListNecklaces to work....
>



  • Prev by Date: Re: About Abel Type Differential Equation
  • Next by Date: Re: How is it possible to factor Sum[a]+Sum[b] to Sum[a+b] ?
  • Previous by thread: Re: ListNecklaces of n beads of |c| different colors (n!=c)?
  • Next by thread: Separating real and imaginary parts of symbolic expressions