6,459 questions
1
vote
3
answers
89
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 ...
-4
votes
1
answer
145
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
35
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}];...
2
votes
1
answer
74
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
25
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
156
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
159
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
91
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
76
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
1
answer
52
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 ...
-1
votes
2
answers
77
views
Find combinations of 2 numbers in a list that those 2 numbers are not the same (Python)
Find combinations of 2 different numbers in a list (In python)
Input:
1st line: n (length of array)
2nd line: array (the array) ex:(1 7 1)
Output:
Numbers of combinations of 2 numbers in a list ...
0
votes
0
answers
41
views
I Need Values from a 2D Array Combined in a Certain Way [duplicate]
I have an array like this:
matrix = [
['A', 'B', 'C'],
['D'],
['E', 'F'],
['G', 'H']
]
And I need to choose a value from each row in such a way as to get this output
ADEG,
ADEH,
ADFG,
ADFH,
...
0
votes
2
answers
121
views
Calculate combinations for a range of text values in excel
I do not know enough about M in PowerQuery to work out how to solve the below.
The example is, I have an excel range of over 300 rows, each with 12 columns that may contain strings of meta-data (these ...
1
vote
1
answer
76
views
Using one dataframe to find matching combinations in fixed sets
A
B
C
D
E
Key 1
1
-1
Key 2
1
-1
Key 3
1
-1
Key 4
-1
1
Key 5
1
-1
Key 6
1
-1
Key 7
1
-1
Key 8
1
-2
1
Final Result
A
B
C
D
E
1
-1
suppose we have the above dataframe where each key is an option ...
0
votes
1
answer
144
views
max combination for a given list
I need an assistant with implementing the following question in Python;
There is a given list:nums = [1, 1, 4, 2, 3, 3, 2, 5]
The request is to write a Python code which gets the maximum number of ...