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

learn more… | top users | synonyms

5
votes
3answers
73 views

Conditional subset generation

I am trying to accomplish the following task: Given a list of coordinates of n points in the plane, I need to find subsets of all points that share the same ...
0
votes
1answer
403 views

Generating all “from n choose k” configurations of a simple list [duplicate]

Suppose that I have a 1-D list called myList. Here's an example: myList = {"A", "B", "C", "D"}; I want to write (or find ...
0
votes
2answers
58 views

Generating polynomials with conditions on coefficients

I want to define polynomials with coefficients given in some range. Namely, let $p$ be a prime number and $n$ be a positive integer. For all positive integer $k\leq n$ I want to generate all ...
6
votes
1answer
267 views

Young Tableaux Miscellanea

I have a problem which is mostly neatly described by using Young Tableaux. Mathematica seems to have these Tableaux built in, except that the Tableaux function is ...
5
votes
1answer
140 views

Alternative to Subsets to generate k-combinations

I need to generare a huge number of k-combinations for a quite big set of numbers (more than 100), so I would avoid Subsets because it requires too much memory (it generates all subsets at once). I ...
12
votes
1answer
549 views

Lazy lists of Tuples and Subsets

I'm trying to build a lazy list that evaluates the n'th m-tuple or subset of a given list using Mathematicas ordering without calculating all the Tuples. The purpose is to allow for example the ...
5
votes
1answer
98 views

Efficiently find all connected subgraphs

Is there a way to generate all the connected subgraphs of a graph in mathematica without going through all the subsets of the nodes and checking if the subgraph is connected (which will be ...
9
votes
2answers
185 views

Checking if one partition is a subpartition of another

Say I've got two partitions of a list (not necessarily containing numbers, and not necessarily distinct), and I want to check that one is a subpartition of the other. Let's look at some examples: ...
5
votes
2answers
89 views

How expand Binomial[n, k] for k >= 6? [closed]

Binomial[n, k] is converted to a polynomial only for k less than 6. ...
6
votes
1answer
206 views

Find exponential generating function from the first few terms

The function FindGeneratingFunction computes the ordinary generating function of a sequence, given a sufficient number of initial terms. I have two questions in ...
3
votes
3answers
178 views

Permutations on elements a>b && b>c

A={1, 2, 3, 4, 5} Permutations[A, {3}] I need to print all permutations where the first number is bigger than the second and the second number is bigger than the ...
2
votes
2answers
79 views

Permutations and recurrence equation

First problem: I need to show all Permutations with length 4 of this elements {x, y, z, w, t} but with this condition: the element z mustn't be after element t. I ...
2
votes
1answer
154 views

Using IntegerPartitions for distinct integers

What I would like to do is to find a way to test how many ways m distinct integers from the set {1,..., n} where ...
1
vote
1answer
33 views

series combinations

is there any possibility of displaying all possible series of the form: "1+/-2^2+/-3^2+/-...+/-n^2", where one can choose the sign before the each term and knows the numbers of the terms in the ...
6
votes
2answers
175 views

Subsets or Outer?

How do I generate all possible subsets of a list of positive numbers (with at least 1 of them), given that each of these positive numbers subvariates itself on its input value and its multiplicative ...
5
votes
2answers
146 views

Combinatorics: Placed errors

Consider a vector of length n where each element can take one of the values U, X, ...
3
votes
2answers
169 views

Partition a range of integers into triples

Some time ago, I was asked to look at a simple to formulate puzzle. Consider the list of numbers {1,2, ..., 33}. Try to split this list in 11 triples, such that in ...
1
vote
1answer
76 views

Computational Complexity of HypergeometricPFQ

What is the computational complexity of HypergeometricPFQ? I got a result of a product of a multinomial and HypergeometricPFQ and I was wondering if that would be considered a closed form solution ...
5
votes
2answers
202 views

How to define even permutations correctly?

I define even permutations as following, but there may be some error. I use it in two different way and get different output. ...
2
votes
2answers
72 views

Arrangements (?) from permutations of rows in a triangle, is there a simpler way to program this?

I am generally confused about integer valued polynomials, and how to count them. Trying to learn the subject I started by listing permutations of the rows in a lower triangular table: $$\displaystyle ...
29
votes
4answers
3k views

Looking for “Longest Common Substring” solution

I'm looking for robust code to solve the "Longest Common Substring" problem: Find the longest string (or strings) that is a substring (or are substrings) of two or more strings. I can just code it ...
-1
votes
1answer
51 views

Create a list of all functions given a set of arguments

I'm trying to examine some patterns on the permutation of elements in finite element functions. I'd like to create a list of all functions (256 of them) on ...
14
votes
2answers
502 views

Generating Gelfand-Tsetlin patterns

I am doing some research on some combinatorial object called GT-patterns. They are generated from three parts of data. Two integer, partitions (sequences of weakly decreasing numbers), $\lambda = ...
11
votes
5answers
635 views

Probability problem — Rube Goldberg solution?

A user posted this question on StackOverflow which was closed as off topic: 3 people are playing a game with a standard 52 card deck. Each player is given 2 cards each, possible cards and their ...
10
votes
1answer
288 views

Is there a function to generate a minimal clique cover?

This is a graph problem known as the "Clique Edge Cover" or "Intersection Number" problem, and the goal is to find, from a given graph like $E=\{\{a,b\},\{a,c\},\{b,c\},\{b,d\},\{c,d\}\}$ and ...
16
votes
7answers
605 views

Enumerating tuples from a larger space such that all pairs of values are present at least once

I am trying to write a function that will accept a list of N lists and returns a list of N-tuples that represent all pairs of values from the original N lists at least once. To illustrate with an ...
4
votes
2answers
167 views

How to check whether elements of a list meet a condition without generating the whole list first?

I have to find the number of elements satisfying a given condition from the set: Tuples[Tuples[Tuples[{0,1},n],n],m] The condition for $n=3,m=3$ is: ...
6
votes
3answers
330 views

Finding all sublists or substrings of a given list/string

Given a list or string, how do I get a list of all (contiguous) sublists/substrings? The order is not important. Example for lists: ...
11
votes
7answers
2k views

Combination and Permutation

How could I obtain the list of all the groups of 5 numbers taken from Range[12] such that the 2 lists have an empty intersection : ...
24
votes
7answers
1k views

How to Derive Tuples Without Replacement

Given a couple of lists like a={1,2,3,4,6} and b={2,3,4,6,9} I can use the built-in Mathematica symbol ...
15
votes
3answers
192 views

Partitioning with constraints on subsets

Given the following data: constraints = {{11, 2}, {11, 3}, {11, 4}, {11, 6}, {11, 9}, {1, 6}, {5, 6}, {2, 5}}; weights = {3, 7, 3, 2, 4, 2, 2, 2, 3, 2, 1}; I ...
0
votes
2answers
109 views

Finding permuations in a specific order

I would like to find the following permutations, but need an elegant way of computing it. Ideally I would like to have a variable determine the highest number in the last element and find all ...
4
votes
4answers
231 views

Partition list into a given number of sub-lists

I'm having quite a hard time with the following. I would like to partition a list into a list of sub-lists, in such a way that the number n of sub-lists is fixed. ...
1
vote
0answers
84 views

Is there a minor bug in Neal Alexander's TopologicalSortAll[]?

There is an amazing answer to this question: All possible topological orderings of a graph By Neal Alexander. However, as user "dark blue" (I am not this user) notes: ...
3
votes
2answers
121 views

Can I generate matrices with a constraint?

Say I want a way to generate matrices with the following properties, All non-diagonal elements are either $0,1,-1$ The diagonals are either $k$ or $k+1$ for some $k \in \mathbb{Z}^+$ for some $k$ ...
14
votes
5answers
744 views

Getting number of binary digits combinations without “forbidden” patterns

I need to get the number of all combinations of binary digits in an 8-digit binary number, but not including those that follow some "forbidden" patterns like these: ...
2
votes
1answer
116 views

defining Associated Stirling numbers of the Second Kind

First, I'm new to Mathematica. Spent my undergraduate programming with Maple and my computer crashed and I lost it. Fortunately, my university offers free Mathematica downloads to students, so here ...
6
votes
1answer
178 views

Random filling of L-length line with l-length segments

I have discrete L-length line filled randomly with 2-length segments so its cover line with gaps 0 or 1. So we can describe cover configuration as sequence of gaps such as {0,0,1,0,1}. How I can ...
13
votes
5answers
680 views

Permutations[Range[12]] produces an error instead of a list

This input: Permutations[Range[12]] Results in this (error) output: ...
3
votes
2answers
225 views

Constructing a list of Cartesian coordinates of the Icosahedron

I’m learning Mathematica and I need the coordinates of the Icosahedron vertices. This is my attempt at writing a program for it. The vertex coordinates are simply all cyclic permutations and ...
1
vote
2answers
173 views

Permutations with restrictions

I have a problem that can be modeled as: there are 8 boxes in total, and 60 different items. I want to put all items into boxes (all of them can be put into a single box). Now I want to find: 1) ...
4
votes
2answers
1k views

