Skip to main content

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
0 answers
20 views

How many unique count sets can be made from n variables? [migrated]

If I have n letters of the alphabet, how many unique sets of the letters can I make, where each unique set contains 1 to n letters? This is basically factorial arithmetic with the caveat that the set ...
David Wanjiru's user avatar
5 votes
1 answer
149 views

Find permutation that satisfies conditions

Suppose you what to find a permutation of integers {1, 2, ..., 13} that satisfy some rules. Rules can be found in variable rules....
azerbajdzan's user avatar
  • 18.8k
0 votes
0 answers
35 views

Writing list as disjoint union of input lists

Suppose I have two lists, s1={{1,2,3},{3,1,2},{3,1,2},{2,3,1},{3,2,1},{1,3,2}} and ...
Tanatofobico's user avatar
12 votes
3 answers
450 views

Visualizing diagrams needed to compute $\operatorname{Tr}(A^3 (A^T)^3)$

I'm looking for help getting Mathematica code to construct diagrammatic expressions like the following, obtained by River Li as a way to compute $\operatorname{Tr}(A^2 (A^T)^2)$ for $d\times d$ matrix ...
Yaroslav Bulatov's user avatar
4 votes
3 answers
115 views

How can I construct an equivalence relation in the form of a 0-1 matrix from a set partition?

I have a partition of a set {1, 2, ..., n}. I would like to construct the equivalence relation that corresponds to the set partition in the form of an $n \times n$ ...
Geoffrey Critzer's user avatar
2 votes
3 answers
102 views

I'm tired trying to get subsets

t={{a,b},{},{},{},{a},{a,b},{},{a,b,c},{},{b}} s={{},{a,b,c},{a,b}} Thread[Subset[t,s]] I'm tired of trying to calculate: {a,b} [which is the intersection [{a,b}, {...
Alyasaa Jasim's user avatar
7 votes
3 answers
242 views

Insert abs into two adjacent terms of the expression

Give an expression expr = a - b - c - d - e; I need to add abs between adjacent letters, the desired result is ...
vector's user avatar
  • 201
0 votes
0 answers
26 views

Nonintersecting lattice paths with given start and endpoints

A prominent topic in combinatorics is the enumeration of nonintersecting lattice paths subject to certain conditions. My goal is fairly simple: given starting points $(1,1), (2,1), \ldots, (k,1)$ and ...
WQE's user avatar
  • 65
0 votes
1 answer
151 views

PartitionsP for non-integer arguments [closed]

Is there a reason why the function PartitionsP[] does not return anything for non-integer arguments, although there is a way to calculate using Rademacher’s ‘exact’ ...
ftel's user avatar
  • 3
2 votes
1 answer
109 views

Efficiently Finding Weighted Integer Partitions

Suppose we have some list of natural numbers $\{ 1, 2, \dots, N \}$ and each natural number $i$ has a 'weight' $w_i$. I would like to generate the all the integer partitions which satisfy the ...
MathPhysPlague's user avatar
2 votes
0 answers
47 views

NextSetPartition

I'm looking for a function similar to the one in the question below, but for the more general problem of set partitions without restricting the set size. NextKSizePartition, or how to partition a set ...
David's user avatar
  • 159
2 votes
1 answer
158 views

How to implement the formula for the number of undirected $k$-cycles in a graph $G$?

This Wolfram MathWorld page said that, Giscard et al. "A General Purpose Algorithm for Counting Simple Cycles and Simple Paths of Any Length." 16 Dec 2016. gave the formula for the number of ...
138 Aspen's user avatar
  • 1,393
3 votes
2 answers
121 views

Generating semistandard Young tableaux in Mathematica?

The Combinatorica package is able to generate standard Young tableau via the command Tableaux. But is there any functionality for generating semistandard Young ...
WQE's user avatar
  • 65
0 votes
0 answers
50 views

Convex hull aborts kernels (reproducible)

11.0.0 for Microsoft Windows (64-bit) (July 28, 2016) ReleaseID -> "11.0.0.0 (5570737, 2016072801) a set of 32 points : ...
Wouter's user avatar
  • 1,343
8 votes
2 answers
635 views

Better code for Ramsey partitions

Ramsey partitions for parameters $a$ and $b$ are certain integer partition of $a+b$ developed by McAvaney, Robertson, and Webb (Combinatorica 1992) for applications in fair division problems where two ...
Brian Hopkins's user avatar
2 votes
3 answers
259 views

How can I optimise the creation of subsets?

I have a list of 21 elements from which I have obtained possible combinations of minimum 3 and up to 10 elements using the Subsets function as follows: ...
LNah's user avatar
  • 189
0 votes
1 answer
51 views

Using UnrankPermutation with Maximize

