Questions tagged [combinatorics]

Questions on the use of Mathematica in combinatorics, including the Combinatorica add-on package.

Filter by
Sorted by
Tagged with
0
votes
0answers
22 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 ...
11
votes
4answers
2k views

Cyclic and Non-cyclic Permutations

Mathematica has a built in function to generate all permutations of a given list of elements; Permutations I can't find an equivalent function to generate cyclic ...
0
votes
0answers
53 views

Code in Mathematica is not running [closed]

I have a question regarding my code in Mathematica. In the beginning when I tried to run my code it worked but then after I closed it and come back to do the same code but with different number it did ...
1
vote
0answers
69 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
1answer
105 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
0answers
49 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; ...
6
votes
5answers
295 views

Construct a permutation tree plot

How to construct a tree like this? I was looking CompleteKaryTree initially, there are some similarities overall, but it's still different. ...
1
vote
0answers
53 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 ...
1
vote
0answers
62 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.) ...
34
votes
8answers
3k views

Insert $+$, $-$, $\times$, $/$, $($, $)$ into $123456789$ to make it equal to $100$

Insert $+$, $-$, $\times$, $/$, $($, $)$ into $123456789$ to make it equal to $100$. Looks like a question for pupils, right? In fact, if the available math symbols are limited to addition ($+$), ...
12
votes
1answer
237 views

StableMarriage vs. FindIndependendEdgeSet: How to use the procedure FindIndependendEdgeSet as a Gale-Shapley algorithm?

From Help, the procedure StableMarriage was an element of the Combinatorica, but it is available in the built-in ...
3
votes
2answers
131 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 ...
7
votes
3answers
305 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 ...
12
votes
4answers
514 views
2
votes
1answer
47 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 ...
1
vote
0answers
45 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
1answer
53 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
1answer
123 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
3answers
294 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
1answer
47 views

Edge thickness in directed path graph doesn't respond

I have the following code to draw a lattice path in 3D: ...
1
vote
1answer
130 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 ...
5
votes
6answers
415 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 ...
1
vote
1answer
98 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 ...
0
votes
1answer
74 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},...
11
votes
8answers
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
1answer
90 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
1answer
84 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
2answers
79 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
6answers
401 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 ...
3
votes
4answers
286 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 ...
6
votes
3answers
636 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 ...
3
votes
3answers
165 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. ...
11
votes
4answers
553 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 ...
14
votes
4answers
756 views

Generating Linear Extensions of a Partial Order

Given a set $S$ and a partial order $\prec$ over $S$, I'm looking for a way to "efficiently" generate a list of linear extensions of $\prec$. Suppose the partial order is given by a ...
1
vote
0answers
37 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. ...
1
vote
1answer
85 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
4answers
106 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}, {-...
4
votes
2answers
280 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 ...
8
votes
3answers
992 views

Counting the number of a specific type of permutation

In the theory of cumulants of vector-valued random variables, the following types of formulas appear: \begin{equation} \theta^i \theta^{jk} [3] = \theta^i \theta^{jk} + \theta^j \theta^{ik} + \theta^k ...
7
votes
5answers
575 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
3answers
179 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
1answer
151 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 ...
13
votes
2answers
1k views

Better way to get Fisher Exact?

I want to perform a Pearson's $\chi^2$ test to analyse contingency tables; but because I have small numbers, it is recommended to perform instead what is called a Fisher's Exact Test. This requires ...
2
votes
4answers
152 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 ...
3
votes
2answers
78 views

Orbits of a set $X$ under the action of cyclic permutation $T$

Let $X$ be a set defined as $$X = \{\{\sigma_1, \dots, \sigma_L\} \;|\; \sigma_i = 0,\dots ,n-1\}.$$ Furthermore, let $T:X\longrightarrow X$ be a cyclic permutation $$ T\cdot\{\sigma_1, \dots, \...
3
votes
3answers
111 views
3
votes
2answers
255 views

How to check whether a string contains a certain number of consonants and vowels?

I am trying to check the answer of the following problem programmatically. A manual calculation by hand must be possible but it is not my question. Given a string ...
2
votes
2answers
98 views

Find all possible configurations of a finite dipole system

I have a system which is composed of the following blocks $$[-,+],[+,+],[+,-],[-,-]$$ I can compose a system of $n$ blocks with the only rule that the edges act as a dipole. for example $$[-,+][-,+][-,...

1
2 3 4 5
10