Skip to main content
The 2025 Developer Survey results are in. Explore insights into technology and tools, careers, community and more. View results.

All Questions

Tagged with
Filter by
Sorted by
Tagged with
4 votes
4 answers
1k views

Merging sorted integer arrays (without duplicates)

I have written a Python function called merge_arrays which takes two lists and returns the new list merge without duplicate. The function works as expected, but my ...
TAHER El Mehdi's user avatar
1 vote
0 answers
164 views

Smallest interval whose sum exceeds a threshold

In a non-negative 1D array x, we wish to find the shortest slice such that x[start:end] > threshold, with constraint that <...
OverLordGoldDragon's user avatar
5 votes
1 answer
232 views

Why is this tensor contraction so slow and how can I make it faster?

I am trying to calculate a specific complicated tensor contraction (of complex valued tensors) which appears as part of some other calculation and is called multiple times in a row, about 100 times or ...
HerpDerpington's user avatar
2 votes
1 answer
268 views

Replace nested for loops when assigning intial conditions in a 4-dimensional array

I create a 4-dimensional (x, y, z, t) array of zero values. I then set the initial values at t = Tmax. To do this, I use a nested for loop. I attempted to improve ...
Ruan's user avatar
  • 111
1 vote
1 answer
176 views

Python - Efficiently pick random data from an array, generate random UUIDs and save it all in an Excel table

I wrote the following prototype: ...
Munchkin's user avatar
  • 205
2 votes
2 answers
1k views

Variable length nested list of lists pad shape

Find shape of n-dim array that'd be formed from nested list of lists with variable lengths if we were to pad the lists to same length at each nest level. E.g. ...
OverLordGoldDragon's user avatar
3 votes
1 answer
97 views

Java i/o speed less than python i/o while printing an array

Motivation: I was solving an array based i/o problem and encountered Time Limit Errors, it was later found that the code for java ran roughly 10x slower than the ...
the_illuminated2003's user avatar
4 votes
1 answer
109 views

Dataframe transformation to numpy ndarray takes ages to complete

I would like to transform my dataframe into an array of fixed-sized chunks from each unique segment. Specifically, I would like to transform the ...
super_ask's user avatar
  • 143
3 votes
2 answers
443 views

Generating binary sequences without repetition

I am trying to generate sequences containing only 0's and 1's. I have written the following code, and it works. ...
learner's user avatar
  • 141
1 vote
1 answer
2k views

Count the number of neighbors

I have a numpy array called contour of \$N\$ coordinates (x,y) of dimension (N, 2). For each ...
Sword Fish's user avatar
3 votes
1 answer
88 views

The problem “Fun game” from a competition

I recently began to learn Python and encountered this problem. The condition: You and your friends are playing the next game. Friends write 𝑁 natural numbers in a ...
Daniil Savinov's user avatar
6 votes
1 answer
2k views

Improving the performance of interpolating between two arrays

The Problem I am currently writing a script that converts images into numerical array representation and then calculates "in-between" images based on linear interpolation between the start and end ...
Fnguyen's user avatar
  • 173
-1 votes
1 answer
57 views

Trying to get every 6th set of 4 bytes from a python array [closed]

I have an array of bytes 6144 bytes long. I want to extract a set of 4 bytes every 6th set of 4 bytes . So every 24 bytes I want to extract 4 of those bytes and join them in a new array. So ...
Jim Ruxton's user avatar
9 votes
3 answers
1k views

Creating an affinity-matrix between protein and RNA sequences

I wrote an algorithm that analyzes protein-RNA interactions and I found that the following function is the bottleneck that causes performance issues: ...
KaPy3141's user avatar
  • 263
2 votes
0 answers
152 views

Python list operation - merge adjacent cubes into minimum number of shapes

I am hoping to find a way to make the process a lot faster. The lists are made of rows of 6 numbers, i.e. [[float] * 6, ...]. The intent is to pass a list of cube ...
alex.l's user avatar
  • 21

15 30 50 per page