What function returns all possible permutations with repeating list elements?

Let's say I want to find a sample space of such experiment: There are three exits from the box: Left (L), right (R) and front (F). Three mice have been put in that box. Find the sample space of an ...
6
votes
1answer
531 views

Finding all length-n words on an alphabet that have a specified number of each letter

For example, I might want to generate all length n=6 words on the alphabet {A, B, C} that have one ...
0
votes
1answer
142 views

Inclusion-Exclusion Principle Implementation

I would like to know how I can write a Mathematica code for the Inclusion–exclusion principle. The formulas governing it are: $ P(\bigcup_{i=1}^n A_i)=\sum_{k=1}^n (-1)^{k-1} ...
1
vote
2answers
93 views

Numbering of cases implied by a subset of Boolean vectors

In the course of a programming problem I stumbled upon the following sub-problem. Given an arbitrary, but fixed, number of Boolean variables, I would like to be able to pick a subset of the ...
1
vote
0answers
136 views

How to sequentially select, from a large set of tuples (of matrices), those with a certain property

I'm interested in finding a computationally efficient way for selecting all tuples of matrices which have a certain property. The property I'm interested in is that I want the column sum, of f[the ...
4
votes
2answers
147 views

How to obtain all the distinct De Bruijn sequences?

In combinatorial mathematics, a $k$-ary De Bruijn sequence $B(k, n)$ of order $n$ is a cyclic sequence of a given alphabet $A$ with size $k$ for which every possible subsequence of length $n$ in $A$ ...
2
votes
2answers
332 views

Making a flag with six vertical stripes

A flag is to be made with six vertical stripes by using colours yellow, blue, green and red in such a way that no two adjacent stripes should have the same colour. In how many ways is this possible? ...
4
votes
1answer
125 views

The algorithm of ListGraphs[n,m]

I'm not sure if this is a Mathematica problem, math problem or a CS problem, so if this is off-topic please transfer it. In the package Combinatorica there is a ...
2
votes
1answer
105 views

Symbolic multiplicative partitions

Let $p_n\#\equiv\prod_{k=1}^{n}p_k$ (primorial): p[n_] := Times @@ Prime[Range[n]] then the multiplicative partitions of $p_{1,2,3,4}\#$ are $$ \{\{2\}\},$$$$ ...