Permutations with some identical elements: Difference between revisions

(→‎{{header|Wren}}: Now uses Wren-perm module.)
Line 404:
["AABBBC", "AABBCB", "AABCBB", "AACBBB", "ABABBC", "ABABCB", "ABACBB", "ABBABC", "ABBACB", "ABBBAC", "ABBBCA", "ABBCAB", "ABBCBA", "ABCABB", "ABCBAB", "ABCBBA", "ACABBB", "ACBABB", "ACBBAB", "ACBBBA", "BAABBC", "BAABCB", "BAACBB", "BABABC", "BABACB", "BABBAC", "BABBCA", "BABCAB", "BABCBA", "BACABB", "BACBAB", "BACBBA", "BBAABC", "BBAACB", "BBABAC", "BBABCA", "BBACAB", "BBACBA", "BBBAAC", "BBBACA", "BBBCAA", "BBCAAB", "BBCABA", "BBCBAA", "BCAABB", "BCABAB", "BCABBA", "BCBAAB", "BCBABA", "BCBBAA", "CAABBB", "CABABB", "CABBAB", "CABBBA", "CBAABB", "CBABAB", "CBABBA", "CBBAAB", "CBBABA", "CBBBAA"]
</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>ClearAll[PermsFromFrequencies]
PermsFromFrequencies[l_List] := Module[{digs},
digs = Flatten[MapIndexed[ReverseApplied[ConstantArray], l]];
Permutations[digs]
]
PermsFromFrequencies[{2, 3, 1}] // Column</lang>
{{out}}
<pre>{1,1,2,2,2,3}
{1,1,2,2,3,2}
{1,1,2,3,2,2}
{1,1,3,2,2,2}
{1,2,1,2,2,3}
{1,2,1,2,3,2}
{1,2,1,3,2,2}
{1,2,2,1,2,3}
{1,2,2,1,3,2}
{1,2,2,2,1,3}
{1,2,2,2,3,1}
{1,2,2,3,1,2}
{1,2,2,3,2,1}
{1,2,3,1,2,2}
{1,2,3,2,1,2}
{1,2,3,2,2,1}
{1,3,1,2,2,2}
{1,3,2,1,2,2}
{1,3,2,2,1,2}
{1,3,2,2,2,1}
{2,1,1,2,2,3}
{2,1,1,2,3,2}
{2,1,1,3,2,2}
{2,1,2,1,2,3}
{2,1,2,1,3,2}
{2,1,2,2,1,3}
{2,1,2,2,3,1}
{2,1,2,3,1,2}
{2,1,2,3,2,1}
{2,1,3,1,2,2}
{2,1,3,2,1,2}
{2,1,3,2,2,1}
{2,2,1,1,2,3}
{2,2,1,1,3,2}
{2,2,1,2,1,3}
{2,2,1,2,3,1}
{2,2,1,3,1,2}
{2,2,1,3,2,1}
{2,2,2,1,1,3}
{2,2,2,1,3,1}
{2,2,2,3,1,1}
{2,2,3,1,1,2}
{2,2,3,1,2,1}
{2,2,3,2,1,1}
{2,3,1,1,2,2}
{2,3,1,2,1,2}
{2,3,1,2,2,1}
{2,3,2,1,1,2}
{2,3,2,1,2,1}
{2,3,2,2,1,1}
{3,1,1,2,2,2}
{3,1,2,1,2,2}
{3,1,2,2,1,2}
{3,1,2,2,2,1}
{3,2,1,1,2,2}
{3,2,1,2,1,2}
{3,2,1,2,2,1}
{3,2,2,1,1,2}
{3,2,2,1,2,1}
{3,2,2,2,1,1}</pre>
 
=={{header|MiniZinc}}==
1,111

edits