Skip to main content

Questions tagged [subset]

Questions on the usage of the Subsets command and related functionalities (Tuples, Permutations etc.), and on how to implement more efficient algorithms.

Filter by
Sorted by
Tagged with
2 votes
2 answers
65 views

How to retrieve the index of a subset in Subsets[list,nspec,{s}]?

Subsets[Range[2000], {4}, {n}] would give the $s^{th}$ subset of the Subsets[Range[2000], {4}]. For example, ...
internet's user avatar
  • 793
2 votes
1 answer
72 views

Find disjoint subsets and their union is {1...9}

I have such a list sets = Select[IntegerDigits /@ (Range[Floor@Sqrt@987654321]^2), DuplicateFreeQ@# && FreeQ[#, 0] &] I want to pick all subsets of ...
vector's user avatar
  • 201
2 votes
1 answer
45 views

How to quickly join in the following way? [duplicate]

Consider the following table: tab = RandomReal[{0, 1}, {10, 3}]; subsets=Subsets[tab, {2}]; How to quickly reduce subsets to a ...
John Taylor's user avatar
  • 5,827
6 votes
2 answers
232 views

How to quickly join in the following way?

Consider the following table: tab = RandomReal[{0, 1}, {10, 3}]; subsets=Subsets[tab, {2}]; How to quickly reduce subsets to a ...
John Taylor's user avatar
  • 5,827
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
0 votes
1 answer
84 views

Generating a list of unions from subsets

I have ...
Alyasaa Jasim's user avatar
0 votes
1 answer
105 views

Generating the union of possible subsets

I want to calculate the union of possible subsets within each set of the family of sets. I use the following code: ...
Alyasaa Jasim's user avatar
6 votes
6 answers
429 views

Count all co-occurances of a pair of strings in a list of lists

I am trying to obtain a co-occurance matrix for pairs of names in a collection of groups of names. So, I have a collection of letters in small groups, such as ...
apg's user avatar
  • 2,155
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
4 votes
3 answers
147 views

How to make two sub-sets each with two distinct elements having a list with four elements?

Consider the following list: list = {{meson1, p1}, {meson2, p2}, {meson3, p3}, {meson4, p4}} I would like to organize it into two sub-sets, each with two elements, ...
John Taylor's user avatar
  • 5,827
9 votes
5 answers
932 views

Find the farthest pairs of two points in 2-dim

I wonder if Mathematica can find the pairs of two points that are the farthest in a given list. Let's say a list, XYlist, of points with (x,y) coordinates. ...
Taiki Bessho's user avatar
1 vote
0 answers
43 views

Creating a Table of Squared Differences through a Single Function

I am having trouble creating a table of squared differences within a single function. I can manually create this table through creating six different alphaDiff ...
Axion004's user avatar
  • 111
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
4 votes
3 answers
267 views

Finding a subset in the set of the digits of Pi

Well, I want to find the first position where the digits of Pi are {a,b,c,...,z}. So to find the first n digits of Pi and put them in listform I used: ...
Jan Eerland's user avatar
  • 2,001
6 votes
7 answers
333 views

How to select elements from a list of pairs based on first element belonging to a different list?

This is my very first question and I really appreciate this ability and thankful the community. I have two lists and need to select only those pairs from the first list, first element of which is ...
Igor Binder's user avatar
3 votes
3 answers
489 views

Check ordered subset in list

I need to find a function that checks if a list is contained in a larger list RESPECTING the order of the smaller one. For example check[{a,b,c},{a,d,b,c}] would ...
Marcosko's user avatar
  • 259
0 votes
1 answer
165 views

How to find a specific spanning subgraph?

A spanning subgraph is a subgraph that contains all the vertices of the original graph. Given a graph $G$, I would like to write a function $f$ for finding a spanning 5-regular bipartite connected ...
licheng's user avatar
  • 2,039
1 vote
1 answer
92 views

KSetPartitions function with fixed points

I'm trying to develop a function that computes some numerators for scattering amplitudes and I need to generate a collection of tree diagrams that contain a set of particles (effectively numbers) <...
Marcosko's user avatar
  • 259
2 votes
1 answer
65 views

How do I compose a list from an Association such that the final product matches a fixed percentage of each of four subsets?

My question is in two parts. The first is about picking discrete elements inside a list of Associations to match a fixed percentage of a final sub-list; the second is about overcoming the rounding ...
Rogo's user avatar
  • 930
3 votes
3 answers
226 views

Dropping list elements that are members of other lists [closed]

I have a set: $$A=\{\{1,2,3\},\{1,3,2\},\{2,1,3\},\{2,3,1\},\{3,1,2\},\{3,2,1\}\}$$ I want to drop elements found in sets B and C from A. $$B=\{\{1,3,2\},\{2,1,3\}\}$$ $$C=\{\{3,1,2\},\{3,2,1\}\}$$ ...
Math-babylon's user avatar
4 votes
4 answers
828 views

How to generate Venn diagram from a universe and 3 random sets?

Given a universe u with random numbers between 1 and 50 and three sets a,b,c, that have random numbers a between 3 and 30, b between 2 and 40 and c between 4 and 49 How can I represent the sets a, b ...
BeTDa's user avatar
  • 490
2 votes
2 answers
214 views

How can I subtract and calculate the complement of a pair of sets? [closed]

I cannot properly implement these operations. How can I do it? This is a reduced example: A={2,3,4} B={2,4,6} C={1,2,3,4} Find ...
wally's user avatar
  • 417
7 votes
3 answers
432 views

Is there a function to generate “subsets” allowing duplicates?

I allow them to be chosen more than once (e.g. allow {1,1}). (A subset means every element is chosen once or less) Also I neglect the order (e.g. ...
Y.D.X.'s user avatar
  • 175
3 votes
1 answer
129 views

select subset of combinations based on condition

My question is about choosing a subset of combinations within a list, based on a condition. Fot example, a shop sells 26 products. The name of a product starts with a letter. Each product has a price. ...
Michiel van Mens's user avatar
6 votes
1 answer
504 views

How to obtain all subsets of a list with repetition?

I'd like to generate all lists of length m containing all possible element combinations from a given list of length n with ...
Andrew's user avatar
  • 2,513
5 votes
4 answers
93 views

List X is a starter of list Y

For lists X and Y, let's define a term 'X is a starter of Y' to be 'there exist a list Z such that Y = Join[X,Z]'. Until now I've used following code for 'X is a starter of Y' ...
imida k's user avatar
  • 4,295
2 votes
1 answer
32 views

ordered set inclusion 2

Slightly change the previous question, ordered set inclusion, Now, consider $A=\{2,3\}$ and $B=\{2,3,4,5\}, C=\{5,2,4,3\}$, Now I want to make element $\{2,3\}$ is in $B$ as well as $C$, what can be ...
phy_math's user avatar
  • 923
2 votes
1 answer
49 views

ordered set inclusion

Suppose I have a ordered set $A=\{2,3\}$ and $B=\{2,3,4\}$ and $C=\{2,4,3\}$. Is there any mathematica command whether $A\subset B$ gives true(or 1) but $A$ which is not a subset of $C$ gives false(or ...
phy_math's user avatar
  • 923
4 votes
2 answers
295 views

How do you turn a normal intersection to a strict one for arbitrary number of sets?

What is the best way to generalize the following interaction of 3 sets to any number of sets: ...
user13892's user avatar
  • 9,443
6 votes
5 answers
205 views

Delete the sublist which can be others' subsets

given lst = {{1, 5}, {2, 5}, {6, 8}, {6, 8, 9}} I want to remove all the sublists which is any other's subset. For the above example, remove ...
AsukaMinato's user avatar
  • 9,928
2 votes
1 answer
136 views

k-subsets of several sets?

Problem: Let A and B be lists of lists of integers. I wish to find every k-element set, ...
Leo's user avatar
  • 1,155
1 vote
0 answers
122 views

How to determine the domain (intersection and disjoint set) of two functions define on a set? [closed]

Suppose I have two multivariate functions $f(x,y,z)$ and $g(x,y,z)$ such that $0<x<1,0<y<1,0<z<1$. $f(x,y,z)$ is defined on values satisfying $\{0<x<1,0<y<1/2, z>y\}$ ...
Amin's user avatar
  • 147
1 vote
0 answers
57 views

Letter Combination Plot

How do I make a plot that displays the total number of letter combinations of n letters (from n=1 to 26)? I've been trying with subset but can't get the syntax right.
WFFNSA's user avatar
  • 11
12 votes
7 answers
1k views

Generate only unique combinations when input contains duplicates

I have a list with repeated elements, such as list = {a, a, b, c, c, c} and I'd like a list of the unique ways to choose 3 elements from it: ...
thecommexokid's user avatar
0 votes
0 answers
140 views

Symbolic Subset Sum Problem

I am interested in solving the following problem with Mathematica, but I do not know if it can be done or how it could be done. Given a finite set of terms $M=\{a_i(p_1, \ldots,p_m) \}_{i=1}^n$, ...
mbpaulus's user avatar
  • 101
6 votes
2 answers
365 views

Graph that visualizes subset relations

First, off I am a bloody beginner when it comes to programming in general and Mathematica in particular. I only started using it so I can make sense of my suggestions for the semantics in my syntax ...
user3201's user avatar
  • 161
4 votes
2 answers
157 views

Simple way to decompose a lists in a certain way?

I want to decompose one list into sublists (each sublist is given by certain lengh and the sum of every sublist is given by the maximun number in lists). For ...
Xuemei's user avatar
  • 1,616
2 votes
1 answer
119 views

Creating pairs of non-intersecting set from a given set

Let's say I have a set {a,b,c,d} and I want to create a list of pairs {{a,b,c,d},{}},{{a,b,c},{d}},{{a,b,c},{}},... such that there is no intersection between each pair, and they do not need to use ...
AlanZ's user avatar
  • 21
0 votes
1 answer
89 views

How to find disjoint subsets such that union of the sets give the motherset or main set?

Let us define a set $\mathcal{S}=\{1,2, 3,\cdots,67\}$. I have a list of 132 subsets. I want to obtain 16(or 17) mutually exclusive subsets such that union of such 16(or 17) is equal to $\mathcal{S}$...
MGK's user avatar
  • 565
1 vote
0 answers
131 views

Generating all possible subgraphs from an adjacency matrix

I have an adjacency matrix given by am. I want to generate all possible subgraphs with 6 nodes. Here is the code I am using to generate them. But, I am getting some error: ...
MGK's user avatar
  • 565
2 votes
1 answer
114 views

Calculate plausibility in Dempster-Shafer theory

I want to use Mathematica to show which subsets of a power set are required to calculate the plausibility for a given set in a power set. This has lead me to compute a summation with a ...
Hefaestion's user avatar
6 votes
1 answer
188 views

Generate list of tuples, modulo PermutationGroup

I have a permutation group, e.g. g = PermutationGroup[{Cycles[{{1, 2}}]}] but not necessarily limited to a single generating cycle. What I want is to create a ...
J Bausch's user avatar
  • 151
0 votes
0 answers
110 views

Iterating over pairs in a list

Take a look at this code: ...
saga's user avatar
  • 101
0 votes
1 answer
142 views

Delete duplicates and sort a list of sets separately? [closed]

I have a set where it has three subsets. I want to have each element of each subsets appears only once, sorted, but the order of subsets does not change. For example: I want to get from $$ \{\{5,2,2,3\...
asad's user avatar
  • 848
6 votes
2 answers
925 views

Subsets of a multiset

The function Subsets[] returns the subsets of a finite set of elements. This function has a shortcoming in that it treats repeated elements distinctively. Is there ...
useranonis's user avatar
2 votes
2 answers
273 views

Finding maximal elements of partially ordered sets

I am dealing with partially ordered sets $\Gamma$, which I represent as directed graphs with an edge going from $a$ to $b$ if $a \leq b$ in $\Gamma$. For example the following graph, ...
Pjotr5's user avatar
  • 555
6 votes
4 answers
811 views

Summation over integers satisfying some conditions

$n$ is a fixed positive integer and $p$ is the largest prime $\le n$: p = Prime[PrimePi[n]] For each subset $L$ of positive composite integers less than or ...
The Substitute's user avatar
1 vote
1 answer
444 views

Creating subsets of lists of lists which have certain properties

PREFACE: This question is about a proper algorithm and its implementation. I will explain the problem as detailed as possible and will give my current algorithm as well as two more possible solutions ...
Armin's user avatar
  • 321
0 votes
1 answer
66 views

determine the structure of Data in sum of two subsets Modulus $n$

I wrote a code below to determine the cases when two subsets of a set $\mathbb{Z_n}=\{0,1,2,\ldots,n-1\}$ are added together element by element (without removing the multiplicity) in $\mathbb{Z_n}$ ...
asad's user avatar
  • 848
10 votes
7 answers
827 views

Is there concise code for the list operation I want to perform?

Is there any concise syntax for the following partitioning of a list. Given {1, 2, 3, 4}, I want to get the output as shown below. I have tried various function ...
vikas's user avatar
  • 101