Talk:Permutations with some identical elements

From Rosetta Code
Revision as of 06:13, 10 February 2020 by Eoraptor (talk | contribs)

Duplicate of Permutations with repetitions

Seems to me this exact operation is covered by the existing (for 6 years!) Permutations_with_repetitions task. --Thundergnat (talk) 19:32, 25 July 2019 (UTC)

I don't think so.He wants to create the permutation of different elements in which each element has its own constant multiplicity in this permutation. His example: [2,1] ( element 1 two times und element 2 1 time ) should give results (1,1,2), (1,2,1) and (2,1,1)

Horst.h

I don't think the permutations_with_repetitions task is about permutations at all, but rather generating all possible sequences (words) of a certain length from an alphabet, where each symbol may be repeated an infinite amount of times as needed.

This task is instead about creating all sequences of a finite set of elements where some elements are indistinguishable from each other.

Yes, you're right; it is different. I've added a Go solution --PureFox (talk) 21:27, 25 July 2019 (UTC)


task wording

Where it says:

   Given an input of the form [a1, a2, ..., ak] where ai denotes how many duplicates of element i you should have, 
   each ai > 0 and the sum of all ai is n.

would it be better with:

   Given an input of the form   [a1, a2, ..., ak]   where   ak   denotes how many duplicates of element   k   you should have, 
   each   ak > 0   and the sum of all   ak   is   n.


(I've added whitespace and used a bigger font to make the subscripts easier to read.)     -- Gerard Schildberger (talk) 03:51, 27 July 2019 (UTC)

That is excellent! --Tobega

Close to the permutations task

Note that one of the simplest algorithms to generate permutations (this one, which also appears in Knuth's TAOCP), can be trivially modified to handle this task: just replace < and > with <= and >=.

Eoraptor (talk) 06:12, 10 February 2020 (UTC)