Skip to main content

All Questions

0 votes
2 answers
114 views

Create lists with 3 levels, containing every combination of sub list(s) values

I am currently stuck with the following problem (I could not find solution already on here that really fitted this): I have three lists a = [a, b, c], b = [1, 2, 3] and c = [0.1, 0.2, 0.3]. I would ...
Ryan's user avatar
  • 11
2 votes
1 answer
3k views

How to produce permutations with replacement in Python

I am trying to write some code (as part of a larger script) to develop numpy arrays of length n, which I can use to change the sign of an input list of length n, in all possible ways. I am trying to ...
Karenv's user avatar
  • 23
13 votes
3 answers
7k views

Faster numpy-solution instead of itertools.combinations?

I'm using itertools.combinations() as follows: import itertools import numpy as np L = [1,2,3,4,5] N = 3 output = np.array([a for a in itertools.combinations(L,N)]).T Which yields me the output I ...
Khris's user avatar
  • 3,212
1 vote
1 answer
535 views

Generate all polynomial terms of certain degree

Having list of n terms ts = ['t1','t2','t3',...,'tn'] there is a task to achieve all possible q-length combinations of this terms. Thus, for ts = ['t1','t2'] q = 4 the answer will be [['t1','t1','...
Mr Tarsa's user avatar
  • 6,651
-1 votes
1 answer
66 views

Combinations of chars via a generator in Python

I am trying to get all the combinations with replacement (in other words, the cartesian product) of strings with length(8) . The output is too big and I am having trouble storing it in memory all at ...
RetroCode's user avatar
  • 332