MathGroup Archive 1997

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

Search the Archive

Re: combinatorics problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7569] Re: [mg7514] combinatorics problem
  • From: daiyanh at mindspring.com (Daitaro Hagihara)
  • Date: Sun, 15 Jun 1997 16:32:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Your case is confirmed on my version 2.2.  Though it's not my experience,
I came up with a workaround, i.e., by transforming the set before Union.

transformStandard[x_List]:=
Block[{len=Length[x],small=Min[x],pos},
      pos=Position[x,small][[1,1]];
      If[x[[1+Mod[pos-2,len]]]>x[[1+Mod[pos,len]]],
         RotateLeft[x,pos-1],
         Reverse[RotateRight[x,len-pos]]]]

Union@(transformStandard/@{{2,1,3,4},{3,4,1,2},{3,4,2,1}})
--> {{1, 2, 3, 4}, {1, 2, 4, 3}}

It's clearer to see.  You can optimize and improve the code as necessary.
I'm not quite all that sure as to how Union behaves against a supplied
test function after fooling around with it.  It's extremely complicated,
I guess.  The answer to the last question for the case of n=4 is, thus,
Union@(transformStandard/@Permutations[Range[4]])
--> {{1, 2, 3, 4}, {1, 2, 4, 3}, {1, 3, 2, 4}},
that is 3 ways out of possible 4!=24 choices.  From other experiments for
different n, I get (n-1)!/2 for n>2.  The aftermath is, divide n! by n
(invariant under shifts) and by 2 (invariant under reversal).

Daitaro Hagihara



  • Prev by Date: Re: List plot with + possible?
  • Next by Date: Re: Creating table with multiple lists
  • Previous by thread: Re: combinatorics problem
  • Next by thread: Re: combinatorics problem