Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
4 votes
1 answer
119 views

Finding the earliest time we can schedule

We have a list of \$j \in \{1,\ldots,N\}\$ jobs with a processing time \$p_j\$ and a demand \$d_j\$ between 0 and 1. These are real numbers. Jobs require the fixed demand over the entirety of their ...
Titan's user avatar
  • 41
3 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 ...
XMehdi01's user avatar
  • 459
5 votes
4 answers
2k views

Automate the boring stuff with python - Character picture grid

Character Picture Grid Say you have a list of lists where each value in the inner lists is a one-character string, like this: ...
Jarne Vercruysse's user avatar
4 votes
3 answers
640 views

Determine whether two arrays have the same elements with the same multiplicities

I have written a Python function called comp that checks whether two given arrays have the same elements, with the same multiplicities. The multiplicity of a member ...
XMehdi01's user avatar
  • 459
1 vote
1 answer
51 views

Optimizing the Dig Pow function

I have written a Python function to solve the Dig Pow problem, where the goal is to find a number k such that the sum of each digit of n raised to a specific and ...
XMehdi01's user avatar
  • 459
2 votes
1 answer
362 views

Generating random number of randomly sized Squares/Rectangles using numpy arrays

I made classes to use in generating square/rectangular shapes on a texture. ...
Nyos's user avatar
  • 21
1 vote
0 answers
152 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
2 votes
1 answer
124 views

Returning all divisors of a number as a matrix with N X 2 dimensions

I have developed a class structure with methods to return a matrix from a single input array. The objective is to insert the middle value of the array so 2n remains ...
Dollar X's user avatar
5 votes
2 answers
315 views

Porting PHP's array_push to Python

I am new to Python but not new to PHP. I've started porting PHP APIs to Python hoping to learn the Python language along the way, currently trying to grasp List, Dict, Set, Tuple. I tried writing PHP'...
hanshenrik's user avatar
5 votes
1 answer
221 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
253 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
  • 101
4 votes
2 answers
1k views

Find all indices where value of array changes

I try to solve the following problem using Python: Given a 1-dimensional numeric array arr, find all indices where the value of ...
NerdOnTour's user avatar
0 votes
1 answer
161 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
  • 195
1 vote
1 answer
126 views

Minimum re-labeling to make an array as close as possible to another one

I have an array with integer labels in [0, n-1], say arr1=[1, 0, 3, 2] with n = 3. And then I have another array again with integer labels in [0, n-1], say arr2=[0, 0, 2, 3]. How can I find the ...
ApPs's user avatar
  • 13
3 votes
1 answer
121 views

Radio Number station code generator in python (or substitute characters with alternating words)

I'm rather fascinated by radio 'number stations', and in preparing for a D&D game, I wanted to use such a method to encrypt complex messages as seemingly random strings of words. I wanted to add ...
Anders Wulf's user avatar

15 30 50 per page
1
2 3 4 5
14