Category "combinations"

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; Ea

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 n

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 usin

How to get multiple combinations of multiple lists in python (Multiple n Choose K or nCr)

I have been looking on google and stack overflow for a few hours and I am sure there is an answer for what this is mathematically or perhaps it is just what the

words amalgamation

I am new user learning python. I have query if it can be done or not. If user input a word suppose "Dance" and characters are "$" and "@", he would get a all po

How to find Z highest subset Sums from the array of N elements

I have an array of numbers, now I want to find all possible subset sums and get the top z elements in it. Example: Input : arr[] = {2, 4, 5}, z = 3 SubsetSums

R find all possible unique combinations

I am trying to find all possible unique combinations in R. It seems that there have been a lot of similar questions asked, but I was not able to find the same o

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 po

Shortest Flow Layout Solver

I have a routing sequence for a set of machines on an assembly line. Each route has to go through the entire line (that is, if you only run the first and second

All possible combinations of columns in dataframe -pandas/python

I'm trying to take one dataframe and create another, with all possible combinations of the columns and the difference between the corresponding values, i.e on 1

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","y","z","z","z","z"), number = c

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,22

Remove duplicate combinations in R [duplicate]

I am using R and I would like to remove combinations in a data.frame. Unique function does not seem to do the job. a b c 1 1 4 A 2 2 3 B 3

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 itert

Google Foobar Challenge 3 - Find the Access Codes

Find the Access Codes Write a function answer(l) that takes a list of positive integers l and counts the number of "lucky triples" of (lst[i], lst[j], lst[k])

Count of combinations with repetitions

I have a very inefficient way of counting the combinations of N/2 items from an array of size N. What I do is sort the array to begin with and then loop through

Algorithm to return all combinations of 3 combinations from a array of length 6 without the number appearing with the same set of numbers

I was trying to write a algorithm in javascript that returns all the possible 3 digit numbers numbers from a given array of length 6 For Example var arr = [1, 2

Combinations of 2 lists [duplicate]

Input: [1, 2, 3] [a, b] Expected Output: [(1,a),(1,b),(2,a),(2,b),(3,a),(3,b)] This works, but is there a better way without an if statemen

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

Javascript - Generating all combinations of elements in a single array (in pairs)

I've seen several similar questions about how to generate all possible combinations of elements in an array. But I'm having a very hard time figuring out how to