Optimization is the act of improving a method or design. In programming, optimization usually takes the form of improving the efficiency of an algorithm, or reducing the resources it requires (space in memory, on disk, or amount of network traffic, etc.).

learn more… | top users | synonyms (2)

6
votes
1answer
43 views

Optimization of aStar in Java

I'm currently looking to optimize my aStar algorithm as my last run through took roughly a minute to generate one path. I've never had to optimize before as I've never run into performance issues, so ...
0
votes
1answer
45 views

Drawing multiple Images

Im trying to draw a lot of fields image for my world generation, all is perfect 64 fps, but if i began to draw all the time the grass it became laggy, like 59 fps (something that musn't happen! :( ), ...
4
votes
0answers
40 views

Evolution simulation speed too slow to scale up

I'm trying to run this code but it is too slow. I know it is long and I don't expect people to read all of it, but I really need help optimizing the EvolvePop ...
2
votes
0answers
39 views

Typeahead Talent Buddy

Problem is Talent Buddy. Your task is to write a function that prints to the standard output (stdout) for each query the user name that matches the query if there are multiple user names ...
3
votes
1answer
45 views

Platform independant thread pool v4

This is a continuation of this question. Following the previous advise, the thread pool now can handle almost all types of input, except for one key form, where the function/functor requires one of ...
2
votes
1answer
36 views

Performance of Codility MaxCounter challenge solution

I'm doing some of the Codility challenges using Ruby. The current challenge is "The MaxCounter," which is described as: Calculate the values of counters after applying all alternating operations: ...
2
votes
0answers
19 views

Python softmatcher using difflib impracticably slow

I have a softmatch function (below) that takes a donor list and a new entry and looks to see if the given donor already exists. The data is not exact, so I have to use a softmatch to determine ...
6
votes
1answer
76 views

Russian doll envelops

Interview question from the interwebz You have a set of envelopes of different widths and heights. One envelope can fit into another if and only if both the width and height of one envelope ...
9
votes
1answer
352 views

Chunk Generation Performance in C#

I'm working on a game in C#, this game generate new chunk (infinite) when you move around. If I have > 1000 chunks in my list then it become laggy even though I only load the necessary chunks on my ...
3
votes
0answers
39 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 ...
4
votes
1answer
47 views

Ignore exceptions when changing column formula in Excel table

The new table feature on Excel is excellent and you can specify a column formula as well as exceptions on the column. However, if you want to change the column formula, Excel will rewrite the whole ...
3
votes
6answers
500 views

Code Hunter 2.06: Count occurrences of 'a' in a string

I'm playing Code Hunt on level 2.06 (loops). This level is about counting the number of "a" in a String. ...
4
votes
2answers
52 views

Cleaning up validator class

I updated my class with more functionality, but I kind if feel like it's a mess or that it can at least be improved by a bit readability, efficiency and/or DRY wise. Anybody who could see if that can ...
7
votes
2answers
348 views

Optimizing this inefficient TicTacToe configuration parser

On a programming contest I came upon this question: Given a partially played 3 × 3 tic-tac-toe configuration, write a program to determine which player will have a better chance of winning if the ...
4
votes
2answers
78 views

Validator refactored to be OO

Based on my previous post I completely re-factored my code to make it object oriented. Anything I could improve when it comes to: Object oriented code; Efficiency; Readability. Any other ...
1
vote
1answer
33 views

Search a file system for files that match a given pattern

My concerns with this code: Is there a more efficient way to find files by pattern in Python? Does os.walk() work in Windows? Is this code pythonic? Should ...
5
votes
2answers
56 views

Convert string to multiline text

I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength ...
8
votes
1answer
79 views

Finding largest subset of line segments that don't intersect

I completed a challenge of codeeval called BayBridges. It can be found here. I have uploaded my code on GitHub here. In summary, the challenge is to take a list of line segments, each specified by ...
4
votes
2answers
63 views

Increasing performance of OpenMP based advection equation solver for Xeon Phi

I am solving linear advection equation in order to learn parallel programming. I am running this code on Xeon Phi co processor. Below is a plot of how it scales up with increasing number of threads. I ...
1
vote
2answers
275 views

The efficiency of looping over nested dictionaries in Python

How to make the following code more efficient? ...
7
votes
2answers
102 views

Performance Issues: Finding Nearest Polygon

Finding the nearest polygon out of a list of polygons seems to be quite a challenge on performance, due to lack of optimization. Consider the following image: I'll give the concept behind this. The ...
0
votes
0answers
16 views

Sorting an input file by a key [closed]

I'm working on some assignments for a course I have coming up in the Fall, and I was wondering what you guys think of my solution (I know it's not the best, but I want to know what I could do better): ...
5
votes
3answers
260 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 ...
4
votes
2answers
89 views

Typeahead autocomplete functionality challenge

I'm working on a Talent Buddy challenge . In this challenge you have to design the autocomplete functionality of Twitter. You are given a list of queries and possible usernames. You have to return the ...
3
votes
1answer
59 views

