Skip to main content
0 votes
1 answer
158 views

I have a list d_n of n integers and the results Z_klm of a function fun(dk, dl, dm) for all binom(n, 3) combinations without repetition (k, l, m) out of d_n indices. Now, for all binom(n, 2) ...
Max Pierini's user avatar
  • 2,355
4 votes
2 answers
95 views

I'm trying to create a list of subsets that add to a particular sum (e.g. 12), but with a limit on the occurrences of some of the terms. The base set to iterate on is {1,2,3,4,5,6,7,8}. I'm trying to ...
wwwm's user avatar
  • 41
3 votes
4 answers
217 views

I need to get the Cartesian product of a dictionary {str: Fraction} with itself, but currently need to "loop" through the dict twice, once for the keys and once for the values. The ...
Ameya's user avatar
  • 1,770
2 votes
2 answers
251 views

I have a list of elements where I want to remove only consecutive duplicates, not all duplicates. For example: data = [1, 1, 2, 2, 2, 3, 1, 1] I want to get: [1, 2, 3, 1] This is different from using ...
sam's user avatar
  • 45
5 votes
2 answers
185 views

It seems that even when islice would theoretically be better, in practice, it is slower than just using slice. So I am a bit puzzled by the difference in performance between the usage of slice and ...
Mathias Sven's user avatar
1 vote
1 answer
208 views

Let's assume there is an event and within this event there are multiple outcomes that can co-exist. An example would be a tennis game where A plays against B and B serves. A couple of possible ...
HJA24's user avatar
  • 416
2 votes
1 answer
185 views

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 ...
theozh's user avatar
  • 27.2k
3 votes
2 answers
118 views

I have to process a huge number of tuples made by k integers, each ranging from 1 to Max_k. Each Max can be different. I need to skip the tuples where an element has reached is max value, in that case ...
user58327's user avatar
1 vote
0 answers
72 views

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 ...
user27394478's user avatar
-1 votes
1 answer
37 views

I can get the triplets with iteration tools in durations list but I want to get matching clips from spots list. Tried to marry two list but dont know how to apply iteration combo on one part of the ...
vjeko sa's user avatar
1 vote
2 answers
67 views

I'm using the below to skip a group of records when a certain condition is met: if (condition met): ... [next(it) for x in range(19)] Where it is an itertuples object created to speed up ...
Chris's user avatar
  • 1,700
-2 votes
2 answers
79 views

When running the code below, python aborts and closes the python prompt: >>> import itertools >>> nComb = 2 >>> t = range(nComb) >>> combs = list(itertools.product(...
Memória de Cálculo's user avatar
1 vote
1 answer
125 views

I am adding type hints to an old code of mine. However, I find with a "problem" I don't know how to solve. I have a function that looks like: def f(x: tuple[tuple[int, int], ...]): ... ...
Gaussian97's user avatar
2 votes
0 answers
146 views

I have a list of n values (in my case, n=19), and I want to generate all possible combinations of these values. My goal is to use each combination as a filter for a Polars DataFrame, iterate over the ...
Simon's user avatar
  • 1,209
1 vote
1 answer
119 views

Assume that I want to assign a color to 5 different balls and have 3 colors r,b and g. I would like to iterate over all these combinations. Preferably I would want to omit combinations that are equal ...
Trailblazer's user avatar

15 30 50 per page
1
2 3 4 5
210