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

learn more… | top users | synonyms

21
votes
1answer
380 views
+100

Efficient lazy weak compositions

In Mathematica all weak k-compositions of integer n can be generated using permutations of integer partitions: ...
4
votes
0answers
121 views

Visualising a 1-(50,15,15) design

The problem I have is the visualisation of a $1-(50,15,15)$ design. That is a set of $50$ points and $50$ blocks (lines), so that each point is on $15$ lines, and each line contains $15$ points. My ...
6
votes
3answers
124 views

generating integer partitions

Mathematica can generate integer partitions of an integer $N$. For example, IntegerPartitions[4] quickly gives ...
2
votes
1answer
111 views

Need Help Writing code to find Capparelli Partitions

I am trying to add multiple criterion to IntegerPartitions[n] so that it sorts only partitions that fit the criterion. It creates a list of list of numbers in ...
17
votes
3answers
443 views

Improving speed of code computing number of nonrepeating partitions

I need to answer the following for a number of parameters: How many ways can the integer $k$ be written as a sum of $n$ different integers ranging from $1$ to $m$? My initial attempt was the ...
0
votes
0answers
43 views

Hook Length Formula and Ferrer's Diagram

So, I am new to using Mathematica, and trying to write some code that needs to use hook length of each cell in Ferrer's diagram of a partition. I first thought of using for loops to manually count ...
0
votes
0answers
38 views

How to get partial results from Subsets[]? [duplicate]

Oftentimes I am searching for the first item in a sequence that satisfies some property. For example, consider the subsets of prime numbers whose total is prime. To start generate them, we could ...
9
votes
5answers
256 views

Find all the possible ways of partitioning a list into a set of pairs of element

I have a list {x1,...,xN} where N is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the ...
5
votes
3answers
84 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
2answers
68 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 ...
7
votes
1answer
282 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 ...
5
votes
2answers
103 views

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

Binomial[n, k] is converted to a polynomial only for k less than 6. ...
5
votes
1answer
131 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 ...
6
votes
1answer
230 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
189 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
80 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 ...
1
vote
1answer
41 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
181 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
147 views

Combinatorics: Placed errors

Consider a vector of length n where each element can take one of the values U, X, ...
2
votes
2answers
74 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 ...
1
vote
1answer
80 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 ...
-1
votes
1answer
52 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 ...
12
votes
2answers
458 views

What is the fastest way to get the nth distinct permutation of a list?

What is the fastest way to write a function nthPermutation[xs_List, n_Integer] which is equivalent to Permutations[xs][[n]] but ...
9
votes
2answers
197 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: ...
4
votes
2answers
182 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
374 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: ...
4
votes
2answers
190 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 ...
15
votes
3answers
213 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
114 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 ...
1
vote
0answers
88 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: ...
4
votes
4answers
263 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. ...
3
votes
2answers
123 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$ ...
16
votes
7answers
628 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 ...
2
votes
1answer
130 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 ...
3
votes
2answers
233 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 ...
5
votes
2answers
207 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. ...
0
votes
1answer
154 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
0answers
139 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
157 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$ ...
4
votes
1answer
127 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
2answers
351 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? ...
1
vote
2answers
94 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 ...
3
votes
2answers
126 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\}\},$$$$ ...
2
votes
1answer
144 views

How to compute the `Automorphisms` of graphs with multiple edges?

I try to compute the Automorphisms of graphs with multiple edges from its AdjacencyMatrix but failed. The following code shows ...
0
votes
1answer
62 views

How should my data be formatted for use with BetweennessCentrality?

A few weeks ago I asked this question. I am trying to upload my data which is an adjacency list for an undirected, unweighed graph and find the betweenness centrality. At the time I tried to use the ...
0
votes
1answer
441 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
1answer
191 views

How do I upload a graph as an adjacency list and find the betweenness centrality?

I have an undirected simple graph in a .txt file formatted as an adjacency list like this: 100 200 200 300 300 400 500 600 700 800 900 ... Every number is a node ...
6
votes
2answers
300 views

Binomial[-1,-1]

According to various sources e.g. http://www.proofwiki.org/wiki/Definition:Binomial_Coefficient and Wolfram themselves http://functions.wolfram.com/GammaBetaErf/Binomial/02/ , the binomial ...
4
votes
1answer
127 views

Challenge: Creating Compilable Permutations Function

As Mathematica's implemented Permutations function is not compilable I tried to write my very own Permutations implementation, called ...
1
vote
2answers
237 views

Mathematica can't minimize a function

Mathematica seems not to be able to minimize this univariate function over integer arguments, $r>2, r \in \mathbb{Z}$. ...