Skip to main content
-3 votes
0 answers
106 views

I want to generate a permutation to check it satisfies an equation before I generate another

I'm writing code to find a convex n-gon with side lengths 1^k,2^k,...,n^k with equal interior angles. If we formulate this as an algebra problem on the complex plane, this is satisfied using the ...
Arianna Stocks's user avatar
2 votes
1 answer
153 views

How to create possible sets of n numbers from m-sized prime number list?

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
  • 26.4k
2 votes
2 answers
92 views

What's the fastest way of skipping tuples with a certain structure in a itertool product?

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
1 answer
51 views

How do I use a custom mapping (sort) on my itertools for loop so that I can print specific strings first?

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
30 views

Tupe video clips list, the other matching durations. Itertools can find triplets that total 90 sec from duration list. Want to print clip names

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
44 views

Dealing with `StopIteration` return from a next() call in Python

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,702
-3 votes
2 answers
65 views

Python itertools product aborting

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
60 views

Type hint for itertools.product doesn't know length of elements

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
102 views

Efficiently Handling Large Combinations in Polars Without Overloading RAM

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,027
1 vote
2 answers
210 views

Finding number of differences between strings in Polars

I have a Polars dataframe in which the cells contain a sequence of single digits as a string of characters, and I want to find the number of differences between the elements of the string. For example:...
Josh9999's user avatar
0 votes
0 answers
32 views

Speed Up Mouse Clicking Automation With PyAutoGUI

I have a program where I'm automating mouse clicking in a game. The program consists of four different coordinates on my screen, and iterating through all 3-length permutations of those coordinates ...
Buracku's user avatar
  • 37
1 vote
1 answer
100 views

Is there an iterator in Python that gives the product but omits permutations of the classes itself?

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
2 votes
1 answer
56 views

itertools.product in dataframe

Inputs: arr1 = ["A","B"] arr2 = [[1,2],[3,4,5]] Expected output: short_list long_list 0 A 1 1 A 2 2 B 3 3 B 4 4 B 5 Current output: short_list long_list 0 A [1, 2] 1 A [3, 4, 5]...
Gооd_Mаn's user avatar
  • 1,076
0 votes
0 answers
23 views

Iterate over dependent iterators together [duplicate]

So here is my scenario: def gen1(a): for item in a: ...
Ben Farmer's user avatar
  • 2,894
0 votes
1 answer
59 views

Python Flask App Freezes with Large Data: Seeking Optimization Advice

I'm developing a Python Flask application to find combinations of numbers from dataset that sum up to a target value. The app works fine with smaller datasets but freezes when processing larger ...
koravik's user avatar

15 30 50 per page
1
2 3 4 5
210