combinations Questions

4

Solved

Given n=2, I want the set of values (1, 1), (1, 2), and (2, 2). For n=3, I want (1, 1), (1, 2), (1, 3), (2, 2), (2, 3), and (3, 3). And so on for n=4, 5, etc. I'd like to do this entirely within th...
Hamo asked 18/10, 2021 at 18:53

6

Solved

I am looking for an algorithm which takes as input a set of two elements T = {0, 1} and k and generates all k-combinations of T as follows: 000 001 010 011 100 101 110 111 It is straightforward ...
Confection asked 18/9, 2012 at 10:30

7

Solved

I'm trying to generate a nested array containing all combinations with repetition in Apple's Swift programming language. An detailed explanation of combinations with repetition can be found near th...
Dakar asked 6/8, 2014 at 14:4

1

Solved

Consider a list : [A,B,C,D] I have to find the fastest way split the list in all possible sets of pairs such that the pairs are mutually exclusive: For example, for the given list, the result...

2

Solved

How would we go about testing all combinations of subarrays in a array where length of each subarray is equal to P times the sum of subarray elements. A brief example: Edit: A = [2,-1,3,0,1,2,1] ,...
Etude asked 23/9, 2021 at 8:33

2

Solved

Consider the following example: import itertools import numpy as np a = np.arange(0,5) b = np.arange(0,3) c = np.arange(0,7) prods = itertools.product(a,b,c) for p in prods: print(p) This iter...
Begum asked 28/9, 2021 at 13:50

6

Solved

I would like to create all possible combinations of a binary vector made of a fixed number of 0 and 1. For example: dim(v)=5x1; n1=3; n0=2; In this case I'd like to have something like: 1,1,1,0,0...
Shadowgraph asked 6/2, 2015 at 14:33

4

Solved

I have a list of possible choices: [[1], [2, 4], [4], [5, 6, 2], [5, 3]]. I want to list all combinations, taking maximum one element from each sublist, without repeating elements. So [1, 2, 4, 5, ...
Acetaldehyde asked 14/9, 2021 at 20:33

3

I have often used itertools module in Python but it feels like cheating if I don't know the logic behind it. Here is the code to find combinations of string when order is not important. def combi...
Minica asked 23/7, 2014 at 10:23

3

I want to retrieve k,v-pairs from a HashMap. The entrys are like this: a = 3,4 b = 5,6 and so on. I need combinations of these values. a=3, b=5 a=3, b=6 a=4, b=5 a=4, b=6 I don't know how many ke...
Fascista asked 16/3, 2011 at 9:0

4

Solved

I have n Sets. Each Set has different number of elements. I would like to write an algorithm which give me all possible combinations from the sets. For example, let's say we have: S1={1,2}, S2={A,B...
Defibrillator asked 14/5, 2013 at 18:1

2

Solved

I need a function similar to expand.grid but without the combinations of duplicate elements. Here is a simplified version of my problem. X1 = c("x","y","z") X2 = c(&qu...
Isomorph asked 19/6, 2021 at 13:15

4

I'm sure this is pretty simple, but I'm stumped for a way to do this. Essentially if I have an array with P collumns and V^P rows, how can I fill in all the combinations, that is, essentially, all ...
Vassaux asked 23/4, 2012 at 8:47

4

Solved

Let's say I have three types of coins -- a penny (0.01), a nickel (0.05), and a dime (0.10) and I want to find the number of ways to make change of a certain amount. For example to change 27 cents:...
Krute asked 8/5, 2021 at 22:30

3

Solved

I am looking to generate more permutation that sums up to a given number N, however this time more efficiently. Since by general methods, it takes forever to create 100+ permutations. However I'm a...
Impostume asked 18/5, 2020 at 0:55

5

Solved

I have a map of lists like: Map("a" -> [1,2,3], "b" -> [4,5,6], "c" -> [7]) I need to produce: [ Map("a" -> 1, "b" -> 4, "c&qu...
Pellikka asked 10/3, 2021 at 21:50

11

Solved

Given an unknown amount of lists, each with an unknown length, I need to generate a singular list with all possible unique combinations. For example, given the following lists: X: [A, B, C] Y: [W...
Spermatogonium asked 19/6, 2013 at 13:40

6

Hello there Stackoverflow people, I run a site that finds its users the cheapest place to buy books. This is easy for a single book, but for multiple books it can sometimes be cheaper to purchase ...
Mcalpin asked 8/1, 2010 at 5:1

4

Solved

Is it possible to combine multiple enums together? Below is code sample of what I would like to see: enum PrimaryColors { Red, Yellow, Blue } enum SecondaryColors { Orange, Green, Purple } ...
Southwest asked 5/12, 2012 at 23:56

6

Solved

How one can calculate the number of combinations and permutations in R? The Combinations package failed to install on Linux with the following message: > install.packages("Combinations&quot...
Slovenly asked 26/10, 2011 at 16:41

5

Solved

I want to compute all possible lists of pairs you could make of a set. For instance: input = [1, 2, 3, 4, 5, 6] output = {[(1,2), (3,4), (5,6)], [(2,3), (4,5), (1,6)], [(2,4), (1,3), (5,6)], [...
Zomba asked 13/2, 2014 at 17:49

3

Solved

I need help finding an efficient algorithm to solve this problem: Given n unsorted sets of integers, find all possible combinations of n and their intersections. For example: Input (n=3): Set 1 = ...
Sokotra asked 24/9, 2014 at 23:27

9

Solved

I have the two arrays: String[] operators = {"+", "-", "*"}; int[] numbers = {48, 24, 12, 6}; And I want to get all possible combination in a String format like this:...
Anteroom asked 14/12, 2018 at 13:46

2

Suppose I have this data frame: matrix(c(2,4,3,1,5,7,1,2,3,5,8,2,4,5,1,1,3,6,1,3,4,5,6,1),nrow=6,ncol=4,byrow = TRUE)->X as.data.frame(X)->X.df V1 V2 V3 V4 1 2 4 3 1 2 5 7 1 2 3 3 5 8 2 4 ...
Deration asked 18/8, 2013 at 11:59

3

My task is to generates all possible combinations of that rows without the hidden # number sign. The input is XOXX#OO#XO and here is the example of what the output should be: XOXXOOOOXO XOXXOOOXXO...
Shimmery asked 30/1, 2021 at 20:50

© 2022 - 2024 — McMap. All rights reserved.