Questions tagged [permutation]

For questions about the functionality related to permutations in Mathematica.

Filter by
Sorted by
Tagged with
2 votes
1 answer
93 views

How to convert a PermutationGroup to a named group

We can convert any built-in named group into PermutationGroup by this code(such as AlternatingGroup[5]): ...
user avatar
  • 23.1k
1 vote
0 answers
65 views

Find Max Instance Over Permutations

I would like to find the maximum of some objective function over all possible permutations ...
user avatar
7 votes
3 answers
307 views

Is there a function to generate “subsets” allowing duplicates?

I allow them to be chosen more than once (e.g. allow {1,1}). (A subset means every element is chosen once or less) Also I neglect the order (e.g. ...
user avatar
  • 75
4 votes
3 answers
89 views

How to find the cycle type vector of a random permutation

Given a random permutation $\pi$ of {1,2,...,n}, I want to produce a list {a1,a2,...,an} of nonnegative integers so that ai is the number of cycles in $\pi$ of length i for each i=1,2,...,n. For ...
user avatar
  • 573
2 votes
1 answer
52 views

Range permutations, treating given runs of consecutive element as they were identical

Given a positive integer $n$ and a list of disjoint intervals in the form $\{\{i_1,i_1+1,i_1+2,\ldots,i_1+n_1\},\{i_2,i_2+1,i_2+2,\ldots i_2+n_2\},\ldots\}$ all contained in $[1,n]$, I want to ...
user avatar
4 votes
3 answers
230 views

Generating signed permutation matrices

As most people (on here at least) know a permutation matrix is a square binary matrix that has exactly one entry of 1 in each row and each column and 0s elsewhere. For the $n \times n$ case there are $...
user avatar
  • 485
3 votes
1 answer
96 views

A code that returns the partial permutations on {1,2,...,n}

A partial permutation is a bijective partial function. A partial function is a map from a subset of {1,2,...,n} into {1,2,...,n}. I want a list of the matrix representations of all the partial ...
user avatar
  • 573
4 votes
1 answer
121 views

Permutations with Repetition

I am working with a function of type F[a,b,c,d,e,f] that obeys the following symmetries: ...
user avatar
5 votes
3 answers
169 views

Permutation avoidance function

It is common for me to see if a permutation of 1,2,...,n, avoids some fixed permutation pattern. For example, the permutation [1,4,2,3,5] contains the pattern 1,3,2, as the elements [1,4,3] appear in ...
user avatar
5 votes
1 answer
473 views

Generating a list of integers that sums to zero

Given a pair of integers n and k, I want to generate all lists of integers of length n, ...
user avatar
4 votes
1 answer
104 views

Binary permutation list code in Mathematica

Given some natural number $N$, I am interested in the set of all binary permutations of length $N$ (with the intention of storing in lists depending on how many $1$'s appear in each permutation). My ...
user avatar
  • 271
7 votes
3 answers
519 views

Visualizing distribution of 3 balls in 3 cells

I want to generate the following Table which shows the distribution of 3 balls in 3 cells. But so far I have had no luck using Permutations, ...
user avatar
1 vote
0 answers
31 views

Why is PermutationProduct not yielding anything? [closed]

When I am trying to compute some products of permutations in S_48, it is somehow not working. Here is my code: ...
user avatar
1 vote
2 answers
83 views

How to get the length of cycles in a Cycles[] expression? [closed]

I am looking for a way to get {5,2} for a Cycles object, like: Cycles[{{1,2,3,4,5},{6,7}}]. ...
user avatar
0 votes
1 answer
51 views

Finding the first few permutations of a list

Given a list, possibly with repeated elements, I am trying to get a list that consists of a specified number of distinct permutations of the list. Essentially, I want to something that works like <...
user avatar
  • 137
4 votes
5 answers
580 views

String permutation

I have a string "abcd". Is there any way in Mathematica such that when I apply some exchange operator $P^{ab}$ it gives me string "bacd"? Edit: After reading answers I felt like I ...
user avatar
5 votes
3 answers
101 views

Find transformations for two non-square matrices $A$ and $B$

Given two matrices $A$ and $B$: What transformation needs to be applied to transform matrix $A$ into matrix $B$? ...
user avatar
  • 1,576
1 vote
0 answers
52 views

How do I generate a random permutation of a (long [millions-length]) list of symbols? [closed]

I have a list of length twelve: p = {t[1, 1], t[1, 2], t[1, 3], t[1, 4], t[2, 2], t[2, 3], t[2, 4], t[1, 5], t[3, 3], t[3, 4], t[1, 6], t[4, 4]} and a set of ...
user avatar
3 votes
1 answer
99 views

How to get the complete list of subsets the pairwise intersections of which are empty

Given the list Range[4]. I want to get the sublists of length 2 where each element has length 2 and the pairwise intersections are empty. So I am looking for: ...
user avatar
  • 2,020
2 votes
1 answer
55 views

Unknown statistical function - groupings of permutations

Please bear with the vagueness of this question's title, as my question itself has to deal with the fact that I don't know what to call the operation I'm looking for. I have a statistical operation ...
user avatar
  • 555
4 votes
2 answers
100 views

Permuting elements in a nested list according to another nested list?

I have two lists (value and label). With the function Permute, I can permute the positions ...
user avatar
  • 1,546
4 votes
1 answer
131 views

Fast enumeration of all perfect matchings in complete graph

I have a code that generates the list with all possible Perfect Matchings (PM) of a fully connected graph. Each edge of the graph is mono or bi-colored with up to ...
user avatar
  • 327
3 votes
3 answers
334 views

Finding all Latin Squares of order 5

A Latin Square is a square of size n × n containing numbers 1 to n inclusive. Each number occurs once in each row and column. An example of a 3 × 3 Latin Square is: $$ \left( \begin{array}{ccc} 1 &...
user avatar
  • 4,868
0 votes
1 answer
84 views

How to create all possible permutations? [closed]

there is a problem: I have 5 letters - a,b,c,d,e and 20 places. I have to use each letter at least once but no more than 10 times. So the result can look like {a,a,a,a,a,a,a,a,a,a,b,b,b,b,b,b,b,c,d,e},...
user avatar
  • 11
1 vote
1 answer
117 views

How to generate all the combinations with repetition and another conditions? [duplicate]

I want to generate all the combinations with repetition for k variables with values from a set of n elements. There are some ways, I like this formula, which I found on this forum (it is for n = 2 and ...
user avatar
  • 11
2 votes
1 answer
93 views

Splitting balls over sized bins

This is strongly related to Splitting a set of integers over a set of bins, but a much simpler case. If we have $N$ indistinguishable balls and $k$ arbitrarily large distinguishable bins, we know the ...
user avatar
  • 45.4k
6 votes
1 answer
90 views

Splitting a set of integers over a set of bins

I have a problem that feels like it should be simple but I'm just drawing a blank on. I've got a set of integers, e.g. ...
user avatar
  • 45.4k
1 vote
1 answer
32 views

Permutation function which allows for repetitions

I want to permute a matrix based on some permutation cycle which is not known beforehand. A function searches through the matrix and returns the pair of indices $i,j$ of the first entry which equals ...
user avatar
3 votes
1 answer
91 views

Solve this equality of permutations

Is it possible to solve an equality such as: $$(123)=\sigma (32) \sigma (31)$$ in term of $\sigma$? I was thinking about Cycles but I couldn't figure out a way to ...
user avatar
  • 6,104
4 votes
1 answer
51 views

How to decompose a 5-cycles into a permutationproduct of two 3-cycles?

We know that every 3-cycles can be expressed as the product of two commutations. Cycles[{{1, 2, 3}}] == PermutationProduct[Cycles[{{1, 3}}], Cycles[{{3, 2}}]] In ...
user avatar
5 votes
2 answers
68 views

Pair-wise equality over large sets of large vectors

I've got an interesting performance tuning/algorithmic problem that I'm running into in an optimization context. I've got a set of ~16-50 lists of integers (usually in ...
user avatar
  • 45.4k
1 vote
0 answers
40 views

Custom Table, for iterating over permutations

It is common that I iterate over all permutations of 1,2...,n, either by making a table or performing a sum. Instead of creating the set of all permutations, it would be better to iterate over them. ...
user avatar
1 vote
1 answer
87 views

How to solve this problem by the way of saving memory?

Eight different boys and five different girls are in a row. Girls are required to be next to each other. How many ways are there (the answer is $9!\times5!$)? ...
user avatar
3 votes
4 answers
292 views

How to visually display the Stirling permutations of $k^{th}$ order?

Definition of Stirling permutation from Wikipedia: In combinatorial mathematics, a Stirling permutation of order k is a permutation of the multiset $\{1, 1, 2, 2, ..., k, k\}$ (with two copies of ...
user avatar
2 votes
4 answers
153 views

How to use function `GeneratingFunction ` to solve this combinatorial problem efficiently?

Divide the 14 elements {A, B, C, C, C, C, D, D, D, D, E, E, E, E} into 7 groups (one group all have two elements), and I want to find out how many kinds of methods ...
user avatar
1 vote
1 answer
82 views

XOR combination between the bits of a string

Given an integer n, we can construct $2^n$ strings of length n. We can take the first element for each of these strings and create a list. In total 'n' such lists are possible. But now I need to ...
user avatar
0 votes
1 answer
48 views

How many memory is needed for this permutations? [closed]

That's the code. Permutations[Alphabet[] , {12}] The pop-up message said that the current computation was aborted because there was insufficient memory available ...
user avatar
  • 1,601
7 votes
2 answers
209 views

Find All Permutations for Multiset

Take a list with repetitions, say {a, a, b, c}, and some permutation thereof, say {c, a, b, a}. I want to know which ...
user avatar
-3 votes
1 answer
69 views

Permutation Combinations Mobile Pattern Codes [closed]

Please help write codes to determine 4 to 6 dot patterns. I am stuck after permutations input. It would really help if one could write direct so I could copy paste code to determine list of 4 to 6 dot ...
user avatar
  • 1
6 votes
1 answer
82 views

Finding sequence of group generators that yields group element

Here is my permutation group that acts on lists of length 4, defined in terms of four generators: ...
user avatar
4 votes
3 answers
449 views

How do I get a list of all possible sums in a list nested list?

Lets say I have the following input: rn={ {1, 1.1, 1.5}, {5, 6, 6.1, 7}, {8, 8, 12, 12, 12.5, 13} } This input has the dimensions of ...
user avatar
  • 309
5 votes
1 answer
121 views

Why is NextPermutation slow?

<< Combinatorica` Permutations[Range[0, 9]][[1000000]] // AbsoluteTiming Nest[NextPermutation, Range[0, 9], 1*^6 - 1] // AbsoluteTiming I want to save memory,...
user avatar
  • 6,497
5 votes
1 answer
84 views

Pair-wise antisymmetric tensor

I am trying to define a tensor $T$ which is antisymmetric under pair-wise exchange of its indices: $T = \delta_{a],[b}\,\delta_{c],[d}\,\delta_{e],[f}\,\delta_{g],[h}$ where $T$ is antisymmetric under ...
user avatar
0 votes
3 answers
105 views

How to find the closed loop number of an array [closed]

I want to find the minimum number of swaps required to reset an array. This problem has many applications in linear algebra. The key point of this question is to find the number of closed loops in ...
user avatar
4 votes
2 answers
198 views

How to divide a list into several single loops

Because of some problems, I need to divide the permutation represented by a list into several single loop lists. For example, for list {4, 3, 2, 1, 7, 6, 5}, it can ...
user avatar
6 votes
4 answers
261 views

How to express permutation as the least number of exchanges

If there are grammatical or terminological errors in the following description, please help correct: In some problems, it is necessary to find out what minimum number of exchanges can change a list ...
user avatar
4 votes
2 answers
156 views

4X4 matrix of distinct cubed integers with identical row and column sums

I wrote the following code: ...
user avatar
  • 1,723
0 votes
0 answers
72 views

How can I shuffle the indices of certain variables?

I am recursively defining rational expressions in two sets of variables $x_i$ and $y_i$. Specifically, for $m<n$, I am interested in replacing all degree-$m$ monomials of the following form: $$\...
user avatar
  • 33
4 votes
1 answer
228 views

Efficiently removing elements from list of permutations

I'm looking for an efficient way to remove entries from a list of permutations. I have a list of variables from which I calculate all possible permutations. I then want to remove those permutations ...
user avatar
  • 109
1 vote
2 answers
85 views

Optimize certain list over permutations, perhaps using recursions?

I am trying to improve my code for computing products of monomial symmetric functions. It boils down to the following. Let lam and ...
user avatar

1
2 3 4 5