Questions tagged [combinatorics]

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

Filter by
Sorted by
Tagged with
11
votes
4answers
493 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
26 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. ...
2
votes
3answers
108 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
77 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
99 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
250 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
243 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
549 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
169 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 ...
0
votes
0answers
69 views

How to solve this combinatorial problem correctly? [migrated]

Question: Ten different candies are given to three children A, B and C. each child has at ...
3
votes
1answer
143 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
150 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
67 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
4answers
204 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
103 views

List manipulation: Find duplicates with respect to symmetry in sublists

I have the following list ...
2
votes
2answers
93 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
612 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
51 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
95 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 ...
3
votes
1answer
83 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
39 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
70 views

Overlay Graph3D with Graphics, with aligned coordinates

I have a Graph3D object representing a 3D lattice path ...
4
votes
1answer
339 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
78 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
499 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
50 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
81 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...
4
votes
1answer
121 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
82 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 ...
4
votes
4answers
203 views

Generating all symmetric binary matrices of order up to 7?

I want to create all symmetric binary matrix with order up to 7. Can anybody help in creating this? I want to obtain the subset of all symmetric matrices, with all diagonal entries being zero.
9
votes
2answers
333 views

Solving a rotating combination lock puzzle

The following puzzle appears in The House of da Vinci II and I thought it might be interesting to tackle in Mathematica: There are numbers marked on four rotating cylinders. These numbers must add up ...
3
votes
1answer
66 views

Counting terms in recursive operation

Suppose $X$ is an algebra and $T :X\to X$ is linear function. Let $L:X\to X$ be a function satisfying the following property $$L(a \cdot b)= T(a)\cdot b + a \cdot T(b)+b\cdot T(a)+T(b)\cdot a\tag{*}$$...
4
votes
2answers
167 views

Non crossing set partitions

A set partition is noncrossing if whenever four elements $a<b<c<d$ are such that $a,c$ are in the same block and $b,d$ are in the same block then $a,b,c,d$ are all in the same block. Can I ...
2
votes
2answers
72 views

How to program combinatorics problems about randomly moving cards from $A$ to $B$ to $C$ to $A$?

I have a lot of problems with the following scenario, for example, Given 3 boxes $A$, $B$ and $C$. The box $A$ contains 2 identical cards $x$, 4 identical cards $y$ and 1 card $z$. The box $B$ ...
2
votes
1answer
96 views

How to find formula from a table?

I recently started using mathematica for simple tasks like simplifying etc. First of all let me say if this breaks any rules I apologize since I'm a novice in using this and I'll remove the question. ...
8
votes
2answers
367 views

How to remove any words containing two adjacent characters with different in both cases and letters?

I have a list of permutations of ABCabc and I want to remove any permutations with two adjacent characters with different in both cases (uppercase and lowercase) ...
7
votes
2answers
259 views

List of tuples without duplicates & repeated values [duplicate]

Given some number nand set of values vals, I want to obtain all the tuples/permutations of size ...
3
votes
2answers
168 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 ...
9
votes
2answers
331 views

Lozenge tilings

I am trying to produce these lozenge tilings as a way of encoding plane partitions. I need to produce something like: but am using demonstration code like this: ...
0
votes
3answers
87 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 ...
6
votes
4answers
235 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 ...
2
votes
0answers
86 views

Why Does Subsets[…,{n}] not Output a Packed List, Even Though it Doesn't Unpack?

Assume list is packed. I expect Subsets[] is a structural operation because it depends on the number of elements, not on what ...
1
vote
2answers
70 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 ...
7
votes
2answers
84 views

Finding the best-fitting subsets by frequencies of list item groupings

Suppose I have a list of groups: {{1,2,3,4}, {1,2}, {3,4}} In this example, 1 most commonly appears within a group that contains ...
4
votes
1answer
58 views

How to list all possible 3-tuples with entries of the 3 tuples from 2 different sets?

If there are two sets $A={1,2,3,4}$ and $B={5,6,7,8}$, how to construct list of all possible 3 tuples where the first two entries are any element from set $A$ and the 3rd entry is any element from set ...
1
vote
1answer
38 views

$q$-multinomial series

I have the following code, which produces a $q$-multinomial coefficient, but selected randomly according to a Poisson distribution. Consider a 3D lattice path selected uniformly at random from a ...
0
votes
1answer
45 views

Optimisation Problem over binomial coefficients

I have 4 variables. $A= l{nq\choose l} {n(1-q)\choose n(1-q)-np+l}$ $B=(np-l){nq\choose l} {n(1-q)\choose n(1-q)-np+l}$ $C=(nq-l){nq\choose l} {n(1-q)\choose n(1-q)-np+l}$ $D=(n(1-q)-np+l){nq\choose l}...
7
votes
5answers
282 views

Rewriting partitions using exponents

I'm looking for a way to re-express a partition given in full form, like $\{{2, 2, 1, 1}\}$, into the shortened form $\{2^2, 1^2\}$, i.e. given a partition with repeated entries, count the number of ...
0
votes
2answers
118 views

How to calculate and display circuits, closed paths, simple paths, cycles … of edges (with a specific length)

I'd like to know that how can I find circuit(basic), simple path, closed path of these edges: Example: ...
3
votes
2answers
177 views

Permutations with Repetition Symbol

I am trying to compute this formula in Mathematica: $$ a = \sum_{n=0}^A P_A^{A-n,n} $$ Where A can be any positive number The problem is that I am unable to find the symbol for permutations with ...

1
2 3 4 5
9