Questions tagged [combinatorics]
Questions on the use of Mathematica in combinatorics, including the Combinatorica add-on package.
465
questions
0
votes
1
answer
49
views
Create list with integer partitions satisfying some conditions
I want to create a function PartSet[N_,M_] of two positive integer variables which outputs a list of all pairs of integer partitions for all integers up to $M$ ...
1
vote
1
answer
49
views
Sorted Tuples without Filtering
Say I have a list $L$ where the elements can be sorted into some canonical order. I want to use Tuples[L,m] but I only want the output lists to be sorted and ...
2
votes
2
answers
69
views
Using the generalised binomial theorem to expand an expression
I would like to use Mathematica to compute the following expansion: $(1+x)^\rho= 1 + \rho x +\dots$ for some $|\rho|<1$ as for example explained here. I tried the Series expansion functions ...
5
votes
1
answer
54
views
Picking integer compositions with certain descent patterns
I am trying to find a nice way to pick out all the integer compositions (ordered partitions) of an integer $n$ that satisfy a given pattern of descents between some adjacent elements. Writing a ...
7
votes
1
answer
419
views
Tuples optimization challenge
Consider a function that for a given integer $0\le n <256$ computes the number of leading zeros in its binary representation.
...
6
votes
1
answer
148
views
Combine each element with all the others in sublists
Suppose that I have a list of numbers
list = {{{1, 0}, {-1, 1}, {0, -1}}, {{-1, 0, 1}, {-1, 1, -1}, {-1, -1, 0}, {1, 1, 0}, {1, -1, 1}, {1, 0, -1}}}
I would like ...
0
votes
1
answer
95
views
Deleting sublists based on a criterion
I generated a list as follows
...
1
vote
0
answers
38
views
Enumerating labeled graphs on n vertices
I'm trying to enumerate the labeled graphs on $n$ vertices having at most $e$ edges. I thought GraphData /@ GraphData[n] and then filtering by edge count would do ...
3
votes
1
answer
51
views
How can I convert sequences to sharings and vice versa?
Given positive integers $k,n$, a $k$-sequence of $I_n$ is a list of $k$ not necessarily distinct elements of $\{1,\dots, n\}$. And an $n$-sharing of $I_k$ is a list of $n$ possibly empty, disjoint ...
4
votes
1
answer
73
views
Implementing summation under combinatorial restriction
For $m,n\in\mathbb N$, I am interested in the numerical evaluation of
$$f(m,n) = \sum_{s_j\in\{\pm1\}}' \prod_{k=1}^{2n-1} (1-e^{\frac{2i\pi}{m} s_k(s_{k+1}+s_{k+2}+\cdots+s_{2n})}),$$
where the ...
2
votes
1
answer
191
views
Is there a Mathematica function that generates all ordered partitions?
My book defines a length $k$ ordered partition of $I_n$ as a sequence of $k$ disjoint, possibly empty subsets of $\{1,\dots, n\}$ that union up to $\{1,\dots, n\}$. Is there a mathematica function ...
2
votes
1
answer
86
views
Mathematica code for q-Stirling numbers
In the paper [A new $q$-Analog of Stirling Numbers],(https://hal.archives-ouvertes.fr/hal-01372920/document)[PDF] J. Cigler defined $q$-Stirling numbers of the second
kind as the following:
He ...
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 ...
0
votes
0
answers
30
views
Building and Plotting a discrete CDF
I'm trying to plot the CDF of a simple "nCr" experiment:
A box contains 4 screws and 6 nails. Two items are drawn at random without replacement. Let X be the number of nails drawn.
I built a ...
6
votes
1
answer
213
views
Producing a random Wang Tile tiling image more efficiently
I'm following along with this SIGGRAPH 2006 paper Recursive Wang Tiles for Real-Time Blue Noise - there's a video here too. Eventually I want to try to produce the blue noise results in the paper, and ...
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:
...
0
votes
0
answers
58
views
Conditional Statement and Loop in Mathematica to find bound
I have a question regarding loop and conditional statements. I have an equation where I would like to find the bound for n and m based on the value of h. Here is what I have so far;
...
1
vote
0
answers
59
views
Triangulation of Point Configuration
I was going through the documentation of Mathematica but couldn't find any built-in function that can find all possible triangulations for a given set of points.
For example, if I have the following ...
2
votes
1
answer
137
views
2
votes
0
answers
64
views
Matroids in Mathematica?
I can't seem to find a "standard" way to implement/manipulate matroids in Mathematica. (They do not seem to be included in Combinatorica, for instance, and googling has turned up nothing.) ...
3
votes
2
answers
139
views
Find different combinations of 3 lists with given constraints
My inputs are 3 lists of unequal length:
A={a,b,c,d}
B={i,j,k}
C={v,w,x,y,z}
And I want to find the combine set X which looks like
...
2
votes
1
answer
56
views
2
votes
1
answer
49
views
Extract only a few coefficients of the multiple of extremely many polynomials
I want to extract some informations, say the coefficients of $x^{500}$ and $x^{1000}$ terms (numerical values are acceptable), of the multiple of
...
7
votes
3
answers
330
views
Partition a nested list such that no repeated elements in every subsets?
I have a large list and for simplicity, let's take the simple list as an example:
lists = {{1, 2}, {1, 6}, {2, 3}, {2, 5}, {3, 4}, {3, 6}, {4, 5}, {5, 6}}
I would ...
1
vote
0
answers
53
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 ...
1
vote
1
answer
56
views
Construct all possible 3-letter words from A,B. Repetition of letters is allowed [closed]
I have two letters A and B. I need to construct all possible 3-letter words. Repetition of letters is allowed. I know that the answer to this problem is 2^3=8. But ...
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 ...
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 &...
1
vote
1
answer
55
views
Edge thickness in directed path graph doesn't respond
I have the following code to draw a lattice path in 3D:
...
5
votes
6
answers
429
views
Count number of balls in each bin, given a two-element sequence of balls and bins
If I have a list:
{ball,ball,BINDIVIDER,ball,ball,ball,BINDIVIDER,BINDIVIDER,ball,BINDIVIDER,ball}
The balls and bins can be in any permutation.
Then, the ...
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},...
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 ...
11
votes
8
answers
1k
views
Transform a number to a factorial
I came across the need to transform a number into a factorial n, with positive integer n. I have searched in the MMA information but I can't find anything like that.
I imagine an input, which verifies ...
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 ...
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.
...
3
votes
2
answers
83
views
Generating representatives of rotation classes of tuples of ones and zeros with a fixed number of ones
In a related question I asked how to generate all the tuples of ones and zeroes with a fixed number of ones (generating tuples of ones and zeroes with a fixed number of ones). I wish to consider a ...
9
votes
6
answers
446
views
generating tuples of ones and zeroes with a fixed number of ones
I would like to generate all the tuples of ones and zeros of a given length and with a given number of ones without generating all the possible tuples, which is impossible for tuples of large enough ...
1
vote
1
answer
133
views
How to efficiently replace the repetitive sequence?
The problem is how to determine the repetitive sequences and replace the part with consecutive sequences
For example:
A={{1,3,4},{2,3,5},{1,6}}
Then, detect there ...
6
votes
3
answers
845
views
How many graphs are there on 4 nodes with degrees 1, 1, 2, 2?
I know just the basic operations on graphs using Mathematica. But I want to know how to write a code that prints all the possible combinations of a graph with a specified number of edges.
Take for ...
11
votes
4
answers
580
views
Scan through (partial) tuples
I have a list of list of positive integers $s = \{s_1, s_2, ..., s_k\}$, each list $s_i$ is possibly of different lengths, and I want to find out if there exists a $k$-tuple of the $s_i$ that sums ...
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.
...
3
votes
3
answers
169
views
How to delete duplicate graphics of the same kind?
A054247: Number of n X n binary matrices under action of dihedral group of the square D_4.
...
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!$)?
...
2
votes
4
answers
107
views
What is the easiest and efficient way to get positive or negative combinations of a list?
Consider the following simple case:
list={1,2,2};
Subsets[{Splice[list],Splice[-list]},{1,Length@list}]
This produces the following combinations:
{{1}, {2}, {2}, {-...
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 ...
4
votes
2
answers
304
views
How to correctly enumerate all the schemes of this cube coloring problem?
This problem is the fifth question of 1996 Chinese High School Mathematics League or Chinese Mathematical Olympiad in Senior:
Choose several colors from the given six different colors to dye six faces ...
7
votes
5
answers
591
views
How to correctly calculate the number of seating plans for the 4-couples problem?
Four couples a are sitting around a round table, in which husband and wife can not be adjacent. How many different seating plans are there?
I want to get as many simple calculations as possible.
...
3
votes
3
answers
188
views
Combinatorial selection with constraints
Five of the 10 actors can only sing, two can only dance, and three can both sing and dance. Now, how many kinds of selection methods are there to perform a program that requires two people to dance ...
3
votes
1
answer
157
views
Solving calculation puzzle [closed]
I recently got asked how to achieve a result of 100 only using the numbers {1,7,7,7,7} (the number 1 can be used only once and ...
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 ...