All Questions
Tagged with array python-3.x
39 questions
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:
...
0
votes
1
answer
38
views
Mangle words to bytearray of lo/hibytes
I would like to refactor the following code snippet adapted from a project I'm involved. It is part of a code to control power outlets via network. The code snippet was written by myself based on the ...
3
votes
1
answer
853
views
Divide array into three disjoint sets with equal sum
Problem definition : Array partition problem
Given an array of positive integers, divide it into three disjoint subsets having equal sum. These disjoint sets cover the complete array.
Example
Input: [...
2
votes
2
answers
86
views
Send an array of files and return the first one that exists
I have a little project, chuy, which is basically a copy of Make.
By request of users I have added support for toml configuration, since originally it only accepted ...
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 ...
3
votes
1
answer
75
views
Generating multiple new arrays using numpy
Say I have the following two different states:
state1 = [0, 1, 0, 1, 1]
state2 = [1, 1, 0, 0, 1]
And I want to generate n number of new states by only changing the ...
3
votes
2
answers
537
views
Multiplying numpy arrays
I have written a function to multiply two numpy arrays.
...
8
votes
2
answers
784
views
Optimize function that returns length of a subarray
I did an exercise today on where the task is to write a function that returns the length of the longest subarray where the difference between the smallest and biggest value in the subarray is no more ...
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 ...
6
votes
1
answer
354
views
Applying gaussian blur on RGBA images
I designed the code and it works quite well for images of lower res. However my program takes a lot of time and ram to display higher res images (occupies 2GB RAM for 4k images and takes 20 minutes). ...
2
votes
1
answer
841
views
Re-implementing an Array Class in Python
I gave an attempt at reinventing the wheel and recreate list methods using my own Array Class to broaden my understanding about lists. I would like advice regarding efficiency, and in implementing ...
2
votes
1
answer
388
views
Dice roller - python
I am about to graduate with my Associates degree in Math and will soon go for my bachelors. I've decided with two years of school left its best if I start learning to program. I am starting with ...
0
votes
2
answers
751
views
Find the maximum value of | Ai - Aj | + | i - j |: [closed]
hackerearth.com practice problem Can you solve it?:
Given an array 'A' consisting of 'n' integers, find the maximum value of the following expression:
\$\lvert A_i - A_j\rvert + \lvert i - j\rvert\...
3
votes
3
answers
659
views
Given an array, find all its elements that can become a leader
I was successful in solving a challenge in codility, but my solution failed performance tests. How can I improve my solution?
Challenge:
Integers K, M and a non-empty array A consisting of N ...
1
vote
2
answers
507
views
Maximum contiguous sum in an array
The following code is my solution for the following Daily Coding Challenge
Given an array of numbers, find the maximum sum of any contiguous
subarray of the array.
For example, given the ...