combinations

Modifying Excel vba that creates all possible combinations from multiple lists

浪子不回头ぞ 提交于 2019-12-24 06:40:30
问题 Hello I found some really great code from a couple years ago to create all possible combinations from multiple rows. It works great but as you try it with more data it returns a run time error 6 overflow. I am very new to VBA but am hoping that there is a way to split up or slow the process down to keep the macro running. My current data should produce 442,368 unique rows, which is a lot but well within the scope of excel's power. I will paste the vba code below. When you hit debug following

combination of two lists in java

随声附和 提交于 2019-12-24 05:20:30
问题 Is there any algorithm to achieve this combination of output? Input : arr1 = {x, y, z} arr2 = {a, b} Output : xa, ya, za xa, ya, zb xa, yb, za xa, yb, zb xb, ya, za xb, ya, zb xb, yb, za xb, yb, zb 回答1: static char[] arr1 = {'x', 'y', 'z'}; static char[] arr2 = {'a', 'b'}; public static void main(String[] args) { print(new char[arr1.length - 1], 0); } static void print(char[] store, int depth) { for(char c : arr2) { if(depth < store.length) { store[depth] = c; print(store, depth + 1); } else

How to randomly pick a number of combinations from all the combinations efficiently?

[亡魂溺海] 提交于 2019-12-24 05:16:11
问题 I know function combn can generate all the possible combinations. However, if the total number of members is large, this is really time-consuming and memory-consuming. My goal is to randomly pick combinations from all the possible combinations. For example, I want 5000 distinct triple set of members from a pool of 3000 members. I think I don't need to generate all possible combinations and choose 5000 from them. But seems that R doesn't have a ready-to-use function to do this. So how to deal

finding combinatorial of large numbers

人盡茶涼 提交于 2019-12-24 04:35:11
问题 What is an efficient way of finding the number of ways k gifts can be chosen from N gifts where N can be very large (N ~ 10^18). That is we have to calculate N(C)K or N chose K. K can also be of the order of N. 回答1: I guess there are no fast ways to compute such large numbers. You can approximate it using Stirling's formula 回答2: Stirling's formula would be useful only if you had further asymptotic information such as k ~ n / 3 or k ~ log n . With no further information on your specific

Number of ways to sum the items in a set to get a target value - Order matters

牧云@^-^@ 提交于 2019-12-24 04:24:06
问题 I'm practicing for programming interviews, and I stumbled upon this question on GlassDoor: "Find the number of ways we can sum the items in the set to get our target value. Order matters." Apparently, the interviewer couldn't come up with an answer, but he left this comment on GlassDoor: "This was more of a math question than a programming question." This problem seems to be different than this one: Finding all possible combinations of numbers to reach a given sum. So my questions is: what is

Using recursion to search all combinations of elements in an array of integers

て烟熏妆下的殇ゞ 提交于 2019-12-24 03:18:36
问题 I am working on this problem from Coderbyte using JS: Have the function ArrayAdditionI(arr) take the array of numbers stored in arr and return the string true if any combination of numbers in the array can be added up to equal the largest number in the array, otherwise return the string false. For example: if arr contains [4, 6, 23, 10, 1, 3] the output should return true because 4 + 6 + 10 + 3 = 23. The array will not be empty, will not contain all the same elements, and may contain negative

Generating all combinations from collections in Smalltalk

好久不见. 提交于 2019-12-24 02:33:24
问题 I've seen this problem resolved for C# and other languages but not for Smalltalk. I have 3 collections, for example: a := #(3 4 5). b := #(4 1 2). c := #(5 2 3). and I need to make all possible combinations, i. e.: #(3 4 5) #(3 4 2) #(3 4 3) #(3 1 5) #(3 1 2) #(3 1 3) #(3 2 5) #(3 2 2) #(3 2 3) #(4 4 5) ... I have seen in Squeak and Pharo there is combinations:atATimeDo: but I don't get how to use it for this case. This is not homework. Any help? 回答1: here is the code from Smalltalk/X's class

Find the index of a specific combination without generating all ncr combinations

帅比萌擦擦* 提交于 2019-12-24 02:22:17
问题 I am trying to find the index of a specific combination without generating the actual list of all possible combinations. For ex: 2 number combinations from 1 to 5 produces, 1,2;1,3,1,4,1,5;2,3,2,4,2,5..so..on. Each combination has its own index starting with zero,if my guess is right. I want to find that index without generating the all possible combination for a given combination. I am writing in C# but my code generates all possible combinations on fly. This would be expensive if n and r

High performance calculation of least squares difference from all possible combinations (n lists)

廉价感情. 提交于 2019-12-24 02:07:21
问题 I'm looking for a very efficient way to calculate all possible combinations from n lists and then keep the combination with the smallest least squares difference. I already have a code that does it, but when it gets to several million combinations things get slow. candidates_len contains a list of lists with lengths i.e. [[500, 490, 510, 600][300, 490, 520][305, 497, 515]] candidates_name contains a list of lists with names i.e. [['a', 'b', 'c', 'd']['mi', 'mu', 'ma']['pi', 'pu', 'pa']] Both

Python - list the combination pair for a function value

允我心安 提交于 2019-12-24 02:05:54
问题 I have a combination of four coordinates, and I am trying to find the distance between each coordinates. I have been able to complete this, but I cannot get my program to list the coordinate pair that corresponds to each distance. import itertools import math point1 = (1,1,0.5) point2 = (3,3,1) point3 = (2,0.5,2) point4 = (0.5,2,1) points = [(point1),(point2),(point3),(point4)] pointsPairs = itertools.combinations(points, 2) for pair in pointsPairs: x1 = pair[0][0] y1 = pair[0][1] z1 = pair[0