Questions tagged [combinations]
A combination is a selection of objects from a larger collection in no particular order.
5,893
questions
0
votes
1
answer
41
views
Minimize sum of a column within multiple combinations of other variables
This one has me banging my head against the wall... would love some help.
I will explain an example of what I am trying to do below with simulated data, but essentially I am trying to minimize the sum ...
3
votes
3
answers
88
views
Python combinations of elements in dict
This is a tough one.
I have a bunch of dicts like the one below (some can be quite large):
V = {
0: [823, 832, 1151, 1752, 2548, 3036],
823: [832, 1151, 1752, 2548, 3036, 3551],
832: [1151,...
0
votes
1
answer
20
views
Output variable names when summing a tuple
A list of variables with assigned values. I want to return all the possible combinations from each pair (every two of them).
The print-out is the names of the pair, and sum of them.
For example:
(Mike,...
-2
votes
1
answer
46
views
I'm curious about the JavaScript combination
I have an array of items.
// groupA,groupB,groupC,groupD length 4 = I want to be 4 column
const arr = [
{ seq: 253, type: "a", group:'A' },
{ seq: 258, type: "a", group:'B' },
...
0
votes
0
answers
15
views
I'm having difficulty putting together basic Python concepts [closed]
this is my first question here on S.O. and I hope you all are doing well in these times. But any who, I have question for Python beginners like myself. I've recently invested into course from a ...
0
votes
1
answer
14
views
How to check multiple possible combinations of if statements?
So I have 20 conditions and im trying to check different combinations.
for example:
1 and 2 or 3
1 or 2 or 3 and 4
4 and 5 or 2
4 and 5 and 2 or 9
ect....
I'm trying to figure out what should I do. I ...
0
votes
2
answers
25
views
MySQL - How to store multiple combinations of colors for one product?
I am searching for the best solution for the following issue:
I have three tables:
Product
id
productName
1
Tshirt
2
Pullover
3
Jacket
Base Color
id
baseColorName
allowedExtraColorIds
1
Green
...
0
votes
1
answer
16
views
Android Kotlin - How do I determine when "last pointer up" on multitouch for several buttons?
Screenshot
I want to do something like playing chords. Any of these five buttons can be pressed in any combination to provide a different result. The order in which they are pressed does not matter, ...
0
votes
0
answers
19
views
Possible combinations of three vectors in specific order in R [duplicate]
I have three vectors.
v1 <- c("A", "C", "D", "E")
v2 <- c("A", "E", "G")
v3 <- c("C", "E", "S&...
1
vote
1
answer
25
views
how to modify the combinations table (that made by expand.grid() function) in r?
I made small, reproducible example,
but my real data is really huge...and have lots of levels.
roomnumber <- c(1,2,3)
color <- c('red','blue','green')
weight <- c(0.1,0.3,0.5)
data <- ...
0
votes
1
answer
32
views
How to create a for loop to go through multiple year combinations for a glm in R?
I have a large dataset with the presence and absence (0,1) of Blue Rockfish and multiple variables (in my case, bathymetry, curvature, eastness, fine scale BPI, and broad scale BPI).
structure(list(...
1
vote
0
answers
46
views
Stop permutations function after certain number of permutations are generated
I am using this script below to generate all possible permutations of a length of 15 from a list of 20 amino acids.
test <- permutations(20, 15, all.amino.acids)
There are soooo many different ...
1
vote
1
answer
41
views
Algorithm to find all combination from an array of objects
Recently a friend of mine proposed to solve a simple problem and I'm struggle to find the best algorithm to solve it.
There's a list of athletes, every athlete has a name, a weight and can have ...
0
votes
1
answer
29
views
Is there a way to permutate list of lists while keeping the lists together?
list1 = [[1,2,3],[4,5,6],[7,8,9]]
Is there anyway possible in the realm of coding that I can permutate this list of lists while keeping the "groups" together?
I really need this solved, ...
-2
votes
0
answers
29
views
how to get all combinations without repetition in php using 2 arrays [closed]
how to get all possible combinations of below arrays
$a = [1,2,3,4,5,6,7,8,9];
$b = ['a','b','c','d','e','f','g','i','j'];
I need to get all combinations, limited to 6 elements only, for result array ...
-2
votes
0
answers
35
views
Combinations generator performance
I wrote a script which produces unique list of combinations, I am having trouble with extracting unique combinations from large set of data i.e more than 90 unique values from list. I read yield ...
1
vote
1
answer
66
views
How to compute the number of combinations with [1, N] that makes the combination sum equals to N?
when n = 1
S(1) = 1;
when n = 2, there are two combinations
2 = 2
2 = 1 + 1
S(2) = 2;
when n = 3, there are 3
3 = 3
3 = 1 + 1 + 1
3 = 1 + 2
S(3) = 3
4 = 4
4 = 1 + 1 + 1 + 1
4 = 2 + 1 + 1
4 = 2 + 2
...
0
votes
1
answer
30
views
All combinations in a 2d Numpy
I am trying to modify the code provided as answer by Hilberts in below question to allow it for multiple values and not only binary.
All binary combinations in a 2d Numpy
So, rather than only allow 0 ...
1
vote
1
answer
22
views
how to ignore the first match of a result when generating the combination of K elements in a list in prolog?
how to ignore the first match of a result when generating the combination of K elements in a list in prolog ?
%here is the code.
combination(0,_,[]).
combination(N,[X|T],[X|Comb]):-N>0,N1 is N-1,...
1
vote
1
answer
54
views
Get every combination (order is important) in vector with given size and elements [closed]
I want to create every possible coloring in a vector for a given size of the vector (amount of vertices) and given possible elements (possible colors)
as an example:
for a graph with 3 vertices and I ...
0
votes
3
answers
49
views
Calculate combinations of several categorical variables
I have a data frame with mainly categorical variables. I want to see the number of combinations of variables found in three of these columns with categorical variables.
The data in the columns looks ...
-1
votes
1
answer
46
views
Getting all combinations of a string with subscript and specif format
I have seen various combination formats. But I have to try something new.
Lets say, we have three lists:
A = ('Li', 'B', 'C', 'N')
B = ('Li', 'B', 'C', 'N')
X = ('O', 'Br', 'Cl')
All the element of ...
0
votes
1
answer
18
views
R loop to iterate and find unique combination between each item
concept_id concept_name event
1: 443387 Malignant tumor of stomach comorb
2: 4193704 Type 2 diabetes mellitus without complication comorb
3: ...
0
votes
0
answers
10
views
TLE on UVA 10776 - Determine The Combination
I tried this problem by backtracking and did some optimization, though I am getting TLE. what further optimization can I do on this code?
Abridged problem statement - Task is to print all different r ...
1
vote
1
answer
33
views
Get all possible partitions of a set using Bell's number in R
I want to find all the possible ways a number of categories can be similar to each other in R. The total number of combinations is calculated as Bell's number. E.g. there are 15 ways to organise 4 ...
0
votes
0
answers
44
views
Find a combination of k numbers in a given sequence of numbers satisfying the condition
I have a problem like this:
Given a list of numbers with n (10 <= n <= 60) numbers x1, x2,..., xn
such that 1 <= xj <= 10. Enter the number k (1 <= k <= 8), enter the
number m (0 &...
0
votes
1
answer
30
views
Is there a efficient way to find only the combinations of interest from V exciting in P
Is there a efficient way to find only the combinations of interest from V exciting in P
I have a list of something like this.
V = [2,3,5,7,9,12]
Size of V can be anywhere from 0 to 50 based on my ...
-1
votes
1
answer
28
views
Addition corresponding to all possible combination of two columns based on a criteria
I have the following input
| ID | Column1 | Column2 | Value |
|:-- |:-------:|:-------:| -----:|
| A | x | a | 4 |
| A | x | b | 1 |
| A | y | a | 5 |...
0
votes
0
answers
21
views
Calculating a list of valid combinations
So I came up with a problem that I can’t logically solve. I’ve fleshed out an example;
You have a list of numbers that you need to output (e.g. 3x number 1 & 2x number 2) - we’ll call them ‘target ...
0
votes
1
answer
36
views
How to print all the unique combinations of a list?
list_a = [1, 2, 3]
I want to print all the unique combinations from the list like this
[ [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] ]
Note: Without using any module
0
votes
2
answers
30
views
Combinations divided into rows with no repetition of elements
I'm working with lists in Python.
I have a list of colleagues which is
colleagues=['Jack', 'Jessica' 'John', 'Mark', 'Mary', 'Paul']
I want to calculate all possible couples (i.e. combination ...
1
vote
0
answers
27
views
All Possible Combinations of Values in a Vector R [duplicate]
In R, I have the following list of letters:
lets <- c("A", "B", "C")
I want to be able to return a resulting list of lists that includes every possible combination of ...
0
votes
1
answer
26
views
Is there an R function to pick only certain row value combinations?
I have a data frame that looks something like this:
my_data <- data.frame(
letter = c("x","x","x","x","x","y","y","y&...
0
votes
2
answers
44
views
Python create all combinations of data points and filter them based on function
I have a table of locations (right now in dataframe) and want to calculate all combinations and their distance from eachother.
Input:
ID
Lat
Lon
1
6,4355
53,2245
2
5,3434
50,2345
3
4,3434
51,2345
...
0
votes
0
answers
24
views
Getting output in combination form in r
I have 3 variables. Hence, I will get 6 combinations. I want to produce the 2nd column in conbination form. I got the folloWing result.
P<- matrix(c (
0.427, -0.193, 0.673,
-0.193, 0.094, -0.428,
0....
-1
votes
0
answers
105
views
How to reduce the time complexity of this algorithm?
I provide two data structures, cart_info and map_case, and get the result real_combinationby the algorithm.
This algorithm is implemented in python
import itertools
cart_info = {'a':1, 'b':2, 'c':2, '...
0
votes
0
answers
19
views
How to get all combinations of records in csv file using python
I want all the combinations of records in a csv file(only one column)
Here is how the column looks like
Here is my code for what I had done
corpus = []
for index, row in df.iterrows():
corpus....
-2
votes
0
answers
44
views
solving combination sum coding challenge
I solved combination sum 3 leetcode problem problem using a method with void return type and backtracking. The solution is intuitive and simple enough, and 90% of the submissions on leetcode follow ...
1
vote
0
answers
38
views
return all possibilities of array with limits for each element
I would like to create a function in c that takes in an argument that takes in as an argument an array where for each element it gives the range (from 0 to the number stored at the array index), I ...
-1
votes
0
answers
28
views
What wrong with my solution to combination sum problem
why is my code not working for inputs [2,3,5],Target =8.
Have debugged this so many times but cant understand y at some point sum becomes 3 while the only element in the list is equal to 2.
https://...
1
vote
0
answers
21
views
How do i go through all possible sequences of a sequenc of numbers?
i think i got a simple problem, i just can not wrap my head around it.
Lets say i got an Array, with integers, representing IDs. (1, 2, 3, 4) in this order. I am looking for a way, to go through all ...
0
votes
0
answers
33
views
in this combination recursive, is it always return correct answer?
Below is widely known combination function.
function getCombination(arr,selectNumber){
const result = [];
if(selectNumber == 1) {
return arr.map(el => [el])
};
...
0
votes
1
answer
39
views
How to create multiple combinations of columns from a pandas dataframe?
I’ll illustrate my problem with a drawing:
I have a pandas dataframe with 13 columns of 6 different types. Then I randomly want to take one of each type and create a new table to perform subsequent ...
1
vote
3
answers
45
views
Combinations in long format by group
So I have a dataset of parents and their children of the following form
Children_id Parent_id
10 1
11 1
12 1
13 2
14 2
What I want is a ...
1
vote
0
answers
65
views
Generate the feasible list of combinations
I have used the following function to generate fund combinations in a portfolio. For example, I have four funds in the portfolio. The incremental change of each fund is 5. The range of allocations for ...
-1
votes
1
answer
96
views
Cartesian product but remove duplicates up to cyclic permutations
Given two integers n and r, I want to generate all possible combinations with the following rules:
There are n distinct numbers to choose from, 1, 2, ..., n;
Each combination should have r elements;
...
-2
votes
3
answers
59
views
Is there a way to find values that contain only 0's and a symbol of any length?
I want to find strings of any length that contain only 0's and a symbol such as a / a . or a -
Examples include 0__0 and 000/00/00000 and .00000
5
votes
3
answers
108
views
Generate first N combinations of length L from weighted set in order of weight
I have a set of letters with weights, which gives their probability of appearing in a string:
a - 0.7
b - 0.1
c - 0.3
...
z - 0.01
As such, the word aaaa has a probability of 0.7*0.7*0.7*0.7 = 0.24. ...
0
votes
0
answers
39
views
Prestashop product stock and product combinations doesn't match
On ours Prestashop shop we have some issue. After adding product with combination and after it sold out combinations still have 10 items in stock when main product stock on product list have 0 product ...
0
votes
2
answers
49
views
Generating combinations if items can be together in one combination just once
Let's say I have N items. Now I want to create M-item combinations but if there already exist a combination {A,B,C} (in this case M=3), then A cannot be in another combination together with B nor C.
...