Tagged Questions
8
votes
4answers
2k views
Finding all indices of largest value in an array
I have the following code that gives me the indices of an array's largest value:
...
7
votes
2answers
137 views
Optimize a parallelized program to optimize train schedules
This loops through a vector of vector of A and adds a smaller array to a bigger one at a specified position+random shift. Then it is checked if it is a better solution, and if yes, it is stored, else ...
6
votes
4answers
3k views
Anagrams for a given input
This question is the first draft, my new revised code is here:
Anagrams for a given input 2.0
Here is my code that I wrote, which basically lists the anagrams for a given input.
I did this by ...
6
votes
2answers
377 views
Is there a way to optimise my Perlin noise?
I just started using Perlin noise a few days ago, and the results look quite good. But it takes over 3 seconds to calculate and draw a 1024x1024 bitmap of said noise. I use an array of 1024x1024 to ...
6
votes
2answers
153 views
Inversion of an array that contains indices
I have an array of length n that contains numbers from 0 to n-1 in random order.
I now want to "inverse" this array to one that where index i corresponds to the location of i in the source array.
...
6
votes
1answer
117 views
Is there a for-statement I can use to subtract elements in my 2-D in order to make my code more efficient and less-cumbersome?
This code works 100%, but I am trying to see if I can use a for-statement to make my second method less-cumbersome and more efficient instead of making so many ...
6
votes
1answer
86 views
Optimize YUV channel splitting function
The input pointer *data contains the data that needs to be split into different arrays and put in yuvInput. Each pixel is 32 ...
5
votes
3answers
267 views
How to increase performance/speed of code that uses .Count() on Lists?
The Test
PublicQuestion_ComplexTest
is taking around 1600ms (1.6 seconds) to run, but used to take 92ms. I have a feeling this is because of recent code changes ...
5
votes
1answer
188 views
Manchester encoder/decoder
I have written a Manchester Encoding encoder / decoder based on my misconception of how it works (whoops). My encoder accepts an array of ones and zeroes, and returns the 'manchester encoded' data ...
5
votes
1answer
305 views
Merging two array of classes
I have this function that should merge two array of classes when id of array1 is equal to id of array2.
For simplicity I ...
5
votes
1answer
435 views
How is my quarterly sales statistics program?
Am I making good use of a 2-D array? Is this code inefficient? I am supposed to receive input from 6 departments for 4 quarterly periods in Java.
My assignment asks:
Quarterly Sales Statistics
...
5
votes
1answer
136 views
Optimize Cython code with np.ndarray contained
Can someone help me further optimize the following Cython code snippets? Specifically, a and b are ...
4
votes
4answers
3k views
4
votes
2answers
143 views
Counting letters program. Notation and optimisation help
I am writing a program in C running on UNIX which counts the number of each letters in a input text file. For a file like this:
The cat sat on the green mat
The output would be like this:
...
4
votes
2answers
20k views
Reading a line from a text file and splitting its contents
I have this kind of file structure
MALE:FooBar:32
FEMALE:BarFoo:23
Where I would want to identify the gender and age of person, ...
4
votes
2answers
125 views
Why is this program for extracting IDs from a file so slow?
This is roughly what my data file looks like:
...
4
votes
1answer
52 views
Computationally efficient way of comparing and merging like object keys
Though I can achieve most ends via a series of conditionals and arithmetic, especially when iterating over or comparing arrays I frequently hear of much more efficient implementations.
Hailing from ...
4
votes
2answers
3k views
Fastest way to iterate over Numpy array
I wrote a function to calculate the gamma coefficient of a clustering. The bottleneck is the comparison of values from dist_withing to ...
4
votes
1answer
240 views
Optimizing Python / Numpy Code
So I'm implementing a version of the mean shift image processing algorithm for color segmentation in python/numpy.
I've written a pure numpy version of the actual mean shifting per pixel (which I ...
4
votes
0answers
75 views
Creating collisions for a breakout style wall
I am creating a breakout style game as an introduction to JavaScript, and would like to know whether the way I have gone about doing this is efficient/viable. As well as needing assistance with ...
3
votes
2answers
469 views
Optimizing unboxed array operations in Haskell
Consider this simplified code which successively permutes array elements:
...
3
votes
1answer
236 views
C# Array Mutator Methods to mimic JavaScript Array Mutator Methods
Between .NET's built-in collection libraries and LINQ extension methods, I never have to use arrays. An unfortunate consequence of this is that I am probably less competent in working with this very ...
3
votes
0answers
48 views
Python Multiprocessing: Using mutable ctype arrays seems to work, yet I am not seeing significant speed-up. Why?
As a brief introduction, I am student working on a body of code which forms part of my Masters' research - this is my first question on SO. My background is in physics and mathematics, so I will ...
3
votes
0answers
203 views
Implementing recursive filters with Haskell/Repa
I recently learned Haskell, and I am trying to apply it to the code I use in order to get a feeling for the language.
I really like the Repa library since I manipulate a lot of multi-dimensional ...
2
votes
4answers
317 views
A more efficient enqueue algorithm in Java
So I have this simple code in Java. It enqueue (adds) and element to the end of the queue (implemented by an ArrayList) without ...
2
votes
2answers
300 views
Remove repeated words from a 2D character array
This code removes repeated words from a word array (2D char array). I want to optimize this as much possible for speed.
...
2
votes
2answers
47 views
Importing tab delimited file into array
I am needing to import a tab delimited text file that has 11 columns and an unknown number of rows (always minimum 3 rows).
I would like to import this text file as an array and be able to call data ...
2
votes
1answer
75 views
Painting Tom Sawyer's Fence - programming on Free Pascal
Tom Sawyer has many friends who paints his fence. Each friend painted
contiguous part of the fence. Some planks could stay unpainted, some
could be painted several times. Program must output ...
2
votes
1answer
252 views
Anagrams for a given input 2.0
This question follows on from :Previous Question
Here is what my reworked code looks like. I neatened it up as much as I could. Changed some of the semantics of it. I also tried to add some faster ...
2
votes
0answers
64 views
Optimization Algorithm: Too much memory consumed
What I have here is an implementation of an optimization algorithm called the covariance matrix adaptation evolutionary strategy. I am using this algorithm to optimize the position of wind turbines ...
1
vote
1answer
509 views
Can anyone check my code?
Can anyone check this code of mine I want to improve it . give me suggestion or tips and tricks to make this code of mine more efficient
Here's my code, I want you guys to give me advices and tips ...
1
vote
4answers
7k views
Find the second-largest number in an array of elements
I have written this code to find second largest element in an array of random integers. If it needs to be optimized, then do comment on it. First of all I'm populating all the elements into the list ...
1
vote
1answer
1k views
First non-repeated character in a string in c
Write an efficient function to find the first non-repeated character
in a string. For example, the first non-repeated character in "total"
is 'o' and the first non-repeated character in ...
1
vote
3answers
88 views
Improving function that compares two strings
I'm learning C and have made this very simple function to compare two strings. I would like to know how it can be improved:
...
1
vote
2answers
839 views
Javascript querystring to object conversion
The below code converts the window.location.search querystring into a JavaScript object. In particular, if a key occurs more than once the resulting value in the object will be an array. Please feel ...
1
vote
1answer
52 views
Optimize jQuery code includes autocomplete function for different input box with different autocomplete content
I have this code below for autocomplete feature of several inputTextbox. The input box also share same class".wikiInput". When user typed something in either of them, a relevant autocomplete dropdown ...
1
vote
3answers
664 views
Optimize Array.indexOf
How can I optimize checking a value in recursion before operating on it? I'm using Array.indexOf (this is Javascript)
...
1
vote
1answer
70 views
Simple Nick Namer Review Request
Hi guys this was my first project, I redid it after getting critique on my second project.
Can I please get some Critique on this project too?
The code is pasted in sections, but it appears exactly ...
1
vote
1answer
217 views
C arrays and loops optimization
I am writing a program for learning purposes that takes an input of a file structured similarly to:
...