Tagged Questions
Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.
-2
votes
0answers
19 views
Google foobar challenge bringing_a_gun_to_a_guard_fight [on hold]
I am stuck with this google foo bar challenge
Uh-oh - you've been cornered by one of Commander Lambdas elite guards! Fortunately, you grabbed a beam weapon from an abandoned guardpost while you were ...
5
votes
0answers
42 views
File system monitor which watches for file/directory changes even after the process is stopped
Building off the python FileSystemEventHandler and DirectorySnapshot classes, my goal is for a number of projects that I am ...
-3
votes
0answers
31 views
Building lists of users and roles for ASP.Net/C# user-management page
I have a user management page that works decently right now with the exception it can take about 5 seconds to load. Testing shows that is it the code I am using to build lists. I was hoping to get a ...
1
vote
2answers
64 views
Optimizing a binary search algorithm
I have implemented a binary search algorithm in C#. Can anyone give me suggestions on improving its effectiveness?
...
0
votes
0answers
26 views
Retrive data for Table from m2m through field is slow
The problem is in the for loop because it do many repetitions and they are slow. For generate a table 40x40 it need about 20 seconds (I will need a table 200x200).
I think this is the relevant code. ...
0
votes
0answers
15 views
Dynamically set angular directive template
I have recently upgraded to AngularJS 1.5 and as the title says, I want to use different templates depending on a value in the ...
2
votes
1answer
54 views
determine if two strings with unrecognized letters are from the same text
Given two Strings S and T of N=>1 and M=>1 characters, respectively, with unrecognized letters (an unrecognized letter is marked by "?", for brevity, every group of K consecutive "?" characters is ...
2
votes
1answer
30 views
4
votes
2answers
58 views
Segmented Sieve of Eratosthenes
I implemented this for the Prime Generator problem on SPOJ, but I am only getting 0.01s run-time, and would like to be able to match the run-times of the top submissions, which are all 0.00s.
What ...
-4
votes
0answers
27 views
What is the best/Optimal way to refactor multiple for loop? [on hold]
Here is my code which is going to through multiple for loops to get the matching product attribute.
I have single product with attributes trying to find out the ...
2
votes
0answers
26 views
Counting items that have a matching attribute
Here is my code which is going to through multiple for loops to get the matching product attribute.
I have single product with attributes trying to find out the ...
-1
votes
0answers
16 views
Batch file - Calling same label multiple times [on hold]
I've written a batch script but there are lots of call that should be removed. Does anyone have some ideas about simplifying my script?
...
8
votes
2answers
69 views
Short and Messy Polybius Square
I attempted to recreate the Polybius square, also called the Polybius checkerboard, which was used in Ancient Greece for cryptography. Since it is an uncommon cipher, it is nowhere on Code Review.
...
1
vote
1answer
38 views
Hackerrank Gemstones Solution
I'm looking for any possible improvements in terms of memory usage and speed, but really any advice is welcome.
Problem statement:
John has discovered various rocks. Each rock is composed of ...
5
votes
0answers
113 views
+50
Super calculator in C
For my mathematical research, I am to deal with very large numbers and I know that the standard C types are not going to stand a chance against them due to their limited capacity, so I decided to ...
4
votes
2answers
261 views
CodeWars: Gap in Primes
I wrote a javascript code for finding the first two consecutive prime numbers (that doesn't have divisors except one and itself) with a specific gap between them. It works well but take too much time ...
1
vote
1answer
47 views
Find and print all numbers in a comma-delimited string using sscanf
I want to find all of the whole numbers in a string that starts with { and ends with }, and uses ...
-3
votes
0answers
20 views
Consolidating event listeners, or being unnecessarily redundant? [on hold]
In my project, I'm at a point where I need to attach a handful of event listeners to various HTML elements (buttons). A few, in particular, share a parent element, which makes me want to use a ...
3
votes
2answers
51 views
Calculate XOR of many consecutive and non-consecutive numbers
question:
answer(start,length)
#start is the starting number of the matrix
#length is number of rows.
example 1:
answer(0,3)
...
6
votes
2answers
127 views
Find K biggest numbers in the array
I was trying to implement method number 2, from this article.
Method 2 (Use temporary array) K largest elements from arr[0..n-1]
Store the first k elements in a temporary array temp[0..k-1]....
2
votes
2answers
61 views
Finding the coordinates on an edge of a square
I wrote a calculation that finds coordinates on an edge of a square, but it came out as a really long nested tangle of conditions. After some reduction and finding common pieces I arrived at this ...
1
vote
1answer
48 views
Incrementing colors
I just started messing around with Java's BufferedImage. I had an idea to try to encode a message into a picture by coloring each pixel a certain color that ...
3
votes
2answers
55 views
Validation Extension method performance
I'm writing a simple set/framework of extension methods for argument/parameter validation. What I'm mostly concerned about, ATM is the performance, against the simpliest boilerplate
...
3
votes
0answers
79 views
Selecting kids for a Christmas play with similar heights
I am doing this problem on SPOJ. The challenge is :
My kid's kindergarten class is putting up a Christmas play. (I hope he gets the lead role.) The kids are all excited, but the teacher has a ...
6
votes
2answers
56 views
Printing mutual anagrams
Question:
An anagram is a word that can be written as a permutation of the
characters of another word, like "dirty room" and "dormitory"(ignore
spaces). However, "the" and "thee" are not ...
6
votes
4answers
245 views
Balanced Parentheses checker in Python
I'd appreciate feedback on the code itself (style, performance optimization (both space and time)), and also on the algorithm (because I think this is typically implemented using a stack).
The ...
2
votes
2answers
248 views
Processing lots of JSON objects
I want to process a ton of JSON objects as quickly as possible.
I've done my best to make the processing as concise and efficient as I can.
How can I make it more efficient?
...
2
votes
2answers
71 views
Search through each file in a directory, list number of instances of searched string
I am trying to open each file listed in Sheet2 Column A, search for a string of text located in Sheet3 Cell B1, list the number of instances this string appears in each particular file in Sheet3, and ...
4
votes
1answer
41 views
Merging rows in excel using VBA
For the first time I've worked in Excel VBA to find rows in my dataset that contain the same adress as another entry in a cluster. These entries have to be merged and the row then is deleted. I've ...
-4
votes
0answers
33 views
OpenMP : parallel implementation of independent loops [closed]
The below code snippet was optimized using OpenMP, as the three functions were taking independent arguments and there were no loop dependencies in three loops I tried to use "omp parallel" along with ...
5
votes
3answers
1k views
Combining .txt files
A guy at the company I work for needed a small application that would combine multiple text files into one, larger text file.
I wrote a console application for this. it seems pretty efficient, but I ...
3
votes
2answers
47 views
Custom UUID based on time
I've been using random UUIDs—from Rust, e.g. Uuid::new_v4()—for my primary keys in a MySQL database. I recently happened across this, which suggests ...
2
votes
1answer
59 views
Scrapy Username Spider
This currently starts out with the speed of 2000 pages/min but shortly after starting it becomes very slow with a speed of about 200 pages/min. Why is this happening? How can I improve this scraper?
<...
3
votes
2answers
40 views
Pairwise distance and residual calculation
I have a code for calculating the pairwise distances and the residuals of my data (X, Y, Z). Data is quite large (average of 7000 rows) and so my interest is code efficiency. My initial code is
...
2
votes
1answer
61 views
Flattening a nested map [closed]
We're migrating our streaming ETL application from Python into Clojure,
the hottest part of the code isn't yet performing as well as our existing
implementation. This looks to be down to the ...
1
vote
0answers
15 views
SICP - exercise 2.5 - Represent pairs of nonnegative integers
Exercise 2.5. Show that we can represent pairs of nonnegative
integers using only numbers and arithmetic operations if we represent
the pair a and ...
3
votes
1answer
81 views
KMP algorithm searching from the right
The generic version of extension method is aimed to work like String.LastIndexOf which can search t from the last position of <...
0
votes
1answer
41 views
Displaying weather data from an Arduino
Please review my code, for performance and readability.
3 issues I am facing are
Uncaught Exception : out of memory (in firefox)
randomly Failed to load resource: The request timed out.
Even if the ...
7
votes
1answer
112 views
A Moses's worthy string splitter
I am trying to perfect my string splitter's performance, to be more fast, more easy to maintain if someone else reads it and more readable code-wise.
Context ,Scope and Objectives
Where I work we ...
7
votes
0answers
82 views
Vectorizing the product of an array of complex numbers
I am trying to write fast/optimal code to vectorize the product of an array of complex numbers. In simple C this would be:
...
0
votes
1answer
37 views
Fire Scheduling with Triggers in CMMS
I worked on cmms project .
I have some scheduling , esch of schedule have some triggers (e.g,. Bymeter , byActivity ,ByPeriod).
I wrote some methods to generate workOrder for each Schedule if ...
135
votes
4answers
21k views
Dijkstra path finding in C# is 15x slower than C++ version
I'm implementing Dijkstra's algorithm with a priority queue for a game I'm developing in Unity with C#. I was a bit disappointed with the performance, so I decided to port the code to C++ and see if ...
1
vote
1answer
69 views
Split string into “n” lengths with padding
I quickly wrote a short program to split a string into \$n\$ lengths with variable-character padding:
...
3
votes
1answer
65 views
Measuring the length of binary numbers in English words in C
Inspired by this question (link to original video), I decided to write some code in C to perform this task, and it is much faster than the Python code, even when run with PyPY, up to a billion, it ...
2
votes
1answer
73 views
Storing and accessing 3D struct array efficiently
I have a structure, and have come up with 3 different 3D arrays to store it in. The thing is, optimization is not my specialty and I need advice from someone who knows their stuff regarding best ways ...
2
votes
2answers
48 views
Crank-Nicolson. Advection - Diffusion. Perfomance
I am writing an advection-diffusion solver in Python. I am quite experienced in MATLAB and, therefore, the code implementation looks very close to possible implementation in MATLAB. I implemented the ...
4
votes
1answer
56 views
Simple Affine cipher
The affine cipher is a simple mathematical substitution cipher. If you're interested in the details behind how it works, this page goes further into detail.
After writing a program to encrypt and ...
5
votes
5answers
148 views
Simply print the string backwards
This code is very, very simple, but I was wondering how it could be improved:
...
7
votes
2answers
93 views
Neural Networks in C
This block of code is one of my first C header files I have made; it's ported from a Python program I made a few months ago for a project.
I was just looking for advice on how to increase the ...
10
votes
4answers
750 views
Random string of variable length generator
Below is my code for generating a random string of random length. I am using it in integration tests. Currently I have almost 2000 tests running each time a commit is made to master and a few of those ...