Questions tagged [combinatorics]

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

Filter by
Sorted by
Tagged with
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.) ...
3
votes
2answers
127 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
1answer
53 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 ...
7
votes
3answers
300 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
0answers
43 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
51 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
120 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
274 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: ...
5
votes
6answers
408 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
1answer
72 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
1answer
93 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
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
89 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
79 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
391 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
1answer
129 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
3answers
566 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
4answers
548 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
0answers
33 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
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. ...
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
104 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
4answers
283 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
2answers
270 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
5answers
573 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
177 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 ...
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
72 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, \...
6
votes
5answers
286 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. ...
3
votes
3answers
110 views

List manipulation: Find duplicates with respect to symmetry in sublists

I have the following list ...
2
votes
2answers
97 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 $$[-,+][-,+][-,...
12
votes
1answer
620 views

Programming a bishop's move on a grid

I am simplifying the question i need too work with, any advice on how to proceed for each step would be appreciated(no answers) I have a square grid of size a by b, inside the cell is an object that ...
1
vote
1answer
61 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 ...
1
vote
1answer
127 views

Randomsample without repetition [closed]

I'm looking for a simple way to generate random samples of lists of integers such that each time I sample I'm sure it chooses a new random sample. This is closely related to Picking random items out ...
4
votes
1answer
95 views

Compute all trees on a given label set

Given a set of labels {a_1,...,a_n} (with some labels possibly appearing multiple times) I would like to efficiently compute all trees with n leaves labelled {a_1,...,a_n} and 2n-2 nodes. This is ...
0
votes
0answers
41 views

Climbing/Descending the Multidimensional Integer Ladder

This is basically a follow-up to Climbing/Descending the Integer Ladder, but in multiple dimensions. It's basically just an index counting problem, but combinatoric blow-up makes it interesting. In ...
2
votes
2answers
75 views

Overlay Graph3D with Graphics, with aligned coordinates

I have a Graph3D object representing a 3D lattice path ...
4
votes
1answer
345 views

How to perform a reduced knapsack problem

I have a problem statement that seems to be a reduced version of the knapsack problem, but I don't know how do it in Mathematica. The problem is as follows: Given a set, S, of integers (e.g {a,b,c,...}...
3
votes
2answers
88 views

using DeleteCases with CoprimeQ

first let me show what I have working correctly f = Permutations[Range[5], {3}] Riffle[f, Apply[CoprimeQ, f, {1}]] now I would like to automate the deletion of a ...
8
votes
4answers
503 views

Climbing/Descending the Integer Ladder

A fun combinatoric puzzle that's popped up in my work that I think would be cute to have a Mathematica solution to, if anyone wants to give it a go. It's basically a ladder climbing/descending problem ...
2
votes
1answer
82 views

Number of partitions of an integer with a fixed number of parts

Is there an easy way in Mathematica to find the number of partitions of $n$ into $k$ parts? Or equivalently, the number of partitions of $n$ with largest part equal to $k$? I realize the function ...
1
vote
2answers
83 views

Solving 190 equations from a list of 2x20 elements [closed]

I have a list of 20 pairs of elements, say {{x1, y1}, {x2, y2}, ...}, and I want to solve the following equation for a constant c...
5
votes
1answer
152 views

Visualizing set partition lattice

There's a cool visualization of set of all partition over 4 elements ordered by refinement, which makes it a lattice. Can Mathematica be used to generate these kinds of visualizations automatically? ...
0
votes
1answer
84 views

From a bag of n balls, with c colours, and d draws count how many variations are possible? [closed]

First, the objective is not to use formulas for combinations, or permutations. The objective is to use loops(for, while, etc.) to make Mathematica count the number of possible variations/sequences of ...

1
2 3 4 5
9