6,458 questions
0
votes
1
answer
158
views
Advanced combinatorics in Python: binom(n,2) subsets of binom(n,3) combinations without repetition
I have a list d_n of n integers and the results Z_klm of a function fun(dk, dl, dm) for all binom(n, 3) combinations without repetition (k, l, m) out of d_n indices.
Now, for all binom(n, 2) ...
8
votes
3
answers
1k
views
How can I create an array of arrays of strings of varying lengths in C?
I am trying to solve the problem posed in this question. Here the OP asks that given a 15 element set, its 2^15 element power set be generated in a manner such that the elements of the power set are ...
2
votes
1
answer
194
views
How to compare a reference combination to multiple cells and return the closest match header in Excel? [duplicate]
I'm working on an Excel sheet where I have:
A reference combination in cell S4, like 4,D,D,D,D,D,D,D
A range of combinations in W3:AH6, where each cell contains a comma-separated string like 3,A,A,A,...
4
votes
2
answers
185
views
Combination generator written in C : works for big n but for small n when n=0 or n=k crashes saying "segmentation fault"
Let's say I have a box and there is a bunch of balls in that box. I can label each ball with a character while making sure no two balls get the same character as labels. I get a string this way. Let's ...
-1
votes
3
answers
343
views
Creating all possible combinations of N items in a list?
I'm working on generating all possible combinations from a list of N elements, regardless of the number of elements in the resultant combinations. This is basically the power set without the empty ...
1
vote
2
answers
118
views
Generating all length-N combinations of all length-M sublists of a list, without repetitions
I have a long input list, and I want to generate combinations of 3 elements. But each combination's elements should be drawn from a length-5 sublist of the original list, rather than drawing elements ...
-1
votes
1
answer
196
views
method to count n-digit numbers that meet given digit patterns
What is a scalable way to count the number of n-digit numbers (in mixed radix) that meet a list of different digit criteria? For example, what are the 4 digit numbers that have any of these patterns ...
0
votes
1
answer
62
views
Generation of particular combinations
In Mathematica I implemented this simple code:
n = 8;
a0 = Range[0, n - 1];
a1 = Subsets[a0, {2}];
a2 = Subsets[a1, {2}];
a3 = Select[a2, Length[Union[Flatten[#]]] == 4 &];
a4 = Subsets[a3, {n/4}];...
3
votes
1
answer
116
views
Target sum algorithm using Numpy
I have a numpy array of floats and a target sum. I am trying to find all possible combinations of elements that would add up to the target sum.
I am struggling to come up with anything computationally ...
0
votes
1
answer
62
views
I have a column in excel and I want to get all sets of combinations in another row or column
Here is my column
enter image description here
I am looking for a formula to get all combinations separated by "/"
Example:
SE/XE
SE/SX
SE/EX
XE/EX
SE/XE/EX and so on
I have so far been able ...
2
votes
1
answer
185
views
How to create possible sets of n numbers from m-sized prime number list?
Input: a list of m prime numbers (with possible repetition), and integers n and t.
Output: all sets of n numbers, where each set is formed by partitioning the input into n parts, and taking the ...
5
votes
3
answers
198
views
Summing columns of Pandas dataframe in a systematic way
I have a pandas dataframe which looks like this:
1_2 1_3 1_4 2_3 2_4 3_4
1 5 2 8 2 2
4 3 4 5 8 5
8 8 8 9 3 3
4 3 4 4 8 3
8 0 7 4 2 2
where the ...
1
vote
1
answer
136
views
What function should I use to sort each row by its columns in a 2d array?
The formula below produces permutations of the digits in the array cols - in this case 1 to 6. The perms variable outputs a 2d array of the permutations without repetitions.
However, I want to get ...
3
votes
2
answers
140
views
Check if a target sum is possible given a vector of values
The problem is to check if it is possible to get a given targetSum from the elements of a given array. Each element should be included once only (if included).
The code is a brute force approach using ...
1
vote
0
answers
72
views
How do I use a custom mapping (sort) on my itertools for loop so that I can print specific strings first?
I'm using python itertools specifically to generate combinations of integer strings. I have already created the loop that will loop through the combinations one at a time. I just need someone to help ...