I want to try and use Maximize with UnrankPermutation to find Costas Arrays (or as close as possible) for a given length l with first two elements l, 1. A permutation array that maximizes the number ...
Eriek's user avatar
  • 827
0 votes
2 answers
88 views

How to make a function that outputs a mesh region object or some other geometric object that represents a cake number?

The lazy caterer's sequence, more formally known as the central polygonal numbers, describes the maximum number of pieces of a disk (a pancake or pizza is usually used to describe the situation) that ...
Peter Burbery's user avatar
9 votes
2 answers
528 views

Drawing Delannoy paths

I want to take the code for a Wolfram Demonstration for a Delannoy number and make a function that can return a list of Delannoy plots. The code is available from the download link. The demonstration ...
Peter Burbery's user avatar
11 votes
2 answers
455 views

Can you give a faster implementation with Mathematica for these q-analog functions?

Now(2023), Mathematica has some QFunctions for q-anlaog. See Official Documentation. e.g.: QPochhammer QFactorial ...
138 Aspen's user avatar
  • 1,393
2 votes
2 answers
297 views

How to generate a list of Langford pairings?

I am wondering how to make a function that makes a list of Langford pairings named LangfordPairings that takes an integer n as output and if Langford pairings exist for that number, they output the ...
Peter Burbery's user avatar
3 votes
1 answer
159 views

How to make a function that returns all super distinct partitions?

I am working on distinct partitions. I recently created a function StrictIntegerPartitions. This is from the book Integer Partitions by George E. Andrews at Pennsylvania State University and Kimmo ...
Peter Burbery's user avatar
8 votes
4 answers
734 views

Design a function that gives all strict partitions of an integer

A strict partition of an integer has all distinct parts. There are no duplicates like 1 in {5,3,1,1} for 10. All the parts are unique. Sylvester created a bijection between the partitions of an ...
Peter Burbery's user avatar
4 votes
3 answers
174 views

Generating all complete pair-wise listing of a starting list

It might well turn out that this question has already been asked; my problem is that I don't know how to describe it succinctly enough to search. I have a list of 12 elements. If I take 2 elements ...
CrimsonDark's user avatar
1 vote
0 answers
41 views

Sequence reconstruction from ordered subsamples

