combinations Questions
9
Solved
I got one puzzle and I want to solve it using Python.
Puzzle:
A merchant has a 40 kg weight which he used in his shop. Once, it fell
from his hands and was broken into 4 pieces. But surprisi...
Papert asked 30/4, 2012 at 17:40
6
Solved
Suppose I am given:
A range of integers iRange (i.e. from 1 up to iRange) and
A desired number of combinations
I want to find the number of all possible combinations and print out all these com...
Himself asked 9/12, 2009 at 20:4
9
Solved
df = pd.DataFrame({'a':['x','x','x','x','x','y','y','y','y','y'],'b':['z','z','z','w','w','z','z','w','w','w'],'c':['c1','c2','c3','c1','c3','c1','c3','c1','c2','c3'],'d':range(1,11)})
a b c d
0 ...
Ultramicroscope asked 13/1, 2021 at 18:8
6
Solved
I would like to count all combinations in a data.frame.
The data look like this
9 10 11 12
1 1 1 1 1
2 0 0 0 0
3 0 0 0 0
4 1 1 1 1
5 1 1 1 1
6 0 0 0 0
7 1 0 0 1
8 1 0 0 1
9 1 1 1 1
10 1 1 1 1
...
Anitaanitra asked 16/12, 2015 at 12:39
2
Solved
I have to built a function which would list the all possibilities to put +, - or nothing between the numbers ranging from 1 to 9 and print it result.
For example:
1+2+3+4+5+6+7+8+9=45,
1+2+3+4+5+...
Split asked 8/5, 2018 at 19:1
3
Solved
I have sets of values that I want to apply as parameters to a function:
params = {
'a': [1, 2, 3],
'b': [5, 6, 7],
'x': [None, 'eleven', 'f'],
# et cetera
}
I want to run myfunc() with all p...
Fingerprint asked 3/7, 2017 at 14:8
32
Solved
How would you go about testing all possible combinations of additions from a given set N of numbers so they add up to a given final number?
A brief example:
Set of numbers to add: N = {1,5,22,15...
Faruq asked 8/1, 2011 at 4:26
5
Solved
I am trying to deduce an algorithm which generates all possible combinations of a specific size something like a function which accepts an array of chars and size as its parameter and return an arr...
Nuclear asked 28/9, 2013 at 13:34
6
Solved
For a string of length n, the formula to compute all the substrings are: n(n+1)/2
Can someone help me out in intuitively understanding this formula?
Wikipedia says:
"The number of substrings of a...
Sacramental asked 14/9, 2012 at 5:23
4
Solved
I have 10 words. How can I get all possible combinations of 5 words (n=10, k=5). The order does not matter.
For example: "A", "B", "C", with k=2 and n=3 should result ...
Aeolotropic asked 27/2, 2011 at 10:48
2
Solved
Consider I have the following dictionary:
someDict = {
'A': [1,2,3],
'B': [4,5,6],
'C': [7,8,9]
}
Is there an easy way I can iterate through to create new dictionaries in a loop for all of the ...
Bequeath asked 2/11, 2020 at 11:51
14
Solved
I'm interested in finding the nth row of pascal triangle (not a specific element but the whole row itself). What would be the most efficient way to do it?
I thought about the conventional way to c...
Zeitler asked 22/3, 2013 at 21:39
1
Solved
A machine provides fault codes which are provided in a pandas dataframe. id identifies the machine, code is the fault code:
df = pd.DataFrame({
"id": [1,1,1,1,1,2,2,2,2,3,3,3,3,3,3,4],
...
Limoli asked 28/9, 2020 at 9:1
4
Given a value of k. Such that k<=100000
We have to print the number of pairs such that sum of elements of each pair is divisible by k.
under the following condition first element should be small...
Komsa asked 12/9, 2013 at 16:19
2
Solved
I have a vector of elements named markers of the form:
markers <- LETTERS[1:5]
Each element in markers is of Boolean type with two possible conditions + and -. I would like a fast an efficient ...
Eyeleteer asked 24/9, 2020 at 6:21
1
Solved
Edit::
after all these discussions with juanpa & fusion here in the comments and Kevin on python chat , i have come to a conclusion that iterating through a generator takes the same time as it ...
Oconnell asked 2/9, 2020 at 4:21
5
What I'd need is to create combinations for two elements a time.
If a list contains: seq = ['A', 'B', 'C']
the output would be com = [['A', 'B'], ['A', 'C'], ['B', 'C']]
all this without itertoo...
Barbabas asked 24/12, 2013 at 17:53
2
Given a collection of numbers that may contain duplicates, find all partitions of it. (all possible ways of dividing the collection.)
For instance, the multiset {1, 1, 2} has 4 partitions:
parti...
Sordino asked 5/12, 2018 at 5:33
2
Solved
I am trying to get all the possible combinations of length 3 of the elements of a variable. Although it partly worked with combn() I did not quite get the output I was looking for. Here's my exampl...
Lamblike asked 24/1, 2014 at 17:53
10
Solved
I'm having trouble coming up with code to generate combinations from n number of arrays with m number of elements in them, in JavaScript. I've seen similar questions about this for other lang...
Afrikaans asked 8/3, 2013 at 16:37
2
Solved
What is the best way to write a control structure that will iterate through each 2-element combination in a list?
Example:
{0,1,2}
I want to have a block of code run three times, once on each ...
Wertheimer asked 10/6, 2013 at 19:56
5
Solved
I would like to generate all combinations of values which are in lists indexed in a dict:
{'A':['D','E'],'B':['F','G','H'],'C':['I','J']}
Each time, one item of each dict entry would be picked a...
Anima asked 2/8, 2016 at 13:28
1
I have some code which loops through a large set of itertools.combinations,
which is now a performance bottleneck. I'm trying to turn to numba's @jit(nopython=True) to speed it up, but I'm running ...
Supplement asked 17/4, 2020 at 0:17
3
I have data in the following format:
Data <- data.frame(
Names = c("Person A", "Person B","Person F", "Person G", "Person F", "Person G", "Person Q", "Person R"),
Time_Stamp = c("2013-08-01 ...
Negatron asked 16/4, 2020 at 20:29
3
Solved
I am looking a function that return me all the unordered combination of a vector. eg
x <- c('red','blue','black')
uncomb(x)
[1]'red'
[2]'blue'
[3]'black'
[4]'red','blue'
[5]'blue','black'
[6]'r...
Isochronize asked 14/1, 2015 at 22:25
© 2022 - 2024 — McMap. All rights reserved.