Questions tagged [combinations]
A combination is a selection of objects from a larger collection in no particular order.
combinations
6,441
questions
-3
votes
1
answer
46
views
Python - Combinatorial Analisys [closed]
I get this question in an interview and I'm still trying to solve this problem. Anyone could help me?
Question
You're embarking on a construction project, aiming to create a wooden fence using ...
1
vote
0
answers
36
views
Generate stable combinations of an unsorted list in python
I have a list made of strings which are not in sorted order. I wish to generate combinations but in such a way that the order of the elements is as in the list. However, Python documentation and its ...
4
votes
1
answer
76
views
How to vectorize groupby combination lists of two columns in Pandas Dataframe
I've a dataframe and need to group by two columns from all possible combinations of dataframe columns ['A','B','C','D','E','F','G']
import pandas as pd
d = {'A': [0,1,1,0,0,1,0,0],
'B': [1,1,0,0,...
0
votes
4
answers
67
views
N series of integers, each of different size, get cartesian product [duplicate]
I have something like this:
{'event1': [2000, 3000, 4000], 'event2': [123, 456]}
but with N keys, not only two like the example
I need to get something like this:
[
{'event1': 2000, 'event2': 123},
{'...
-1
votes
0
answers
29
views
How do I loop through all possible attachment configurations of items with attachment sites?
I have a collection of items for which I need to loop through combinations. Each item has two types of sites: A sites and B sites. Different items can have different numbers of A and B sites.
I am ...
0
votes
3
answers
49
views
Create a list of pairs, by position, from multiple other lists
I need to make a list of pairs from several other lists. The pairs will consist of a value from the same position in each list. There could be a varying number of lists, but each list will have the ...
-1
votes
0
answers
46
views
How do I make a certain substring come first in my mapping for printing combinations one at a time?
I'm working with python and I am currently generating combinations of a 74 character string that prints all combinations one at a time. I have a mapping that allows me to choose which kind of string I ...
1
vote
1
answer
28
views
How to resolve complex boolean expressions into all possible combinations
I'm trying to solve the following problem. I have a set of logical operations and I would like to resolve them into all possible combinations. For example:
"((A | X) & B & C) | (C | E) &...
0
votes
2
answers
47
views
Issue in backtracking while creating combinations of a list of size k
def combination(n,k):
combi=[]
def backtrack(start,comb):
print(comb)
if len(comb)==k:
combi.append(comb.copy())
return
for ...
-2
votes
1
answer
65
views
Creating Internal Loops Dynamically
My code is working perfectly :
const i=['a','e','i','o','u'];
let q=[];
for(let t=0,l=i.length;t<l;++t)
{
for(let e=t+1,l=i.length;e<l;++e)
{
for(let z=e+1,l=i.length;z<l;++z)...
3
votes
1
answer
72
views
Iterate over indices in multinomial expansion
Context: In the multinomial expansion, the valid indices [k1, k2, ... kr] for each term fulfill the equation n = k1 + k2 + ... + kr. Given r and n, I'm trying to iterate over all terms. For that, I ...
0
votes
2
answers
72
views
After finding all combinations of 5 unique elements, I then want to find which combination appears the most times in a list of lists?
In python I used itertools combination to get all unique 5 combinations:
from itertools import combinations
lst = ["a", "b", "c", "d","e", "f&...
2
votes
2
answers
81
views
How to check if some number can be retrieved as the result of the summation or difference of the given numbers
I have an arbitrary list of positive integers and some number X. I want to check if it is possible to retrieve X using basic operations such as summation and difference.
Any number from the list can ...
2
votes
1
answer
131
views
Is there a more efficient way to generate all combinations of elements in an array?
Here is a recursive solution to generating all combinations of elements in an array.
import java.util.List;
import java.util.ArrayList;
public class Combinations {
public static List<List<...
0
votes
0
answers
14
views
Isotope Combination filters Dropdown
I've got an issue with isotope metafizzy filters combination : https://isotope.metafizzy.co/
I'm building a line-up for concerts and meetings.
And for example i have a band that plays in London on ...