Given a sequence (we'll assume of integers) like seq = {1, 0, 0, 1, 2, 0, 1} I can take a random permutation ...
b3m2a1's user avatar
  • 46.9k
0 votes
1 answer
141 views

How to calculate the number of partial derangements of a multiset in Mathematica?

I have found some helpful information on enumerating derangements at https://math.stackexchange.com/questions/4645664/the-number-of-partial-derangements-of-a-52-card-deck-ignoring-suits, https://sites....
Peter Burbery's user avatar
1 vote
1 answer
128 views

Fixing code for a combinatorics problem

The problem I am solving is: Determine all possible values of positive integer $n$, such that there are $n$ different $3$-element subsets $A_1,A_2,...,A_n$ of the set $\{1,2,...,n\}$, with $|A_i \cap ...
matrix42's user avatar
  • 7,108
1 vote
1 answer
255 views

Enumeration of a sequence involving closure operators

Let us call a collection $\mathcal{F} \subseteq \mathcal{P}(X)$ special if it satisfies the following two conditions: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$, it holds that $U \...
user227351's user avatar
8 votes
2 answers
573 views

How can I correctly use LazySubsets from Wolfram's Lazy package?

I know that Subsets[list] gives the power set of list and Subsets[list,{k}] gives all subsets containing exactly $k$ elements. ...
licheng's user avatar
  • 2,039
2 votes
1 answer
229 views

Finding induced subgraphs that are also trees

Given a graph $G$ with $n$ vertices, I need to find a subgraph consisting of $m$ vertices $\{v_1,\ldots,v_m\}$, and the induced subgraph of this subgraph should also be a tree. For example, suppose $G$...
Dotman's user avatar
  • 456
1 vote
1 answer
71 views

Additive graphs code

For $n\geq 1$ the fibonacci sum graph on the set $[n]=\{1,2,\ldots,n\}$ denoted by $G_n$, is the graph with vertex set $[n]$ and edge set $\{uv, u+v=F_i, \text{for some}\quad i\}$. I wrote the ...
d.y's user avatar
  • 143
2 votes
0 answers
112 views

Is FindShortestTour really exact? [closed]

I have read online that the FindShortestTour function on Mathematica uses the Concorde TSP solver, which is meant to provide exact solutions. However, I have been playing with this problem on my own, ...
slithy_tove's user avatar
4 votes
2 answers
244 views

How to find a Hamiltonian walk of a graph?

Edit: After John L.'s reminder, there is a specific term, namely "Hamiltonian walk" for my previous question. See How can we find a shortest closed walk passing through all vertices?. So I ...
licheng's user avatar
  • 2,039
5 votes
4 answers
293 views

Efficient generation of n-bit base-m Gray code with adjacent bit changes

How can I generate n-bit base-m Gray code in Mathematica, where only 1 bit changes at a time and all possibilities are covered? I have been hitting my head against a metaphorical wall for a few hours ...
More Senne's user avatar
6 votes
3 answers
289 views

Plot diagonal lattice path

I'd like to plot lattice paths like RUURUD where R is a step to the right, U is a step above ...
sankiago's user avatar
1 vote
1 answer
207 views

Arrange 1-n^2 in n×n grid satisfy products of rows equal to products columns

For which $n\in\mathbb{N}$ is it possible to arrange $\{1,…,n^2\}$ in an $n\times n$ grid so that the set of products of columns equals the set of products of rows? I can find solution for $3\times 3$ ...
expression's user avatar
  • 5,652
4 votes
0 answers
78 views

Can FindMinimumCostFlow be trusted?

So, I recently began to use graphs algorithms in Mathematica notebooks to solve an unbalanced assignment problem. After running the algorithm, I wanted to check that the total flow was equal to the ...
WaterFox's user avatar
  • 185
1 vote
2 answers
127 views

Delete the subsets containing the same $2$ integers present in other subsets

From my previous question, if I consider a list like this: $\{$$\{$$\{$$1,2,3$$\}$,$\{$$4,5,6$$\}$$\}$, $\{$$\{$$1,2,4$$\}$,$\{$$3,5,6$$\}$$\}$, $\{$$\{$$1,2,5$$\}$,$\{$$3,4,6$$\}$$\}$, $\{$$\{$$1,2,6$...
user967210's user avatar
6 votes
4 answers
302 views

Distribute arguments over a function in all ordered combinations

I'm looking for a function that can do this ...
Albercoc's user avatar
  • 998
4 votes
1 answer
164 views

How to generate 3-subsets that satisfy certain conditions without post-filtering?

Edits: In fact it is a set partition problem. I have a set as follows: ...
licheng's user avatar
  • 2,039
7 votes
3 answers
244 views

Permutations with subsets not containing the same elements

I would like to define a function of two integer variables $ \{n, k\} $, with $ k | n $, that would print all the possible permutations of the first $ n$ positive integers, such that the subsets of $ ...
user967210's user avatar
2 votes
1 answer
108 views

Find all ways to split a list into k sublists (of different length)

I would like to write an efficient code for splitting a set into k disjoint subsets, whose union would be the input set. The input set is represented by sorted lists with no repetitions, and the ...
wedelfach's user avatar
6 votes
1 answer
168 views

Issues with FindPlanarColoring

I tried to use FindPlanarColoring on the following planar graph: ...
A. Kato's user avatar
  • 406
3 votes
1 answer
92 views

Generating all $k$ combinations from $n$ objects [closed]

Suppose I have $n$ numbers $\{1,2,\cdots,n\}$, is there a very quick way of generating $k$-combinations using Mathematica?
Apocalypse's user avatar
0 votes
1 answer
123 views

Counting number of (non distinct) integer partitions into k

I want to count and generate the number of non distinct integer partitions into k. I know that IntegerPartitions[n,{k}] returns the partitions of integer n into k. E.g. IntegerPartitions[4, {2}] ...
00123456's user avatar
0 votes
0 answers
46 views

Arranging 4 identical items in 7 spots [closed]

There are 4 unique items, for the sake of the example call them balls. Each ball is exactly the same, and we need to see how many different ways those 4 balls can fit in those 7 slots. I am not sure ...
Jack G's user avatar
  • 1
3 votes
1 answer
262 views

Enumeration of a certain sequence III

Let’s call a collection $\mathcal{F} \subseteq \mathcal{P}(X)$ satisfying: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$ it holds that $U \cap V \in \mathcal{F}$. special. We can ...
user227351's user avatar
4 votes
2 answers
197 views

Mathematica can't find Minimum sum under integer constrains

I'm trying to verify a solution to a simple probability problem using Mathematica. Here's the problem: A drawer contains red socks and black socks. When two socks are drawn at random, the probability ...
mikemykhaylov's user avatar
3 votes
4 answers
320 views

Verifying a combination problem using subsets

The question is shown below. The handwritten answer is one of the methods of the mark scheme. This method "seemed" ok, but we are not so convinced about the Total of 140 ways. Also, there is ...
CasperYC's user avatar
  • 1,632
4 votes
3 answers
245 views

How to solve combination problem with mathematica?

How to find the smallest n s.t: $$\binom{2500-n}{50}/\binom{2500}{50} < 0.5$$
omg's user avatar
  • 163

1
2 3 4 5
11