combinations Questions
8
I had an interview were I was asked a seemingly simple algorithm question: "Write an algorithm to return me all possible winning combinations for tic tac toe." I still can't figure out an efficient...
Karolkarola asked 25/2, 2015 at 6:4
10
Solved
I'm trying to create a function in JavaScript that given a string will return an array of all possible combinations of the letters with each used at most once, starting with the shortest. e.g for t...
Toscanini asked 21/8, 2012 at 4:55
9
Solved
More than once now I have needed to generate all possible pairs of two vectors in MATLAB which I do with for loops which take up a fair few lines of code i.e.
vec1 = 1:4;
vec2 = 1:3;
i = 0;
pairs ...
Snowdrop asked 16/9, 2011 at 15:26
10
Solved
I am trying to capture ctrl+z key combination in javascript with this code:
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<script type='te...
Swatch asked 15/4, 2013 at 2:0
3
Solved
This is homework
I'm working on a project, and a very small (very small, once I get this working...it's basically the pre-req for the rest of the project) part of it is to generate some combinatio...
Banish asked 8/10, 2013 at 13:51
20
Solved
I have a list of integers List<int> in my C# program. However, I know the number of items I have in my list only at runtime.
Let us say, for the sake of simplicity, my list is {1, 2, 3}
Now I...
Tichonn asked 18/10, 2011 at 5:33
18
Solved
I am trying to implement a coin problem, Problem specification is like this
Create a function to count all possible combination of coins which can be used for given amount.
All possible combinati...
Guenna asked 22/11, 2010 at 9:10
2
Solved
Similar questions are 1 and 2 but the answers didn't help.
Assume we have a list of integers. We want to find K disjoint lists such that they completely cover the given list and all have the same s...
Nephrolith asked 4/2, 2023 at 0:14
14
Solved
What's the best algorithm to find all binary strings of length n that contain k bits set? For example, if n=4 and k=3, there are...
0111
1011
1101
1110
I need a good way to generate these given ...
Enterectomy asked 5/12, 2009 at 4:23
1
Solved
Im trying to accomplish a Vectoriced Numpy version of itertools.combinations, that I futher can decorate with @jit (Numba) - To make it even faster. (I am not sure if this even can be done)
The dat...
Jaquelinejaquelyn asked 14/12, 2022 at 9:31
8
Solved
I have an array of 7 numbers (1,2,3,4,5,6,7) and I want to choose 5 of the numbers like
(1,2,3,4,5), (1,2,3,4,6), (1,2,3,4,7).
Note that (1,2,3,4,5) is equal to (4,5,3,1,2), so only one of those sh...
Spiritual asked 18/9, 2010 at 16:38
10
Solved
I am trying to generate all possible combinations of 0 and 1's in a vector of length 14. Is there an easy way of getting that output as a list of vectors, or even better, a dataframe?
To demonstra...
Zaller asked 9/9, 2013 at 19:5
5
Solved
I have two vectors and I am trying to find all unique combinations of 3 elements from vector1 and 2 elements from vector2. I have tried the following code.
V1 = combn(1:5, 3) # 10 combinations in t...
Ofay asked 2/12, 2022 at 21:14
5
Solved
I have made a vector which looks like this:
v1 <- c("1 1","1 2","1 3",
"2 1","2 2","2 3",
"3 1","3 2","3 3&...
Alanson asked 19/10, 2022 at 13:16
3
Solved
How to generate sequences of r objects from n objects? I'm looking for a way to do either permutations or combinations, with/without replacement, with distinct and non-distinct items (aka multisets...
Vange asked 21/3, 2014 at 20:43
19
I don't actually know how to describe what I wanted, but I'll show you:
For example:
$data1 = "the color is";
$data2 = "red";
What should I do (or process) so $result is the co...
Steffie asked 1/12, 2011 at 5:18
5
Solved
I just came across with this interesting question from my colleague. I'm trying now, but meanwhile I thought I could share it here.
With the password grid shown in the Android home screen, how man...
Whap asked 8/8, 2011 at 8:38
14
There are n people numbered from 1 to n. I have to write a code which produces and print all different combinations of k people from these n. Please explain the algorithm used for that.
Platinic asked 20/10, 2012 at 19:12
2
Solved
Similar to this question (Scala), but I need combinations in PySpark (pair combinations of array column).
Example input:
df = spark.createDataFrame(
[([0, 1],),
([2, 3, 4],),
([5, 6, 7, 8],)],
...
Pew asked 15/9, 2022 at 6:14
3
Solved
I though this would be straightforward, unfortunately, it is not.
I am trying to build a function to take an iterable of dictionaries (i.e., a list of unique dictionaries) and return a list of list...
Toul asked 24/12, 2018 at 17:32
5
Solved
I have two vectors:
group1 <- c("a", "b")
group2 <- c("c", "d", "e")
I want get all combinations of one element from 'group1', with one or t...
Peripatetic asked 3/9, 2022 at 20:22
3
Solved
There is a great answer regarding the generation of partition sets:
Set partitions in Python
(another similar answer with ruby is found here: Calculate set partitions with specific subset sizes whi...
Theresatherese asked 24/8, 2022 at 12:19
5
Solved
I wrote an algorithm that is inadequate, namely because it does not handle [,abc] cases (see the string variations and conditions below), and would like to know how it can be improved so it covers ...
Taurine asked 26/8, 2022 at 7:55
6
Solved
A multi-set is a set in which all the elements may not be unique.How to enumerate all the possible permutations among the set elements?
Overleap asked 30/10, 2013 at 7:19
3
Solved
I'm not sure if permutations is the correct word for this. I want to given a set of n vectors (i.e. [1,2],[3,4] and [2,3]) permute them all and get an output of
[1,3,2],[1,3,3],[1,4,2],[1,4,3],[2,...
Overdrive asked 12/11, 2011 at 22:37
© 2022 - 2024 — McMap. All rights reserved.