The tag has no usage guidance.

learn more… | top users | synonyms

27
votes
6answers
2k views

How to select minimal subsets?

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
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 ...
13
votes
5answers
3k views

Define a mathematical set

I have a terribly short question: Is there a way to define a pure mathematical set? I tried a bit of googling, but the word "set" has two meanings and the other one (as in setting) as by far more ...
11
votes
8answers
513 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
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 : ...
11
votes
10answers
762 views

Finding neighbors from list

Say you are given the following list: list={{3, 2, 1}, {3, 4, 2}, {2, 4, 1}, {1, 4, 3}}; Two numbers $x,y$, not necessarily distinct, are neighbors if one of the ...
11
votes
1answer
261 views

How to find longest monotonic sequence?

I have a list, for example list = {2, 1, 3, 5, 4, 6} How to find longest ascending sequence of this list? There are two meanings of this question: Find the ...
10
votes
5answers
419 views

How to randomly select subsets

I have a list of around 300 elements. I want to sample subsets of length 25 such that my samples are all distinct. My first inclination was to use something like ...
10
votes
4answers
339 views

Complement of multisets

Given lists $a$ and $b$, which represent multisets, how can I compute the complement $a\setminus b$? I'd like to construct a function xunion that returns the ...
10
votes
3answers
365 views

Patternmatching sets

How to match set-patterns against sets? A set (in the mathematical sense) is a list of elements without repetition and order of elements does not matter. For example, we have a pattern set ...
9
votes
6answers
427 views

Performing Computations on Sets

I would like to find a permutation of $\quad S=\{\frac{1}{10}, \frac{1}{2}, \frac{4}{7}, \frac{3}{5}, \frac{2}{3} \}\quad$ that maximizes the sum of theses elements raised to unique powers: ...
8
votes
3answers
707 views

how to efficiently apply function to all pairs of a set (and collect the results)

To build a graph, I need to apply a function f[a_, b_] to all pairs of a list (3500 elements). The function itself returns a link ...
7
votes
1answer
250 views

How to get all possible orderings (equal ranks allowed) for given set of $N$ objects?

Hope there is a solution besides the tedious generation of nested loops. (Trying to avoid reinventing the wheel.) Here is an example with $N = 3$ objects. There are $13$ needed orderings (first ...
6
votes
3answers
698 views

Subsets of a list

Consider the following demand of products for the next four months. data={1,20,3,40}; I could produce the whole demand in the first months, leading to the ...
5
votes
1answer
114 views

Amount of k-sized not-duplicated subsets of subsets of pair with disitinct sorted integers

I have a list, L, of this kind ($n\in \mathbb{N}$): L=Sort[RandomSample[Subsets[Range[n],{2}],RandomInteger[{1,Binomial[n,2]}]]] S contains any k-sized subset ...
4
votes
3answers
263 views

Counting number of inversions

Is there an inbuilt method to find the number of inversions in a set of numbers? I found Inversions in Combinatorica but when I ...
4
votes
2answers
130 views

How to constrain the generation of all possible orderings?

Here is code from Simon Woods' answer for getting all possible weak (equal ranks allowed) orderings for $N=3$ objects: ...
4
votes
1answer
172 views

List all possible elements of a set

I have this two sets: $A = \{\emptyset, \{\emptyset\}, \{\{\emptyset\}, \emptyset\}\}$ $B = \{\{x, \{x, y\}\} | x \in A, y \in A\}$ Now I want to list all possible elements that are in $B$. How do ...
4
votes
2answers
726 views

Exact cover solution

Is it possible to get a exact cover solution(s) and/or number of possible solutions in Mathematica?
3
votes
7answers
382 views

Concise way to generate multiset lists

I wrote the following to generate a multiset with the same number of items over a fixed range: ConstantArray[#, 3]& /@ Range[9] // Flatten ...
3
votes
0answers
69 views

Listing all combinations produced by picking one element from each of several sets [duplicate]

I have a problem like this, I am given the following sets {a,b,c}, {d,e,f}, {h,i,j}. I want to pick one element from each set, and output a list of all the ...
2
votes
2answers
362 views

Combining lists with common elements efficiently [duplicate]

Possible Duplicate: Computing the equivalence classes of the symmetric transitive closure of a relation I am required to process sets consisting of 2-element subsets of integers by ...
2
votes
1answer
153 views

Intersection does not take list of lists

The function Intersection takes a number of lists (sets) and finds their intersection. However, the precise input is ...
1
vote
3answers
152 views

How to write equal subset

I have a unique set S={1,1,3,3,3} but from this unique set I can create many combinations like {1,3,3,3,1}, {3,3,1,3,1}, ... I ...
1
vote
2answers
1k views

Plot 3D set (or a domain of three-variable function)

is there any way to plot a "3D set" of points subject to certain rules? For example, my task is to find maximum of some function of three variables which have to meet some conditions. Of course I ...
1
vote
2answers
141 views

How do I do the Minkowski sum of two sets?

I have 2 sets, $X$ and $Y$. How do I find the Minkowski sum of these sets?
1
vote
1answer
125 views

Set theoretic operations on sets of real numbers

I have two pieces of code that produce a bunch of real numbers, say $A$ and $B$ respectively. (It is not relevant to the question, but $A$ consists of eigenvalues of the Hamiltonian of some physical ...
0
votes
4answers
44 views

How to multy-Set a group of lists?

I have a group of lists, for example: lists = RandomInteger[10, {100, 2}] {{6, 7}, {7, 4}, {3, 3}, ....} Now, I want to ...
0
votes
1answer
59 views

Mining for matching elements of sets with equal divisors

This problem is extrapolated from a problem that was solved on how to manipulate lists of set outputs as a union ( Equation Autogeneration ), where the concern now is how to mine for (or attain from ...
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} ...
0
votes
0answers
42 views

Addition of all elements of two sets with each other [duplicate]

Let $S_1=\{a_1,a_2,\ldots,a_m\}$ and $S_2=\{b_1,b_2,\ldots,b_n\}$ be two sets. I want to list all $a_i+b_j$ for each $1\leq i\leq m$ and $1\leq j\leq n$ in a set. Is there a commend in mathematica for ...
0
votes
0answers
235 views

Putting set elements into venn diagram

My problem has two parts. Before that I have two Lists/Sets. It suppose to be created them by two initial strings. In the first part, I need to show sets' elements in venn diagram. I can create venn ...