cartesian-product Questions
8
Solved
To create all possible combinations of two sets of parameters and perform an action on them, you can do:
setOf(foo, bar, baz).forEach { a ->
setOf(0, 1).forEach { b ->
/* use a and b */
}...
Unreserve asked 12/12, 2018 at 18:38
3
I have 2 series, bids and asks, indexed on time.
Some timestamps are duplicated, indicating a price was updated more than once, but the timestamp resolution was too large to capture the differenc...
Mcbroom asked 14/7, 2019 at 21:52
11
Solved
I've a vector of vectors say vector<vector<int>> of different sizes as follows:
vector<vector<int>> items = {
{ 1, 2, 3 },
{ 4, 5 },
{ 6, 7, 8 }
};
I want to create comb...
Matron asked 11/3, 2011 at 22:28
3
Solved
There is an excellent C++ solution (actually 2 solutions: a recursive and a non-recursive), to a Cartesian Product of a vector of integer vectors. For purposes of illustration/simplicity, let us ju...
Hautboy asked 11/12, 2012 at 3:4
16
Solved
I wish to produce the Cartesian product of 2 lists in Haskell, but I cannot work out how to do it. The cartesian product gives all combinations of the list elements:
xs = [1,2,3]
ys = [4,5,6]
car...
Scottie asked 7/11, 2010 at 21:13
3
Solved
I think this is a common combinatorics problem, but I can't seem to find a name for it or any material about it. I am doing this in Python and numpy, but if there is a fast matrix method for this, ...
Furrier asked 19/7, 2011 at 16:3
20
Solved
How can I get the Cartesian product (every possible combination of values) from a group of lists?
For example, given
somelists = [
[1, 2, 3],
['a', 'b'],
[4, 5]
]
How do I get this?
[(1, 'a', 4...
Dichromatic asked 10/2, 2009 at 19:54
7
I have a list of sets, and I wish to sample n different samples each containing an item from each set.
What I do not want is to have it in order, so, for example, I will get all the samples necess...
Apothem asked 8/2, 2018 at 13:34
5
Solved
I would like to generate all the possible combinations of the elements of a given number of vectors.
For example, for [1 2], [1 2] and [4 5] I want to generate the elements:
[1 1 4; 1 1 5; 1 2 4;...
Hitt asked 12/11, 2010 at 14:56
4
Solved
Hope that someone can help me with a cartesian product in Google Sheets. I have data in two separate columns and wish to create all possible combinations of the two columns in a separate tab. The f...
Clew asked 17/1, 2021 at 21:54
14
Solved
I have two pandas dataframes:
from pandas import DataFrame
df1 = DataFrame({'col1':[1,2],'col2':[3,4]})
df2 = DataFrame({'col3':[5,6]})
What is the best practice to get their cartesian product ...
Ethbun asked 7/11, 2012 at 12:33
5
Solved
I have a class structure like so:
Person
Dogs (dog 1, dog 2, etc)
Puppies (puppy A, puppy B, etc)
There is one person. He has 1..n dogs. Each dog has 1..n puppies.
I want a list of all the poss...
Armanda asked 1/11, 2010 at 22:43
3
Solved
While writing a program that finds all the different combos for a list, I found a lot of threads about using intertools.product() instead of intertools.combinations_with_replacement(), as I have be...
Amour asked 20/1, 2014 at 0:51
18
Solved
I have two numpy arrays that define the x and y axes of a grid. For example:
x = numpy.array([1,2,3])
y = numpy.array([4,5])
I'd like to generate the Cartesian product of these arrays to generat...
Nan asked 21/6, 2012 at 18:30
5
Solved
This question asks how to compute the Cartesian product of a given number of vectors. Since the number of vectors is known in advance and rather small, the solution is easily obtained with nested f...
Zayin asked 10/3, 2010 at 18:10
8
Solved
I have a Google SpreadSheets doc with three columns A, B and C.
I need to populate the Column C with all the possible combinations of the values in Columns A and B. Please take a look a the captur...
Croatian asked 15/3, 2017 at 9:36
36
Solved
How would you implement the Cartesian product of multiple arrays in JavaScript?
As an example,
cartesian([1, 2], [10, 20], [100, 200, 300])
should return
[
[1, 10, 100],
[1, 10, 200],
[1, ...
Cavin asked 6/9, 2012 at 15:59
1
Solved
I am rewriting a python program into rust and I am struggling to translate this line:
itertools.product(range(0,8), repeat=n)
What I am trying to achieve is something like this: https://pastebin.co...
Antiworld asked 24/3, 2023 at 13:35
1
I am trying to write a test with JUnit 5 which should test multiple combinations of some parameters. Essentially I want to test some cartesian product of inputs from different sources. Consider the...
Lamee asked 25/8, 2020 at 11:35
11
Solved
Do you know some neat Java libaries that allow you to make cartesian product of two (or more) sets?
For example: I have three sets. One with objects of class Person, second with objects of class ...
Mindszenty asked 3/4, 2009 at 14:17
10
Solved
The R function expand.grid returns all possible combination between the elements of supplied parameters. e.g.
> expand.grid(c("aa", "ab", "cc"), c("aa", "ab", "cc"))
Var1 Var2
1 aa aa
2 ab aa
...
Hiccup asked 18/6, 2013 at 14:11
2
Solved
I want to get the Cartesian product of a, b, c, d:
a = ['a1']
b = ['b1', 'b2']
c = ['c1', 'c2', 'c3']
d = ['d1']
Here is code in Ruby:
e = [b, c, d]
print a.product(*e)
Output is:
[
["a1", ...
Ascocarp asked 12/3, 2015 at 5:49
3
Solved
I am trying to test some other Python code repeatedly, using all possible combinations of values for six different parameters. For each parameter I want to iterate over a range of values with a giv...
Solfatara asked 24/6, 2012 at 3:30
8
Solved
I want to have a binary operator cross (cross-product/cartesian product) that operates with traversables in Scala:
val x = Seq(1, 2)
val y = List('hello', 'world', 'bye')
val z = x cross y # i can...
Microampere asked 6/2, 2013 at 22:35
2
If I want to create a Cartesian product of a list of lists in Haskell, I can do this:
product [] = [[]]
product (xs:xss) = concatMap (\k -> map (k:) (product1 xss)) xs
or even this:
sequence...
Karalynn asked 6/12, 2017 at 7:22
1 Next >
© 2022 - 2024 — McMap. All rights reserved.