Calculating if a point is within a polygon, or outside of it

Here is the function (along with its support functions): ...
5
votes
4answers
153 views

Faster method to find data using search word?

I need to search through a string array to find every occurrence of "Parameters Table", and between each "Parameters Table" and the next, get another string from a specified index (that remains ...
4
votes
3answers
64 views

String self-similarity

It's a string problem I have been making on Hackerrank. It is executing fine on all test cases except the last two. These last two test case are declaring it "Terminated due to time out". C programs ...
5
votes
3answers
73 views

Calculating the ranks of classmates' exam grades

The questions from hackerearth: Geeko is in worry now because an exam is coming up and he has to know what rank he can get on exams. So he goes back into the the school records and finds the ...
14
votes
6answers
2k views

Sherlock and The Beast

This is my solution to this question from Hackerrank. Given N (<= 100000), find the largest N-digit number such that: The number has only 3 and 5 as its digits. Number of times 3 ...
4
votes
1answer
49 views

Optimize iteration output to text file

I've written a piece of code which combines given letters in groups of n letters, and writes all the combinations in a text file. This is my first attempt and I wonder if there is an optimal way to do ...
1
vote
0answers
19 views

Optimizing jQuery table building by replacing appends with string concat

I've wrote some code to create a grid of data, however depending on the size of the grid being drawn, IE8 shows a warning message about a long running script. I've read that multiple appends are a ...
5
votes
1answer
62 views

Calculating “element-wise” the angles between two lists of vectors

Let's say you have two lists of vectors: v1s = [a, b, c] v2s = [d, e, f] I am interested in generating the following ...
3
votes
1answer
75 views

Is there a better way to write these two nested loops in Erlang?

Since one month, I'm learning Erlang and I like it so much. Today, I wrote an algorithm to solve a problem. Some time ago, I used two nested for loops in C# to ...
1
vote
0answers
24 views

Avoiding boundaries if-cases when filtering image matrix

I have the following MATLAB Code which I want to optimize. It's related to an image matrix (2D) which I want to filter. Though it is MATLAB code, the same problem would arise in C code. The problem ...
5
votes
1answer
54 views

How can I optimize this SQL ranking generator query?

I have a World Cup fixture app where people can guess the results of the matches. Everything is working great, but each time I update the ranking, it takes 20 minutes for just 3000 users. So there ...
3
votes
1answer
56 views

Quick Hull Algorithm implementation for higher dimensions

I tried to implement the Quick Hull Algorithm for computing the convex hull of a finite set of D-dimensional points. Here is the repository. Algorithm itself: ...
0
votes
0answers
18 views

Memory read/write access efficiency [migrated]

I've heard conflicting information from different sources, and I'm not really sure which one to believe. As such, I'll post what I understand and ask for corrections. Let's say I want to use a 2D ...
9
votes
2answers
72 views

Scalability of running commands from user input

Here is some code I have that has been extracted and shrunk down from a project of mine. ...
6
votes
2answers
373 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 ...
3
votes
2answers
67 views

Optimizing graph analysis

I've implemented the Floyd Warshall algorithm in this problem. However, as this is my first time in handling with adjacency list, I was not able to make it memory efficient. I used a 1000*1000 and ...
5
votes
0answers
149 views

Puzzle game with sequence numbers

I am currently developing a puzzle game that has sequence numbers. The player has to fill the grid with sequence numbers in ascending order. Starting from 1 the player can move horizontally or across ...
10
votes
1answer
91 views

Sieve of Atkins algorithm

I got the inspiration to write this algorithm from this question. The OP cited the Sieve of Atkin as one of the fastest ways to generate primes. So I figured I would give it a try: ...
6
votes
2answers
228 views

Pinging a URL with libcurl

I've asked a question about pinging a URL before, but I wanted something that was a bit shorter and still just as efficient. libcurl seemed to be the perfect answer. Here is my method: ...
2
votes
2answers
100 views
2
votes
2answers
46 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 ...
6
votes
2answers
119 views

Prime Number Speed

I know prime number programs have been beaten to death. I am have been programming for eight years (not that long, but I'm not in my 20s yet and I got a programming job straight out of high school so ...
3
votes
1answer
58 views

Displaying TimeSpan as largest interval (with units) - Part II

[This is a follow-up question to: Displaying TimeSpan as largest interval (with units). The code listed here has been refactored since the original question was posed. Please note that the scope of ...
5
votes
2answers
158 views

Efficient way to get every unique combination of “Pick 1 number from each Group of Numbers”

My question is: Using C# and/or Linq, how can this existing code be improved to be more efficient? (My "Complex" example takes about 5 seconds to run, how to make it faster?) What the code is ...
5
votes
3answers
283 views

Displaying TimeSpan as largest interval (with units)

The following method is used in a call center application to display an approximation of remaining time. The call center telephone operator would inform the caller that they could perform their ...
3
votes
2answers
81 views

Simplify an if else construct with assignment before if and else

I want to simplify an if: .. else: .. construct: ...