Re: Why are permutations dupl

*To*: mathgroup at smc.vnet.net*Subject*: [mg54691] Re: [mg54628] Why are permutations dupl*From*: DrBob <drbob at bigfoot.com>*Date*: Sun, 27 Feb 2005 01:29:16 -0500 (EST)*References*: <200502251040.j1PAeSVa021379@ls413.htnet.hr>*Reply-to*: drbob at bigfoot.com*Sender*: owner-wri-mathgroup at wolfram.com

Here's a link that MAY help. http://forums.wolfram.com/mathgroup/archive/2004/Aug/msg00180.html Bobby On Fri, 25 Feb 2005 11:40:28 CEST, <valentina.mikel at po.htnet.hr> wrote: > Bob! > Yes, I'm aware we're talking about 14! here, but this I got reduced from 24! and > that is unsolvable! > As I imagine, I would have to make a function in Mathematica that performs the > functionality of NextPermutation; it is called once for every sequential > permutation, and it still must not return duplicates. > > The scenario is as follows: > > loop > { > C++ program calls Mathematica's NextPermutationModified function, which returns > 1 (next) result. > C++ program performs some operations > } until no more permutations are left > > Can you make this function, as specified? > > Pseudo-code for this would be even better, as that would enable me to solve the > problem directly in C++ without Mathematica at all! > > Can you produce a code-snippet so that Mathematica throws out _one result at the > time_, so that I can call this from a C++ process in my program. > > THAnks Bob > >> You get duplicates because the two zeroes are treated as distinct items, as if > you'd > entered: >> >> Needs["DiscreteMath`Combinatorica`"] >> LexicographicPermutations[{a, b, c, d}] /. {c -> 0, d -> 0} >> >> Is this what you wanted, instead? >> >> Union@LexicographicPermutations[{a,b,0,0}] >> >> {{0,0,a,b},{0,0,b,a},{0,a,0,b},{0,a,b,0},{0,b,0,a},{0,b,a,0},{ >> a,0,0,b},{a,0,b,0},{a,b,0,0},{b,0,0,a},{b,0,a,0},{b,a,0,0}} >> >> or maybe... >> >> LexicographicPermutations[{a,b,0}]/.(0\[RuleDelayed]Sequence[0,0]) >> >> {{a,b,0,0},{a,0,0,b},{b,a,0,0},{b,0,0,a},{0,0,a,b},{0,0,b,a}} >> >> as for > LexicographicPermutations[{0,C,D,0,G,H,J,0,0,P,0,0,T,V,0,X,Y,0,0,4,0,7,8,0}], you > have GOT to be kidding. Even with the most conservative assumption, look how many > permutations there'd be: >> >> Length@Union@{0,C,D,0,G,H,J,0,0,P,0,0,T,V,0,X,Y,0,0,4,0,7,8,0} >> %! >> >> 14 >> >> 87178291200 >> >> Bobby >> >> On Thu, 24 Feb 2005 03:21:32 -0500 (EST), Valentina Mikel > <valentina.mikel at po.htnet.hr> > wrote: >> >> > When I enter >> > >> > LexicographicPermutations[{a, b, 0, 0}] >> > >> > the result is following: >> > {{a, b, 0, 0}, {a, b, 0, 0}, {a, 0, b, 0}, {a, 0, 0, b}, { >> > a, 0, b, 0}, {a, 0, 0, b}, {b, a, 0, 0}, {b, a, 0, 0}, { >> > b, 0, a, 0}, {b, 0, 0, a}, {b, 0, a, 0}, {b, 0, 0, a}, { >> > 0, a, b, 0}, {0, a, 0, b}, {0, b, a, 0}, {0, b, 0, a}, { >> > 0, 0, a, b}, {0, 0, b, a}, {0, a, b, 0}, {0, a, 0, b}, { >> > 0, b, a, 0}, {0, b, 0, a}, {0, 0, a, b}, {0, 0, b, a}} >> > >> > >> > Why does the result repeat duplicate cases? >> > In my case I must perform exact functionality of >> > LexicographicPermutations[{0,C,D,0,G,H,J,0,0,P,0,0,T,V,0,X,Y,0,0,4,0,7,8,0}]; >> > since there are lots of duplicates I'm trying to implement this in C++ >> > for maximum speed. >> > >> > Can this be avoided in Mathematica itself, and how? >> > >> > >> > >> > >> >> >> >> -- >> DrBob at bigfoot.com >> www.eclecticdreams.net >> > > > > > ---------------------- T - C o m - - W e b m a i l ---------------------- > Ova poruka poslana je upotrebom T-Com Webmail usluge. > http://komunikator.tportal.hr > > > > > -- DrBob at bigfoot.com www.eclecticdreams.net

**Re: Re: Re: Mathematica 5 and Windows XP**

**Mathematica Graphics output in an ASP.NET WebApplication II**

**Re: Mathematica batch file**

**Mathematica Graphics output in an ASP.NET WebApplication II**